Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@ When enabled, the following items can appear in the context menu:

When you right-click the extension's toolbar icon, by default only a minimal set of actions are shown. Enabling this option adds all available context menu actions to the toolbar icon's right-click menu, matching the full set available in the page context menu.

#### Show Error Notifications

Shows a browser notification if a cache clear operation triggered by a **keyboard shortcut** or **right-click context menu** encounters an error. Errors that occur through the popup UI are always shown inline regardless of this setting.

Disable this if you find error notifications disruptive and prefer to check results manually.

#### Show Deprecated Options

Some cache types are deprecated — they were part of older browser APIs that are no longer actively used (such as App Cache, Web SQL, and File Systems). These options are hidden by default to keep the interface clean.
Expand Down
2 changes: 1 addition & 1 deletion src/components/OptionsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const props = withDefaults(
'showConfirmation',
'contextMenu',
'contextAction',
'showErrorNotifications',
// 'showErrorNotifications',
'showDeprecated',
'showUpdate',
],
Expand Down
10 changes: 5 additions & 5 deletions src/entrypoints/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default defineBackground(() => {
chrome.commands?.onCommand.addListener(onCommand)
chrome.contextMenus?.onClicked.addListener(onClicked)

chrome.notifications.onClicked.addListener(notificationsOnClicked)
// chrome.notifications.onClicked.addListener(notificationsOnClicked)
})

async function onInstalled(details: chrome.runtime.InstalledDetails) {
Expand Down Expand Up @@ -107,10 +107,10 @@ async function onClicked(ctx: chrome.contextMenus.OnClickData, tab?: chrome.tabs
}
}

async function notificationsOnClicked(notificationId: string) {
console.log('notificationsOnClicked:', notificationId)
await chrome.notifications.clear(notificationId)
}
// async function notificationsOnClicked(notificationId: string) {
// console.log('notificationsOnClicked:', notificationId)
// await chrome.notifications.clear(notificationId)
// }

async function setDefaultOptions(defaultOptions: object) {
console.log('setDefaultOptions', defaultOptions)
Expand Down
29 changes: 16 additions & 13 deletions src/entrypoints/background/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,28 @@ export function processUpdate(options: Options, version: string, previous?: stri
console.log('processUpdate:', options)
console.log('version:', version)
console.log('previous:', previous)
const config = getAppConfig()

if (
previous !== undefined &&
compareSemver(previous, '1.0.0') < 0 &&
compareSemver(version, '1.0.0') >= 0
) {
upgrade100(options)
// TODO: Determine strategy to set updateUrl path...
const url = `${config.updateUrl}/v1.0`
console.log('url:', url)
chrome.tabs.create({ active: false, url }).catch(console.warn)
try {
const config = getAppConfig()
if (
previous !== undefined &&
compareSemver(previous, '1.0.0') < 0 &&
compareSemver(version, '1.0.0') >= 0
) {
upgrade100(options)
// TODO: Determine strategy to set updateUrl path...
const url = `${config.updateUrl}/v1.0`
console.log('url:', url)
chrome.tabs.create({ active: false, url }).catch(console.warn)
}
} catch (e) {
console.warn(e)
}
}

function upgrade100(options: Options) {
console.log('%c--- Processing v1.0.0 Upgrade ---', 'color: Gold')
let changed
if ('enable' in options.ctx) {
if (options.ctx && 'enable' in options.ctx) {
console.log('Deleting: options.ctx.enable:', options.ctx.enable)
delete options.ctx.enable
changed = true
Expand Down
11 changes: 5 additions & 6 deletions src/utils/cache.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// noinspection JSDeprecatedSymbols

import { i18n } from '#imports'
import { isFirefox, isMobile } from '@/utils/system.ts'
import { getOptions } from '@/utils/options.ts'
import { sendNotifications } from '@/utils/extension.ts'
import type { Options } from '@/utils/options.ts'
// import { sendNotifications } from '@/utils/extension.ts'

export async function clearCache(type: ClearCacheType) {
const isAll = type.endsWith('All')
Expand All @@ -18,10 +17,10 @@ export async function clearCache(type: ClearCacheType) {
}
} catch (e) {
console.error(e)
if (options.showErrorNotifications) {
const message = e instanceof Error ? e.message : i18n.t('ui.text.unknown')
await sendNotifications(i18n.t('ui.cache.error'), message)
}
// if (options.showErrorNotifications) {
// const message = e instanceof Error ? e.message : i18n.t('ui.text.unknown')
// await sendNotifications(i18n.t('ui.cache.error'), message)
// }
}
}

Expand Down
19 changes: 9 additions & 10 deletions src/utils/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,12 @@ export function clickOpen(e: Event, close = false) {
.catch(console.log)
}

export async function sendNotifications(title: string, message: string) {
// TODO: Add error icon...
const notification = await chrome.notifications.create({
type: 'basic',
iconUrl: chrome.runtime.getURL('icons/48.png'),
title,
message: message,
})
console.debug('notification:', notification)
}
// export async function sendNotifications(title: string, message: string) {
// const notification = await chrome.notifications.create({
// type: 'basic',
// iconUrl: chrome.runtime.getURL('icons/48.png'),
// title,
// message: message,
// })
// console.debug('notification:', notification)
// }
2 changes: 1 addition & 1 deletion src/utils/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const defaultOptions = {
showDeprecated: false,
contextMenu: true,
contextAction: false,
showErrorNotifications: true,
// showErrorNotifications: true,
showUpdate: false,

radioBackground: 'bgPicture' as 'bgNone' | 'bgPicture' | 'bgVideo',
Expand Down
2 changes: 1 addition & 1 deletion wxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default defineConfig({
'activeTab',
'browsingData',
'contextMenus',
'notifications',
// 'notifications',
'scripting',
'storage',
],
Expand Down
Loading