HaJaeKyung / KittyExtension

Fan add-on for https://www.cryptokitties.co
MIT License
232 stars 88 forks source link

I've implemented a versioning system to clear localStorage on changes. #12

Closed VesterDe closed 6 years ago

VesterDe commented 6 years ago

So far the thing has been backwards incompatible most of the time so this should improve UX for future changes.

HaJaeKyung commented 6 years ago

First load the kittyPluginVersion is not set. Set it to 0 if it doesn't exist. Also change plugin to extension, trying to keep things consistent.

var savedVersion = localStorage.getItem('kittyPluginVersion') || 0;

VesterDe commented 6 years ago

The || 0 part of the localStorage getter isn't really needed is it? localStorage returns null if the key doesn't exist. Null will act the same as 0 in this case.

I've added it anyway, it's your repository. And I merged your latest changes.

HaJaeKyung commented 6 years ago

Tested it some more and it kicks you out of the whole site. Don't think that would be a nice experience for people. Instead of clearing the entire storage you can just set the storage values to empty.

VesterDe commented 6 years ago

Good call, it didn't happen to me but it's a better idea to only delete those 2 keys yes, I didn't notice the page also saves some data to localStorage already.