Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove the old permissionss saved in localstorage #2670

Merged
merged 3 commits into from
Apr 2, 2020
Merged

Conversation

LianaHus
Copy link
Collaborator

since the structure has been changed

fixing https://github.com/ethereum/remix-ide/issues/2663

@LianaHus LianaHus requested a review from yann300 March 24, 2020 12:41
@@ -41,6 +41,11 @@ export class PermissionHandler {

constructor () {
this.permissions = this._getFromLocal()
// remove the old permissions saved in versions < 0.9.4 since the structior has been changed
if (!localStorage.getItem(['isNewEngine'])) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this an array? ['isNewEngine']

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, a typo. will fix it

@LianaHus LianaHus added this to the IDE-v0.8-prerelease milestone Mar 24, 2020
@@ -41,6 +41,11 @@ export class PermissionHandler {

constructor () {
this.permissions = this._getFromLocal()
// remove the old permissions saved in versions < 0.9.4 since the structior has been changed
if (!localStorage.getItem('isNewEngine')) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps having a more precise flag like isNewEngine-<version_number> would be better, the structure might change again in the future

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well i had that before but then remove it. I can add it if you want, i didn't want to overthink

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok let's add it then

this.currentVersion = 1
// here we remove the old permissions saved before adding 'permissionVersion'
// since with v1 the structior has been changed because of new engine ^0.2.0-alpha.6 changes
if (!localStorage.getItem('permissionVersion')) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that still won't work like this, you have to do
if (localStorage.getItem('permissionVersion') !== this.currentVersion) {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this.currentVersion is 2. or 4. the user loads and there is no 'permissionVersion' this would be undefined. ok i can leave the check for undefined.
now lets say permissionVersion is 1 and we have currentVersion=2 now so 1 != 2 we gonna rm the old one(correct) and set it to 1(incorrect).

with my logic, if the 'permissionVersion' was not introduced it will rm the old permissions and set 1 to permissionVersion.
if it is already there will not do anything

@yann300 yann300 removed this from the IDE-v0.8-prerelease milestone Mar 31, 2020
@yann300 yann300 merged commit 4c0c7e7 into master Apr 2, 2020
@yann300 yann300 deleted the rmOldPerm branch April 2, 2020 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants