From e2b9ea1f49c514d2249156fb8a06a108b5c18c2e Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Mon, 10 Jul 2023 13:33:52 +0530 Subject: [PATCH] refactor: switch to preload script - delete ipcCalls --- reports/commonExporter.ts | 5 +- src/App.vue | 5 +- src/components/Controls/AttachImage.vue | 3 +- src/components/ExportWizard.vue | 9 +- src/components/HowTo.vue | 3 +- src/components/SearchBar.vue | 7 +- src/components/Sidebar.vue | 3 +- src/errorHandling.ts | 11 +- src/pages/DatabaseSelector.vue | 3 +- src/pages/GetStarted.vue | 6 +- src/pages/ImportWizard.vue | 3 +- src/pages/Settings/Settings.vue | 3 +- src/renderer.ts | 3 +- src/renderer/registerIpcRendererListeners.ts | 8 +- src/shims-tsx.d.ts | 2 +- src/utils/ipcCalls.ts | 142 ------------------- src/utils/language.ts | 5 +- src/utils/printTemplates.ts | 5 +- src/utils/ui.ts | 19 +-- 19 files changed, 37 insertions(+), 208 deletions(-) delete mode 100644 src/utils/ipcCalls.ts diff --git a/reports/commonExporter.ts b/reports/commonExporter.ts index cf18c307..54d4140c 100644 --- a/reports/commonExporter.ts +++ b/reports/commonExporter.ts @@ -1,12 +1,11 @@ import { t } from 'fyo'; import { Action } from 'fyo/model/types'; import { Verb } from 'fyo/telemetry/types'; -import { saveData } from 'src/utils/ipcCalls'; +import { getSavePath, showExportInFolder } from 'src/utils/ui'; import { getIsNullOrUndef } from 'utils'; import { generateCSV } from 'utils/csvParser'; import { Report } from './Report'; import { ExportExtention, ReportCell } from './types'; -import { getSavePath, showExportInFolder } from 'src/utils/ui'; interface JSONExport { columns: { fieldname: string; label: string }[]; @@ -184,7 +183,7 @@ export async function saveExportData( filePath: string, message?: string ) { - await saveData(data, filePath); + await ipc.saveData(data, filePath); message ??= t`Export Successful`; showExportInFolder(message, filePath); } diff --git a/src/App.vue b/src/App.vue index 7da7d944..71fab550 100644 --- a/src/App.vue +++ b/src/App.vue @@ -53,7 +53,6 @@ import { connectToDatabase, dbErrorActionSymbols } from './utils/db'; import { initializeInstance } from './utils/initialization'; import * as injectionKeys from './utils/injectionKeys'; import { showDialog } from './utils/interactive'; -import { checkDbAccess, checkForUpdates } from './utils/ipcCalls'; import { setLanguageMap } from './utils/language'; import { updateConfigFiles } from './utils/misc'; import { updatePrintTemplates } from './utils/printTemplates'; @@ -147,7 +146,7 @@ export default defineComponent({ this.activeScreen = Screen.Desk; await this.setDeskRoute(); await fyo.telemetry.start(true); - await checkForUpdates(); + await ipc.checkForUpdates(); await setLanguageMap(); this.dbPath = filePath; this.companyName = (await fyo.getValue( @@ -164,7 +163,7 @@ export default defineComponent({ return; } - if (filePath !== ':memory:' && !(await checkDbAccess(filePath))) { + if (filePath !== ':memory:' && !(await ipc.checkDbAccess(filePath))) { await showDialog({ title: this.t`Cannot open file`, type: 'error', diff --git a/src/components/Controls/AttachImage.vue b/src/components/Controls/AttachImage.vue index 9651c679..2dbb8444 100644 --- a/src/components/Controls/AttachImage.vue +++ b/src/components/Controls/AttachImage.vue @@ -57,7 +57,6 @@