its for when you want to get like notifications for your reposts

feat(extension): add badge

ptr.pet 25bebc62 7c0c486f

verified
+9 -4
+7 -3
extension/entrypoints/background.ts
··· 15 15 export default defineBackground({ 16 16 persistent: true, 17 17 main: async () => { 18 + browser.action.setBadgeBackgroundColor({ color: "#0886FE" }); 19 + browser.action.setBadgeTextColor({ color: "#FFFFFF" }); 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 - onMessage("setItems", ({ data }) => { 30 - items = data; 32 + onMessage("clearItems", () => { 33 + items = []; 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 + 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 - 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 - sendMessage("setItems", [], "background"); 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 + clearItems: {}; 14 15 } 15 16 }