Skip to content

Commit

Permalink
Merge pull request #331 from adobe/issue-330
Browse files Browse the repository at this point in the history
fix: delete project not working in safari
  • Loading branch information
rofe committed Apr 28, 2023
2 parents 528574a + d7a1022 commit d32384d
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/extension/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ function alert(msg) {
return null;
}

// shows a window.confirm (noop if headless)
function confirm(msg) {
if (typeof window !== 'undefined' && !/HeadlessChrome/.test(window.navigator.userAgent)) {
// eslint-disable-next-line no-alert
return window.confirm(msg);
}
return true;
}

// shorthand for browser.i18n.getMessage()
export function i18n(msg, subs) {
return chrome.i18n.getMessage(msg, subs);
Expand Down Expand Up @@ -347,7 +338,7 @@ export async function deleteProject(handle, cb) {
const projects = await getConfig('sync', 'hlxSidekickProjects') || [];
const i = projects.indexOf(handle);
if (i >= 0) {
if (confirm(i18n('config_delete_confirm'))) {
try {
// delete admin auth header rule
const [owner, repo] = handle.split('/');
chrome.runtime.sendMessage({ deleteAuthToken: { owner, repo } });
Expand All @@ -358,8 +349,8 @@ export async function deleteProject(handle, cb) {
await setConfig('sync', { hlxSidekickProjects: projects });
log.info('project deleted', handle);
if (typeof cb === 'function') cb(true);
} else {
log.info('project deletion aborted', handle);
} catch (e) {
log.error('project deletion failed', handle, e);
if (typeof cb === 'function') cb(false);
}
} else {
Expand Down

0 comments on commit d32384d

Please sign in to comment.