mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-15 15:10:31 -08:00
feat: don't sync if there is no net work, or passed in syncImmediately: false
This commit is contained in:
parent
600068b422
commit
109355cb5d
2 changed files with 7 additions and 4 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { ipcMain, dialog } from 'electron';
|
||||
import { ipcMain, dialog, net } from 'electron';
|
||||
import { injectable, inject } from 'inversify';
|
||||
import { debounce } from 'lodash';
|
||||
import {
|
||||
|
|
@ -223,8 +223,8 @@ export class Git implements IGitService {
|
|||
logger.log(level, this.translateMessage(message), meta);
|
||||
},
|
||||
error: (error) => {
|
||||
this.translateAndLogErrorMessage(error);
|
||||
reject(error);
|
||||
this.translateAndLogErrorMessage(error as Error);
|
||||
reject(error as Error);
|
||||
},
|
||||
complete: () => resolve(),
|
||||
});
|
||||
|
|
@ -238,6 +238,9 @@ export class Git implements IGitService {
|
|||
}
|
||||
|
||||
public async commitAndSync(wikiFolderPath: string, remoteUrl: string, userInfo: IGitUserInfos): Promise<void> {
|
||||
if (!net.isOnline()) {
|
||||
return;
|
||||
}
|
||||
return await new Promise<void>((resolve, reject) => {
|
||||
this.gitWorker?.commitAndSyncWiki(wikiFolderPath, remoteUrl, userInfo).subscribe(this.getWorkerObserver(resolve, reject));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ export class WorkspaceView implements IWorkspaceViewService {
|
|||
|
||||
// get sync process ready
|
||||
try {
|
||||
if (workspace.syncOnStartup && storageService !== SupportedStorageServices.local) {
|
||||
if (workspace.syncOnStartup && storageService !== SupportedStorageServices.local && syncImmediately) {
|
||||
// check synced wiki should have githubRepoUrl
|
||||
if (typeof githubRepoUrl !== 'string') {
|
||||
throw new TypeError(`githubRepoUrl is undefined in initializeAllWorkspaceView when init ${wikiFolderLocation}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue