From c0d98a803470d7f1da27fb931b5eac25e20ce8b5 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 16 Mar 2022 14:33:52 +0100 Subject: [PATCH 1/2] do not crash if localstorage is full --- .../src/app/plugins/permission-handler-plugin.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx b/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx index 1b947d75dd..22412ed9e8 100644 --- a/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx +++ b/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx @@ -33,7 +33,11 @@ export class PermissionHandlerPlugin extends Plugin { persistPermissions() { const permissions = JSON.stringify(this.permissions) - localStorage.setItem('plugins/permissions', permissions) + try { + localStorage.setItem('plugins/permissions', permissions) + } catch (e) { + console.log(e) + } } switchMode (from: Profile, to: Profile, method: string, set: boolean) { @@ -123,4 +127,4 @@ export class PermissionHandlerPlugin extends Plugin { } }) } -} \ No newline at end of file +} From 458fd8ce3e956374c06484ba97eedab553c8faba Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 16 Mar 2022 20:35:02 +0100 Subject: [PATCH 2/2] fallback memor --- apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx b/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx index 22412ed9e8..eee8d64165 100644 --- a/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx +++ b/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx @@ -14,8 +14,10 @@ const profile = { export class PermissionHandlerPlugin extends Plugin { permissions: any currentVersion: number + fallbackMemory: boolean constructor() { super(profile) + this.fallbackMemory = false this.permissions = this._getFromLocal() this.currentVersion = 1 // here we remove the old permissions saved before adding 'permissionVersion' @@ -27,6 +29,7 @@ export class PermissionHandlerPlugin extends Plugin { } _getFromLocal() { + if (this.fallbackMemory) return this.permissions const permission = localStorage.getItem('plugins/permissions') return permission ? JSON.parse(permission) : {} } @@ -36,6 +39,7 @@ export class PermissionHandlerPlugin extends Plugin { try { localStorage.setItem('plugins/permissions', permissions) } catch (e) { + this.fallbackMemory = true console.log(e) } }