fix memory. Squashed commit of the following:
commit 1c24e48f2528238aeac417866ccec9ee3deced5f
Author: fyears <1142836+fyears@users.noreply.github.com>
Date: Fri Mar 25 02:08:05 2022 +0800
just some trying
This commit is contained in:
parent
a5e415aeaf
commit
6474faad51
@ -65,7 +65,6 @@
|
|||||||
"assert": "^2.0.0",
|
"assert": "^2.0.0",
|
||||||
"aws-crt": "^1.10.1",
|
"aws-crt": "^1.10.1",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
"codemirror": "^5.63.1",
|
|
||||||
"crypto-browserify": "^3.12.0",
|
"crypto-browserify": "^3.12.0",
|
||||||
"dropbox": "^10.22.0",
|
"dropbox": "^10.22.0",
|
||||||
"http-status-codes": "^2.2.0",
|
"http-status-codes": "^2.2.0",
|
||||||
|
|||||||
@ -196,6 +196,26 @@ export const prepareDBs = async (vaultRandomID: string) => {
|
|||||||
return db;
|
return db;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const dropDBs = async (db: InternalDBs) => {
|
||||||
|
const a1 = localforage.dropInstance({
|
||||||
|
name: DEFAULT_DB_NAME,
|
||||||
|
storeName: DEFAULT_TBL_VERSION,
|
||||||
|
});
|
||||||
|
const a2 = localforage.dropInstance({
|
||||||
|
name: DEFAULT_DB_NAME,
|
||||||
|
storeName: DEFAULT_TBL_DELETE_HISTORY,
|
||||||
|
});
|
||||||
|
const a3 = localforage.dropInstance({
|
||||||
|
name: DEFAULT_DB_NAME,
|
||||||
|
storeName: DEFAULT_TBL_SYNC_MAPPING,
|
||||||
|
});
|
||||||
|
const a4 = localforage.dropInstance({
|
||||||
|
name: DEFAULT_DB_NAME,
|
||||||
|
storeName: DEFAULT_SYNC_PLANS_HISTORY,
|
||||||
|
});
|
||||||
|
await Promise.all([a1, a2, a3, a4]);
|
||||||
|
};
|
||||||
|
|
||||||
export const destroyDBs = async () => {
|
export const destroyDBs = async () => {
|
||||||
// await localforage.dropInstance({
|
// await localforage.dropInstance({
|
||||||
// name: DEFAULT_DB_NAME,
|
// name: DEFAULT_DB_NAME,
|
||||||
|
|||||||
45
src/main.ts
45
src/main.ts
@ -10,13 +10,14 @@ import {
|
|||||||
COMMAND_URI,
|
COMMAND_URI,
|
||||||
} from "./baseTypes";
|
} from "./baseTypes";
|
||||||
import { importQrCodeUri } from "./importExport";
|
import { importQrCodeUri } from "./importExport";
|
||||||
import type { InternalDBs } from "./localdb";
|
|
||||||
import {
|
import {
|
||||||
insertDeleteRecordByVault,
|
insertDeleteRecordByVault,
|
||||||
insertRenameRecordByVault,
|
insertRenameRecordByVault,
|
||||||
insertSyncPlanRecordByVault,
|
insertSyncPlanRecordByVault,
|
||||||
loadDeleteRenameHistoryTableByVault,
|
loadDeleteRenameHistoryTableByVault,
|
||||||
prepareDBs,
|
prepareDBs,
|
||||||
|
dropDBs,
|
||||||
|
InternalDBs,
|
||||||
} from "./localdb";
|
} from "./localdb";
|
||||||
import { RemoteClient } from "./remote";
|
import { RemoteClient } from "./remote";
|
||||||
import {
|
import {
|
||||||
@ -77,16 +78,25 @@ type SyncTriggerSourceType = "manual" | "auto" | "dry" | "autoOnceInit";
|
|||||||
const iconNameSyncWait = `remotely-save-sync-wait`;
|
const iconNameSyncWait = `remotely-save-sync-wait`;
|
||||||
const iconNameSyncRunning = `remotely-save-sync-running`;
|
const iconNameSyncRunning = `remotely-save-sync-running`;
|
||||||
|
|
||||||
const iconSvgSyncWait = createElement(RotateCcw);
|
const getIconSvg = () => {
|
||||||
iconSvgSyncWait.setAttribute("width", "100");
|
const iconSvgSyncWait = createElement(RotateCcw);
|
||||||
iconSvgSyncWait.setAttribute("height", "100");
|
iconSvgSyncWait.setAttribute("width", "100");
|
||||||
const iconSvgSyncRunning = createElement(RefreshCcw);
|
iconSvgSyncWait.setAttribute("height", "100");
|
||||||
iconSvgSyncRunning.setAttribute("width", "100");
|
const iconSvgSyncRunning = createElement(RefreshCcw);
|
||||||
iconSvgSyncRunning.setAttribute("height", "100");
|
iconSvgSyncRunning.setAttribute("width", "100");
|
||||||
|
iconSvgSyncRunning.setAttribute("height", "100");
|
||||||
|
const res = {
|
||||||
|
iconSvgSyncWait: iconSvgSyncWait.outerHTML,
|
||||||
|
iconSvgSyncRunning: iconSvgSyncRunning.outerHTML,
|
||||||
|
};
|
||||||
|
|
||||||
|
iconSvgSyncWait.empty();
|
||||||
|
iconSvgSyncRunning.empty();
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
export default class RemotelySavePlugin extends Plugin {
|
export default class RemotelySavePlugin extends Plugin {
|
||||||
settings: RemotelySavePluginSettings;
|
settings: RemotelySavePluginSettings;
|
||||||
// cm: CodeMirror.Editor;
|
|
||||||
db: InternalDBs;
|
db: InternalDBs;
|
||||||
syncStatus: SyncStatusType;
|
syncStatus: SyncStatusType;
|
||||||
oauth2Info: OAuth2Info;
|
oauth2Info: OAuth2Info;
|
||||||
@ -344,8 +354,10 @@ export default class RemotelySavePlugin extends Plugin {
|
|||||||
async onload() {
|
async onload() {
|
||||||
log.info(`loading plugin ${this.manifest.id}`);
|
log.info(`loading plugin ${this.manifest.id}`);
|
||||||
|
|
||||||
addIcon(iconNameSyncWait, iconSvgSyncWait.outerHTML);
|
const { iconSvgSyncWait, iconSvgSyncRunning } = getIconSvg();
|
||||||
addIcon(iconNameSyncRunning, iconSvgSyncRunning.outerHTML);
|
|
||||||
|
addIcon(iconNameSyncWait, iconSvgSyncWait);
|
||||||
|
addIcon(iconNameSyncRunning, iconSvgSyncRunning);
|
||||||
|
|
||||||
this.oauth2Info = {
|
this.oauth2Info = {
|
||||||
verifier: "",
|
verifier: "",
|
||||||
@ -629,9 +641,14 @@ export default class RemotelySavePlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onunload() {
|
async onunload() {
|
||||||
log.info(`unloading plugin ${this.manifest.id}`);
|
log.info(`unloading plugin ${this.manifest.id}`);
|
||||||
this.destroyDBs();
|
await dropDBs(this.db);
|
||||||
|
this.syncRibbon = undefined;
|
||||||
|
if (this.oauth2Info !== undefined) {
|
||||||
|
this.oauth2Info.helperModal = undefined;
|
||||||
|
this.oauth2Info = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadSettings() {
|
async loadSettings() {
|
||||||
@ -792,10 +809,6 @@ export default class RemotelySavePlugin extends Plugin {
|
|||||||
await this.saveSettings();
|
await this.saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyDBs() {
|
|
||||||
/* destroyDBs(this.db); */
|
|
||||||
}
|
|
||||||
|
|
||||||
async setCurrSyncMsg(
|
async setCurrSyncMsg(
|
||||||
i: number,
|
i: number,
|
||||||
totalCount: number,
|
totalCount: number,
|
||||||
|
|||||||
@ -1376,15 +1376,10 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
|||||||
.onChange(async (val) => {
|
.onChange(async (val) => {
|
||||||
if (val === "enable" && !bridge.secondConfirm) {
|
if (val === "enable" && !bridge.secondConfirm) {
|
||||||
dropdown.setValue("disable");
|
dropdown.setValue("disable");
|
||||||
const modal = new SyncConfigDirModal(
|
new SyncConfigDirModal(this.app, this.plugin, () => {
|
||||||
this.app,
|
bridge.secondConfirm = true;
|
||||||
this.plugin,
|
dropdown.setValue("enable");
|
||||||
() => {
|
}).open();
|
||||||
bridge.secondConfirm = true;
|
|
||||||
dropdown.setValue("enable");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
modal.open();
|
|
||||||
} else {
|
} else {
|
||||||
bridge.secondConfirm = false;
|
bridge.secondConfirm = false;
|
||||||
this.plugin.settings.syncConfigDir = false;
|
this.plugin.settings.syncConfigDir = false;
|
||||||
@ -1506,4 +1501,10 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hide() {
|
||||||
|
let { containerEl } = this;
|
||||||
|
containerEl.empty();
|
||||||
|
super.hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user