mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-08 14:07:01 +09:00
#724: autoUpdater logic and design fixes
This commit is contained in:
parent
57c9fb88bf
commit
aaaf6d2491
6 changed files with 101 additions and 82 deletions
13
electron.js
13
electron.js
|
@ -234,10 +234,14 @@ function createWindow () {
|
|||
exit(relaunch);
|
||||
});
|
||||
|
||||
ipcMain.on('update', (e) => {
|
||||
ipcMain.on('updateDownload', (e) => {
|
||||
checkUpdate(false);
|
||||
});
|
||||
|
||||
ipcMain.on('updateCancel', (e) => {
|
||||
clearTimeout(timeoutUpdate);
|
||||
});
|
||||
|
||||
ipcMain.on('urlOpen', async (e, url) => {
|
||||
shell.openExternal(url).catch((error) => {
|
||||
console.log(error);
|
||||
|
@ -511,6 +515,7 @@ function autoUpdaterInit () {
|
|||
|
||||
autoUpdater.logger = log;
|
||||
autoUpdater.logger.transports.file.level = 'debug';
|
||||
autoUpdater.autoDownload = false;
|
||||
autoUpdater.channel = config.channel;
|
||||
|
||||
setTimeout(() => { checkUpdate(true); }, TIMEOUT_UPDATE);
|
||||
|
@ -525,6 +530,10 @@ function autoUpdaterInit () {
|
|||
isUpdating = true;
|
||||
clearTimeout(timeoutUpdate);
|
||||
send('update-available', autoUpdate);
|
||||
|
||||
if (!autoUpdate) {
|
||||
autoUpdater.downloadUpdate();
|
||||
};
|
||||
});
|
||||
|
||||
autoUpdater.on('update-not-available', (info) => {
|
||||
|
@ -535,7 +544,7 @@ function autoUpdaterInit () {
|
|||
|
||||
autoUpdater.on('error', (err) => {
|
||||
Util.log('Error: ' + err);
|
||||
send('update-error', err);
|
||||
send('update-error', err, autoUpdate);
|
||||
});
|
||||
|
||||
autoUpdater.on('download-progress', (progress) => {
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
],
|
||||
|
||||
"delay": {
|
||||
"menu": 60
|
||||
"menu": 60,
|
||||
"popup": 60
|
||||
},
|
||||
|
||||
"placeHolder": {
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
.popups {
|
||||
.popup.popupConfirm {
|
||||
.innerWrap { width: 672px; padding: 32px 48px 48px 48px; }
|
||||
.innerWrap { width: 672px; padding: 32px 48px 40px 48px; }
|
||||
.title { font-size: 28px; line-height: 32px; letter-spacing: -0.48px; margin-bottom: 16px; }
|
||||
.label { margin-bottom: 26px; }
|
||||
.button { height: 32px; line-height: 32px; margin-right: 10px; }
|
||||
.button { margin-right: 16px; }
|
||||
.button.last-child { margin: 0px; }
|
||||
|
||||
.smile { margin-bottom: 12px; }
|
||||
|
|
|
@ -281,10 +281,8 @@ class App extends React.Component<Props, State> {
|
|||
ipcRenderer.on('popup', (e: any, id: string, data: any) => {
|
||||
commonStore.popupCloseAll();
|
||||
window.setTimeout(() => {
|
||||
commonStore.popupOpen(id, {
|
||||
data: data,
|
||||
});
|
||||
}, 100);
|
||||
commonStore.popupOpen(id, { data: data });
|
||||
}, Constant.delay.popup);
|
||||
});
|
||||
|
||||
ipcRenderer.on('checking-for-update', (e: any, auto: boolean) => {
|
||||
|
@ -294,10 +292,14 @@ class App extends React.Component<Props, State> {
|
|||
});
|
||||
|
||||
ipcRenderer.on('update-available', (e: any, auto: boolean) => {
|
||||
commonStore.progressSet({ status: 'Checking for update...', current: 1, total: 1 });
|
||||
if (!auto) {
|
||||
commonStore.progressSet({ status: 'Checking for update...', current: 1, total: 1 });
|
||||
};
|
||||
});
|
||||
|
||||
ipcRenderer.on('update-not-available', (e: any, auto: boolean) => {
|
||||
commonStore.progressClear();
|
||||
|
||||
if (!auto) {
|
||||
commonStore.popupOpen('confirm', {
|
||||
data: {
|
||||
|
@ -308,7 +310,6 @@ class App extends React.Component<Props, State> {
|
|||
},
|
||||
});
|
||||
};
|
||||
commonStore.progressClear();
|
||||
});
|
||||
|
||||
ipcRenderer.on('download-progress', this.onProgress);
|
||||
|
@ -318,20 +319,26 @@ class App extends React.Component<Props, State> {
|
|||
commonStore.progressClear();
|
||||
});
|
||||
|
||||
ipcRenderer.on('update-error', (e: any, err: string) => {
|
||||
console.log(err);
|
||||
ipcRenderer.on('update-error', (e: any, err: string, auto: boolean) => {
|
||||
console.error(err);
|
||||
commonStore.progressClear();
|
||||
commonStore.popupOpen('confirm', {
|
||||
data: {
|
||||
title: 'Oops!',
|
||||
text: Util.sprintf('Can’t check available updates, please try again later.<br/><span class="error">%s</span>', err),
|
||||
textConfirm: 'Retry',
|
||||
textCancel: 'Later',
|
||||
onConfirm: () => {
|
||||
ipcRenderer.send('update');
|
||||
|
||||
if (!auto) {
|
||||
commonStore.popupOpen('confirm', {
|
||||
data: {
|
||||
title: 'Oops!',
|
||||
text: Util.sprintf('Can’t check available updates, please try again later.<br/><span class="error">%s</span>', err),
|
||||
textConfirm: 'Retry',
|
||||
textCancel: 'Later',
|
||||
onConfirm: () => {
|
||||
ipcRenderer.send('updateDownload');
|
||||
},
|
||||
onCancel: () => {
|
||||
ipcRenderer.send('updateCancel');
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
ipcRenderer.on('import', this.onImport);
|
||||
|
|
|
@ -408,6 +408,8 @@ class MenuBlockAction extends React.Component<Props, State> {
|
|||
};
|
||||
|
||||
this.ref.blur();
|
||||
|
||||
let menuId = '';
|
||||
let menuParam: I.MenuParam = {
|
||||
element: '#item-' + item.id,
|
||||
type: I.MenuType.Vertical,
|
||||
|
@ -425,73 +427,73 @@ class MenuBlockAction extends React.Component<Props, State> {
|
|||
},
|
||||
};
|
||||
|
||||
this.timeout = window.setTimeout(() => {
|
||||
switch (item.id) {
|
||||
case 'turn':
|
||||
menuParam.data.onSelect = (item: any) => {
|
||||
if (item.type == I.BlockType.Text) {
|
||||
C.BlockListSetTextStyle(rootId, blockIds, item.key, (message: any) => {
|
||||
this.setFocus(blockIds[0]);
|
||||
});
|
||||
};
|
||||
|
||||
if (item.type == I.BlockType.Div) {
|
||||
C.BlockListSetDivStyle(rootId, blockIds, item.key, (message: any) => {
|
||||
this.setFocus(blockIds[0]);
|
||||
});
|
||||
};
|
||||
|
||||
if (item.type == I.BlockType.Page) {
|
||||
this.moveToPage();
|
||||
};
|
||||
|
||||
this.props.close();
|
||||
};
|
||||
|
||||
commonStore.menuOpen('blockStyle', menuParam);
|
||||
break;
|
||||
|
||||
case 'color':
|
||||
menuParam.offsetY = node.offset().top - el.offset().top - 40;
|
||||
menuParam.data.value = color;
|
||||
menuParam.data.onChange = (color: string) => {
|
||||
C.BlockListSetTextColor(rootId, blockIds, color, (message: any) => {
|
||||
switch (item.id) {
|
||||
case 'turn':
|
||||
menuId = 'blockStyle';
|
||||
menuParam.data.onSelect = (item: any) => {
|
||||
if (item.type == I.BlockType.Text) {
|
||||
C.BlockListSetTextStyle(rootId, blockIds, item.key, (message: any) => {
|
||||
this.setFocus(blockIds[0]);
|
||||
});
|
||||
|
||||
this.props.close();
|
||||
};
|
||||
|
||||
commonStore.menuOpen('blockColor', menuParam);
|
||||
break;
|
||||
|
||||
case 'background':
|
||||
menuParam.offsetY = node.offset().top - el.offset().top - 40;
|
||||
menuParam.data.value = bgColor;
|
||||
menuParam.data.onChange = (color: string) => {
|
||||
C.BlockListSetBackgroundColor(rootId, blockIds, color, (message: any) => {
|
||||
|
||||
if (item.type == I.BlockType.Div) {
|
||||
C.BlockListSetDivStyle(rootId, blockIds, item.key, (message: any) => {
|
||||
this.setFocus(blockIds[0]);
|
||||
});
|
||||
|
||||
this.props.close();
|
||||
};
|
||||
|
||||
commonStore.menuOpen('blockBackground', menuParam);
|
||||
break;
|
||||
|
||||
case 'align':
|
||||
menuParam.data.onChange = (align: I.BlockAlign) => {
|
||||
C.BlockListSetAlign(rootId, blockIds, align, (message: any) => {
|
||||
this.setFocus(blockIds[0]);
|
||||
});
|
||||
|
||||
this.props.close();
|
||||
if (item.type == I.BlockType.Page) {
|
||||
this.moveToPage();
|
||||
};
|
||||
|
||||
commonStore.menuOpen('blockAlign', menuParam);
|
||||
break;
|
||||
};
|
||||
}, Constant.delay.menu);
|
||||
this.props.close();
|
||||
};
|
||||
break;
|
||||
|
||||
case 'color':
|
||||
menuId = 'blockColor';
|
||||
menuParam.offsetY = node.offset().top - el.offset().top - 40;
|
||||
menuParam.data.value = color;
|
||||
menuParam.data.onChange = (color: string) => {
|
||||
C.BlockListSetTextColor(rootId, blockIds, color, (message: any) => {
|
||||
this.setFocus(blockIds[0]);
|
||||
});
|
||||
|
||||
this.props.close();
|
||||
};
|
||||
break;
|
||||
|
||||
case 'background':
|
||||
menuId = 'blockBackground';
|
||||
menuParam.offsetY = node.offset().top - el.offset().top - 40;
|
||||
menuParam.data.value = bgColor;
|
||||
menuParam.data.onChange = (color: string) => {
|
||||
C.BlockListSetBackgroundColor(rootId, blockIds, color, (message: any) => {
|
||||
this.setFocus(blockIds[0]);
|
||||
});
|
||||
|
||||
this.props.close();
|
||||
};
|
||||
break;
|
||||
|
||||
case 'align':
|
||||
menuId = 'blockAlign';
|
||||
menuParam.data.onChange = (align: I.BlockAlign) => {
|
||||
C.BlockListSetAlign(rootId, blockIds, align, (message: any) => {
|
||||
this.setFocus(blockIds[0]);
|
||||
});
|
||||
|
||||
this.props.close();
|
||||
};
|
||||
break;
|
||||
};
|
||||
|
||||
if (menuId) {
|
||||
this.timeout = window.setTimeout(() => {
|
||||
commonStore.menuOpen(menuId, menuParam);
|
||||
}, Constant.delay.menu);
|
||||
};
|
||||
};
|
||||
|
||||
onClick (e: any, item: any) {
|
||||
|
|
|
@ -170,7 +170,7 @@ class CommonStore {
|
|||
if (callBack) {
|
||||
callBack();
|
||||
};
|
||||
}, Constant.delay.menu);
|
||||
}, Constant.delay.popup);
|
||||
};
|
||||
|
||||
@action
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue