Skip to content

Commit

Permalink
Merge branch 'master' into chore/style-isolation
Browse files Browse the repository at this point in the history
  • Loading branch information
eritbh committed Oct 10, 2024
2 parents e573b35 + 3d4046f commit 1023cea
Show file tree
Hide file tree
Showing 5 changed files with 416 additions and 1,325 deletions.
16 changes: 11 additions & 5 deletions extension/data/components/PageNotificationContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@ export function PageNotificationContainer () {

// Register listener for messages from the background page
useEffect(() => {
const messageListener = (message: any) => {
if (message.action === 'tb-show-page-notification') {
const messageListener = (message: unknown) => {
// TODO: we need proper types for these messages
if ((message as any).action === 'tb-show-page-notification') {
// Add to beginning of list so it shows up on top
// TODO: wouldn't it be better to do this via `flex-direction`?
setNotifications([message.details, ...notifications]);
} else if (message.action === 'tb-clear-page-notification') {
setNotifications([(message as any).details, ...notifications]);
} else if ((message as any).action === 'tb-clear-page-notification') {
// Remove the notification from the list
setNotifications(notifications.filter(notif => notif.id !== message.id));
setNotifications(notifications.filter(notif => notif.id !== (message as any).id));
}

// `@types/webextension-polyfill` wants us to explicitly return
// `undefined` from synchronous listeners to indicate that we're not
// doing any async stuff relying on the `sendResponse` param
return undefined;
};

browser.runtime.onMessage.addListener(messageListener);
Expand Down
3 changes: 2 additions & 1 deletion extension/data/tbapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export const sendRequest = async ({
okOnly,
}: RequestOptions) => {
// Make the request
const messageReply = await browser.runtime.sendMessage({
// TODO: types for runtime messages
const messageReply: any = await browser.runtime.sendMessage({
action: 'tb-request',
method,
endpoint,
Expand Down
Loading

0 comments on commit 1023cea

Please sign in to comment.