diff --git a/packages/desktop/electron/electronApi.js b/packages/desktop/electron/electronApi.js index 873966fecc7..fe772a10881 100644 --- a/packages/desktop/electron/electronApi.js +++ b/packages/desktop/electron/electronApi.js @@ -7,30 +7,12 @@ const NotificationManager = require('./lib/notificationManager') const { menuState } = require('./lib/menuState') const features = require('../features/features').default -let activeProfileId = null const eventListeners = {} const ElectronApi = { updateAppSettings(settings) { return ipcRenderer.invoke('update-app-settings', settings) }, - getActiveProfile() { - return activeProfileId - }, - updateActiveProfile(id) { - activeProfileId = id - }, - async renameProfileFolder(oldPath, newPath) { - return ipcRenderer.invoke('get-path', 'userData').then((userDataPath) => { - if (oldPath.startsWith(userDataPath)) { - try { - fs.renameSync(oldPath, newPath) - } catch (err) { - console.error(err) - } - } - }) - }, async removeProfileFolder(profilePath) { return ipcRenderer.invoke('get-path', 'userData').then((userDataPath) => { // Check that the removing profile path matches the user data path @@ -82,28 +64,6 @@ const ElectronApi = { return result.filePath }) }, - saveStrongholdBackup: ({ allowAccess }) => null, - async exportTransactionHistory(defaultPath, contents) { - return ipcRenderer - .invoke('show-save-dialog', { - properties: ['createDirectory', 'showOverwriteConfirmation'], - defaultPath, - filters: [{ name: 'CSV Files', extensions: ['csv'] }], - }) - .then((result) => { - if (result.canceled) { - return null - } - return new Promise((resolve, reject) => { - try { - fs.writeFileSync(result.filePath, contents) - resolve(result.filePath) - } catch (err) { - reject(err) - } - }) - }) - }, /** * Gets directory for app's configuration files * @@ -337,12 +297,6 @@ const ElectronApi = { updateTheme(theme) { return ipcRenderer.invoke('update-theme', theme) }, - startLedgerProcess() { - return ipcRenderer.send('start-ledger-process') - }, - killLedgerProcess() { - return ipcRenderer.send('kill-ledger-process') - }, } module.exports = ElectronApi diff --git a/packages/shared/lib/core/app/interfaces/platform.interface.ts b/packages/shared/lib/core/app/interfaces/platform.interface.ts index 7afcb4cd86e..adb1d31d6c4 100644 --- a/packages/shared/lib/core/app/interfaces/platform.interface.ts +++ b/packages/shared/lib/core/app/interfaces/platform.interface.ts @@ -8,17 +8,13 @@ import { AppTheme } from '../enums' export interface IPlatform { getStrongholdBackupDestination(defaultPath: string): Promise - saveStrongholdBackup({ allowAccess }: { allowAccess: boolean }): Promise - exportTransactionHistory(defaultPath: string, contents: string): Promise getUserDataPath(): Promise getDiagnostics(): Promise<{ label: string; value: string }[]> getOS(): Promise getMachineId(): Promise updateAppSettings(settings: Partial): Promise - getActiveProfile(): string updateActiveProfile(id: string): void removeProfileFolder(profilePath: string): Promise - renameProfileFolder(oldPath: string, newPath: string): Promise listProfileFolders(profileStoragePath: string): Promise updateMenu(attribute: string, value: unknown): void popupMenu(): void @@ -55,7 +51,4 @@ export interface IPlatform { getLanguageCode(): Promise updateTheme(theme: AppTheme): void - - startLedgerProcess(): Promise - killLedgerProcess(): Promise } diff --git a/packages/shared/lib/core/profile/actions/active-profile/login.ts b/packages/shared/lib/core/profile/actions/active-profile/login.ts index 105db7b16b2..b3c6bcfd437 100644 --- a/packages/shared/lib/core/profile/actions/active-profile/login.ts +++ b/packages/shared/lib/core/profile/actions/active-profile/login.ts @@ -141,7 +141,6 @@ export async function login(loginOptions?: ILoginOptions): Promise { setTimeStrongholdLastUnlocked() } } else { - Platform.startLedgerProcess() incrementLoginProgress(2) } diff --git a/packages/shared/lib/core/profile/actions/active-profile/logout.ts b/packages/shared/lib/core/profile/actions/active-profile/logout.ts index ad204a1ef33..098f7b064a8 100644 --- a/packages/shared/lib/core/profile/actions/active-profile/logout.ts +++ b/packages/shared/lib/core/profile/actions/active-profile/logout.ts @@ -19,7 +19,6 @@ import { IProfileManager } from '@core/profile-manager/interfaces' import { profileManager } from '@core/profile-manager/stores' import { routerManager } from '@core/router/stores' import { clearFilters } from '@core/utils/clearFilters' -import { Platform } from '@core/app' /** * Logout from active profile @@ -28,7 +27,6 @@ export async function logout(clearActiveProfile = true, _lockStronghold = true): if (get(isSoftwareProfile)) { _lockStronghold && lockStronghold() } else if (isLedgerProfile(get(activeProfile).type)) { - Platform.killLedgerProcess() get(isPollingLedgerDeviceStatus) && stopPollingLedgerNanoStatus() } diff --git a/packages/shared/lib/core/profile/actions/active-profile/resetActiveProfile.ts b/packages/shared/lib/core/profile/actions/active-profile/resetActiveProfile.ts index 941af5cb950..9822696cf1f 100644 --- a/packages/shared/lib/core/profile/actions/active-profile/resetActiveProfile.ts +++ b/packages/shared/lib/core/profile/actions/active-profile/resetActiveProfile.ts @@ -1,10 +1,8 @@ import { activeProfile, activeProfileId, INITIAL_ACTIVE_PROFILE, IProfile } from '@core/profile' -import { Platform } from '@core/app' import { get } from 'svelte/store' export function resetActiveProfile(): void { const { lastUsedAccountIndex } = get(activeProfile) activeProfile.set({ ...INITIAL_ACTIVE_PROFILE, lastUsedAccountIndex }) activeProfileId.set(null) - Platform.updateActiveProfile(null) } diff --git a/packages/shared/lib/core/profile/actions/active-profile/setActiveProfile.ts b/packages/shared/lib/core/profile/actions/active-profile/setActiveProfile.ts index afc670891cc..6e16d960705 100644 --- a/packages/shared/lib/core/profile/actions/active-profile/setActiveProfile.ts +++ b/packages/shared/lib/core/profile/actions/active-profile/setActiveProfile.ts @@ -1,9 +1,7 @@ import { activeProfile, INITIAL_ACTIVE_PROFILE, IPersistedProfile, IProfile } from '@core/profile' import { activeProfileId } from '@core/profile/stores' -import { Platform } from '@core/app' export function setActiveProfile(persistedProfile: IPersistedProfile): void { activeProfile?.set({ ...INITIAL_ACTIVE_PROFILE, ...persistedProfile }) activeProfileId?.set(persistedProfile.id) - Platform.updateActiveProfile(persistedProfile.id) } diff --git a/packages/shared/lib/tests/__mocks__/platform.mock.ts b/packages/shared/lib/tests/__mocks__/platform.mock.ts index b86c0a78def..fa5fb016e71 100644 --- a/packages/shared/lib/tests/__mocks__/platform.mock.ts +++ b/packages/shared/lib/tests/__mocks__/platform.mock.ts @@ -6,12 +6,6 @@ const Platform: IPlatform = { NotificationManager: undefined, PincodeManager: undefined, close(): void {}, - exportTransactionHistory(defaultPath: string, contents: string): Promise { - return Promise.resolve(null) - }, - getActiveProfile(): string { - return '' - }, getDiagnostics(): Promise<{ label: string; value: string }[]> { return Promise.resolve([]) }, @@ -47,16 +41,12 @@ const Platform: IPlatform = { removeProfileFolder(profilePath: string): Promise { return Promise.resolve(undefined) }, - renameProfileFolder(oldPath: string, newPath: string): Promise { - return Promise.resolve(undefined) - }, saveRecoveryKit(kitData: ArrayBuffer): Promise { return Promise.resolve(undefined) }, unhandledException(title: string, err: IError | unknown): Promise { return Promise.resolve(undefined) }, - updateActiveProfile(id: string): void {}, updateAppSettings(settings: Partial): Promise { return Promise.resolve(undefined) }, @@ -97,5 +87,4 @@ const Platform: IPlatform = { updateTheme(): void {}, } -window['__CAPACITOR__'] = Platform window['__ELECTRON__'] = Platform diff --git a/yarn.lock b/yarn.lock index 964d419935c..489ba220294 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4081,9 +4081,9 @@ flatted@^3.1.0: integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ== follow-redirects@^1.0.0: - version "1.15.2" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" - integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== + version "1.15.5" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.5.tgz#54d4d6d062c0fa7d9d17feb008461550e3ba8020" + integrity sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw== for-each@^0.3.3: version "0.3.3"