Skip to content

Commit

Permalink
feat(extension): open readme on install, release on update
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyko committed Aug 1, 2023
1 parent 8676b28 commit 6814b7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@searchy/extension",
"version": "0.2.0",
"version": "0.2.1",
"contributors": [
"Alistair Smith <alistairsmith01@gmail.com>",
"Carter Himmel <me@fyko.net>"
Expand Down
13 changes: 13 additions & 0 deletions apps/extension/src/background.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {SITES, template} from '@searchy/links';
import Fuse from 'fuse.js';

const repo = 'alii/searchy';

const fuse = new Fuse(Object.keys(SITES), {
shouldSort: true,
threshold: 0.4,
Expand Down Expand Up @@ -68,3 +70,14 @@ async function navigate(url: string) {

return chrome.tabs.create({url});
}

chrome.runtime.onInstalled.addListener(details => {
const cases: Record<chrome.runtime.OnInstalledReason, string | undefined> = {
[chrome.runtime.OnInstalledReason.INSTALL]: `https://github.com/${repo}/tree/master/apps/extension#readme`,
[chrome.runtime.OnInstalledReason.UPDATE]: `https://github.com/${repo}/releases/tags/latest`,
[chrome.runtime.OnInstalledReason.CHROME_UPDATE]: undefined,
[chrome.runtime.OnInstalledReason.SHARED_MODULE_UPDATE]: undefined,
};
const url = cases[details.reason];
if (url) void navigate(url);
});

0 comments on commit 6814b7c

Please sign in to comment.