tangled
alpha
login
or
join now
ptr.pet
/
bsky-repost-likes
2
fork
atom
its for when you want to get like notifications for your reposts
2
fork
atom
overview
issues
pulls
pipelines
feat(extension): add badge
ptr.pet
8 months ago
25bebc62
7c0c486f
verified
This commit was signed with the committer's
known signature
.
ptr.pet
SSH Key Fingerprint:
SHA256:Abmvag+juovVufZTxyWY8KcVgrznxvBjQpJesv071Aw=
+9
-4
3 changed files
expand all
collapse all
unified
split
extension
entrypoints
background.ts
popup
main.tsx
types
shim.d.ts
+7
-3
extension/entrypoints/background.ts
···
15
15
export default defineBackground({
16
16
persistent: true,
17
17
main: async () => {
18
18
+
browser.action.setBadgeBackgroundColor({ color: "#0886FE" });
19
19
+
browser.action.setBadgeTextColor({ color: "#FFFFFF" });
20
20
+
18
21
onMessage("connectService", connect);
19
22
onMessage("disconnectService", disconnect);
20
23
onMessage("connectionStatus", () => {
···
26
29
onMessage("items", () => {
27
30
return items;
28
31
});
29
29
-
onMessage("setItems", ({ data }) => {
30
30
-
items = data;
32
32
+
onMessage("clearItems", () => {
33
33
+
items = [];
34
34
+
browser.action.setBadgeText({ text: "" });
31
35
});
32
36
33
37
// connect on service start once
···
54
58
serviceDomain,
55
59
pushNotification: (item) => {
56
60
items = [item, ...items];
61
61
+
browser.action.setBadgeText({ text: items.length.toString() });
57
62
sendMessage("setItems", items, "popup");
58
63
},
59
64
setConnectionStatus,
60
65
setError,
61
66
doRetry: () => {
62
62
-
console.log("ws", websocket, " status ", connectionStatus);
63
67
if (websocket !== null && connectionStatus === "error") {
64
68
const b = reconnectBackoff;
65
69
reconnectBackoff *= 2;
+1
-1
extension/entrypoints/popup/main.tsx
···
72
72
items,
73
73
clearItems: () => {
74
74
setItems([]);
75
75
-
sendMessage("setItems", [], "background");
75
75
+
sendMessage("clearItems", {}, "background");
76
76
},
77
77
connectionStatus: connectionStatus,
78
78
error,
+1
extension/types/shim.d.ts
···
11
11
setError: string | null;
12
12
items: ProtocolWithReturn<{}, Notification[]>;
13
13
setItems: Notification[];
14
14
+
clearItems: {};
14
15
}
15
16
}