Skip to content

Commit

Permalink
Add upcoming permission notification (OctoLinker#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanbuck authored Apr 6, 2020
1 parent 490b165 commit f051bf8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/core/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as storage from '@octolinker/helper-settings';
import helperSortUrls from '@octolinker/helper-sort-urls';
import normaliseResolverResults from '@octolinker/helper-normalise-resolver-results';
import notification from './notification';
import updateNotice from './update-notice';
import Plugins from './plugin-manager.js';
import debugMode from './debug-mode.js';
import loader from './loader.js';
Expand Down Expand Up @@ -70,6 +71,7 @@ function watch(viewSpy) {
function init() {
debugMode(storage.get('debugMode'));
notification();
updateNotice();

injection(() => {
if (!blobReader.hasBlobs()) {
Expand Down
36 changes: 36 additions & 0 deletions packages/core/update-notice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as storage from '@octolinker/helper-settings';
import { showNotification } from '@octolinker/user-interface';

let notificationEl;

document.body.addEventListener('click', event => {
if (
event.target.classList.contains('js-hide-update-notice') ||
event.target.classList.contains('js-flash-close-update-notice')
) {
storage.set('showUpdateNoticePermissionUpdate', false);
if (notificationEl) {
notificationEl.remove();
}
}
});

export default async function() {
if (navigator.userAgent.includes('Firefox')) {
return;
}

const showUpdateNoticePermissionUpdate = storage.get(
'showUpdateNoticePermissionUpdate',
);

if (showUpdateNoticePermissionUpdate === false) {
return;
}

const url = 'https://github.com/OctoLinker/OctoLinker/issues/870';

const body = `<b>Important</b>: Our next release will ask for additional permission to access api.github.com. <a href="${url}" target="_blank" class="js-hide-update-notice">Why the change?</a>`;

notificationEl = showNotification({ body, id: 'update-notice' });
}

0 comments on commit f051bf8

Please sign in to comment.