Skip to content

Commit

Permalink
Store extension version in browser storage (#220)
Browse files Browse the repository at this point in the history
This fix the issue where the update notification was shown twice to the user when browsing on github.com and gist.github.com. That happened because we stored the version in the LocalStorage. The LS is bounded to the domain and therefore the notification was appearing twice to the user. By using the browser build in storage this can be avoided.
  • Loading branch information
stefanbuck authored and josephfrazier committed Dec 2, 2016
1 parent 9e62eab commit 0e148ce
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions lib/notification.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import { showNotification } from './gh-interface';
import * as storage from './options/storage.js';

let isNewVersion = false;
const pkgVersion = require('../package.json').version.split('.').slice(0, -1).join('.');

const installedVersion = window.localStorage.getItem('OctoLinkerVersion');
window.localStorage.setItem('OctoLinkerVersion', pkgVersion);
export default function () {
let isNewVersion = false;

if (installedVersion && installedVersion !== pkgVersion) {
isNewVersion = true;
}
const installedVersion = storage.get('version') || window.localStorage.getItem('OctoLinkerVersion');

// Remove this in after three releases (v4.8)
if (window.localStorage.getItem('OctoLinkerVersion')) {
window.localStorage.removeItem('OctoLinkerVersion');
}

storage.set('version', pkgVersion);

if (installedVersion && installedVersion !== pkgVersion) {
isNewVersion = true;
}

export default function () {
if (isNewVersion) {
showNotification();
}
Expand Down

0 comments on commit 0e148ce

Please sign in to comment.