|
|
|
@ -25,7 +25,7 @@ class AsyncDebouncedQueue { |
|
|
|
|
clearTimeout(this.queues.get(callback)!.timer); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let timer = setTimeout(async () => { |
|
|
|
|
const timer = setTimeout(async () => { |
|
|
|
|
await callback(); |
|
|
|
|
this.queues.delete(callback); |
|
|
|
|
}, customDelay || this.delay); |
|
|
|
@ -34,8 +34,6 @@ class AsyncDebouncedQueue { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<gitActionDispatch>, loaderDispatcher: React.Dispatch<any>) => { |
|
|
|
|
plugin = viewPlugin |
|
|
|
|
gitDispatch = gitDispatcher |
|
|
|
@ -172,35 +170,6 @@ export const getGitConfig = async () => { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const syncFromWorkspace = async (callback: Function, isLocalhost = false) => { |
|
|
|
|
//gitDispatch(setLoading(true));
|
|
|
|
|
await disableCallBacks(); |
|
|
|
|
if (isLocalhost) { |
|
|
|
|
gitDispatch(setCanUseApp(false)); |
|
|
|
|
gitDispatch(setLoading(false)); |
|
|
|
|
await enableCallBacks(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
const workspace = await plugin.call( |
|
|
|
|
"filePanel", |
|
|
|
|
"getCurrentWorkspace" |
|
|
|
|
); |
|
|
|
|
if (workspace.isLocalhost) { |
|
|
|
|
gitDispatch(setCanUseApp(false)); |
|
|
|
|
await enableCallBacks(); |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
gitDispatch(setRepoName(workspace.name)); |
|
|
|
|
gitDispatch(setCanUseApp(true)); |
|
|
|
|
} catch (e) { |
|
|
|
|
gitDispatch(setCanUseApp(false)); |
|
|
|
|
} |
|
|
|
|
await callback(); |
|
|
|
|
await enableCallBacks(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const loadFiles = async (filepaths: string[] = null) => { |
|
|
|
|
try { |
|
|
|
|
const branch = await plugin.call('dgitApi', "currentbranch") |
|
|
|
@ -217,18 +186,6 @@ export const loadFiles = async (filepaths: string[] = null) => { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const getStorageUsed = async () => { |
|
|
|
|
try { |
|
|
|
|
const storageUsed = await plugin.call("storage" as any, "getStorage" as any); |
|
|
|
|
} catch (e) { |
|
|
|
|
const storage: string = await plugin.call('dgitApi', "localStorageUsed" as any); |
|
|
|
|
const storageUsed = { |
|
|
|
|
usage: parseFloat(storage) * 1000, |
|
|
|
|
quota: 10000000, |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const disableCallBacks = async () => { |
|
|
|
|
callBackEnabled = false; |
|
|
|
|
} |
|
|
|
|