Skip to content

Commit 292ad18

Browse files
committed
feat(context): adds a context menu to add to search history only
1 parent a030887 commit 292ad18

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/models/context/context-menu.model.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const ContextMenuId = {
22
OpenInSideTrakt: 'open-in-side-trakt',
3+
AddToSearchHistory: 'add-to-search-history',
34
} as const;
45

56
export type ContextMenuIds = (typeof ContextMenuId)[keyof typeof ContextMenuId];
@@ -16,4 +17,9 @@ export const ContextMenus: Record<ContextMenuIds, ContextMenu> = {
1617
title: 'Open in side trakt',
1718
contexts: ['selection'],
1819
},
20+
[ContextMenuId.AddToSearchHistory]: {
21+
id: ContextMenuId.AddToSearchHistory,
22+
title: 'Add to search history',
23+
contexts: ['selection'],
24+
},
1925
} as const;

src/scripts/background/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ runtime?.onInstalled.addListener(async () => {
1818

1919
context.onClicked.addListener(async info => {
2020
if (!context || !runtime) return;
21-
if (info.menuItemId !== ContextMenuId.OpenInSideTrakt) return;
2221
if (!info?.selectionText) return;
2322

2423
await storage.local.set(RouterStorageKey.LastRoute, {
2524
name: Route.Search,
2625
query: { search: info.selectionText },
2726
} satisfies Partial<RouteLocationNormalized>);
2827

28+
if (info.menuItemId !== ContextMenuId.OpenInSideTrakt) return;
29+
2930
if (action?.openPopup) {
3031
await action.openPopup();
3132
} else {

0 commit comments

Comments
 (0)