fallback memor

yann300-patch-40
yann300 3 years ago
parent 9a7808a201
commit 5324dfd254
  1. 4
      apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx

@ -14,8 +14,10 @@ const profile = {
export class PermissionHandlerPlugin extends Plugin { export class PermissionHandlerPlugin extends Plugin {
permissions: any permissions: any
currentVersion: number currentVersion: number
fallbackMemory: boolean
constructor() { constructor() {
super(profile) super(profile)
this.fallbackMemory = false
this.permissions = this._getFromLocal() this.permissions = this._getFromLocal()
this.currentVersion = 1 this.currentVersion = 1
// here we remove the old permissions saved before adding 'permissionVersion' // here we remove the old permissions saved before adding 'permissionVersion'
@ -27,6 +29,7 @@ export class PermissionHandlerPlugin extends Plugin {
} }
_getFromLocal() { _getFromLocal() {
if (this.fallbackMemory) return this.permissions
const permission = localStorage.getItem('plugins/permissions') const permission = localStorage.getItem('plugins/permissions')
return permission ? JSON.parse(permission) : {} return permission ? JSON.parse(permission) : {}
} }
@ -36,6 +39,7 @@ export class PermissionHandlerPlugin extends Plugin {
try { try {
localStorage.setItem('plugins/permissions', permissions) localStorage.setItem('plugins/permissions', permissions)
} catch (e) { } catch (e) {
this.fallbackMemory = true
console.log(e) console.log(e)
} }
} }

Loading…
Cancel
Save