mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 02:30:47 -08:00
refactor: delete unused from edit workspace
This commit is contained in:
parent
4bf0f686d4
commit
7e8b78fdc7
2 changed files with 1 additions and 59 deletions
|
|
@ -12,16 +12,13 @@ import ListItemText from '@material-ui/core/ListItemText';
|
||||||
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
|
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
|
||||||
import Switch from '@material-ui/core/Switch';
|
import Switch from '@material-ui/core/Switch';
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import FormGroup from '@material-ui/core/FormGroup';
|
|
||||||
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
|
||||||
import Checkbox from '@material-ui/core/Checkbox';
|
|
||||||
|
|
||||||
import connectComponent from '../../helpers/connect-component';
|
import connectComponent from '../../helpers/connect-component';
|
||||||
import getMailtoUrl from '../../helpers/get-mailto-url';
|
import getMailtoUrl from '../../helpers/get-mailto-url';
|
||||||
|
|
||||||
import defaultIcon from '../../images/default-icon.png';
|
import defaultIcon from '../../images/default-icon.png';
|
||||||
|
|
||||||
import { getIconFromInternet, save, updateForm } from '../../state/dialog-edit-workspace/actions';
|
import { save, updateForm } from '../../state/dialog-edit-workspace/actions';
|
||||||
|
|
||||||
const styles = theme => ({
|
const styles = theme => ({
|
||||||
root: {
|
root: {
|
||||||
|
|
@ -311,7 +308,6 @@ const mapStateToProps = state => ({
|
||||||
});
|
});
|
||||||
|
|
||||||
const actionCreators = {
|
const actionCreators = {
|
||||||
getIconFromInternet,
|
|
||||||
updateForm,
|
updateForm,
|
||||||
save,
|
save,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
import {
|
import {
|
||||||
UPDATE_EDIT_WORKSPACE_DOWNLOADING_ICON,
|
|
||||||
UPDATE_EDIT_WORKSPACE_FORM,
|
UPDATE_EDIT_WORKSPACE_FORM,
|
||||||
DIALOG_EDIT_WORKSPACE_INIT,
|
DIALOG_EDIT_WORKSPACE_INIT,
|
||||||
} from '../../constants/actions';
|
} from '../../constants/actions';
|
||||||
|
|
@ -31,59 +30,6 @@ export const init = () => ({
|
||||||
type: DIALOG_EDIT_WORKSPACE_INIT,
|
type: DIALOG_EDIT_WORKSPACE_INIT,
|
||||||
});
|
});
|
||||||
|
|
||||||
// to be replaced with invoke (electron 7+)
|
|
||||||
// https://electronjs.org/docs/api/ipc-renderer#ipcrendererinvokechannel-args
|
|
||||||
export const getWebsiteIconUrlAsync = (url) => new Promise((resolve, reject) => {
|
|
||||||
try {
|
|
||||||
const id = Date.now().toString();
|
|
||||||
const { ipcRenderer } = window.remote;
|
|
||||||
ipcRenderer.once(id, (e, uurl) => {
|
|
||||||
resolve(uurl);
|
|
||||||
});
|
|
||||||
ipcRenderer.send('request-get-website-icon-url', id, url);
|
|
||||||
} catch (err) {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export const getIconFromInternet = (forceOverwrite) => (dispatch, getState) => {
|
|
||||||
const { form: { picturePath, homeUrl, homeUrlError } } = getState().dialogEditWorkspace;
|
|
||||||
if ((!forceOverwrite && picturePath) || !homeUrl || homeUrlError) return;
|
|
||||||
|
|
||||||
dispatch({
|
|
||||||
type: UPDATE_EDIT_WORKSPACE_DOWNLOADING_ICON,
|
|
||||||
downloadingIcon: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
getWebsiteIconUrlAsync(homeUrl)
|
|
||||||
.then((iconUrl) => {
|
|
||||||
const { form } = getState().dialogEditWorkspace;
|
|
||||||
if (form.homeUrl === homeUrl) {
|
|
||||||
const changes = { internetIcon: iconUrl || form.internetIcon };
|
|
||||||
if (forceOverwrite) changes.picturePath = null;
|
|
||||||
dispatch(({
|
|
||||||
type: UPDATE_EDIT_WORKSPACE_FORM,
|
|
||||||
changes,
|
|
||||||
}));
|
|
||||||
dispatch({
|
|
||||||
type: UPDATE_EDIT_WORKSPACE_DOWNLOADING_ICON,
|
|
||||||
downloadingIcon: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (forceOverwrite && !iconUrl) {
|
|
||||||
return window.remote.dialog.showMessageBox({
|
|
||||||
message: 'Unable to find a suitable icon from the Internet.',
|
|
||||||
buttons: ['OK'],
|
|
||||||
cancelId: 0,
|
|
||||||
defaultId: 0,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}).catch(console.log); // eslint-disable-line no-console
|
|
||||||
};
|
|
||||||
|
|
||||||
export const updateForm = (changes) => (dispatch) => {
|
export const updateForm = (changes) => (dispatch) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: UPDATE_EDIT_WORKSPACE_FORM,
|
type: UPDATE_EDIT_WORKSPACE_FORM,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue