Skip to content

Commit

Permalink
Fetch unread notifications in addition to read ones
Browse files Browse the repository at this point in the history
  • Loading branch information
sirbrillig committed Sep 9, 2024
1 parent c038697 commit 77ba83e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/lib/github-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,12 @@ export async function fetchNotificationsForAccount(
const octokit = createOctokit(account);
const notificationsResponse =
await octokit.rest.activity.listNotificationsForAuthenticatedUser({
all: false,
all: true,
});

const notes: Note[] = [];

// FIXME: do these fetches in parallel instead of serial
for (const notification of notificationsResponse.data) {
let commentAvatar: string;
let commentHtmlUrl: string;
Expand Down
8 changes: 8 additions & 0 deletions src/renderer/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ function getMatchingPrevNote(prevNotes: Note[], note: Note): Note | undefined {
return prevNotes.find((prevNote) => getNoteId(prevNote) === getNoteId(note));
}

/**
* Return all the new notes, but if they match one of the previous notes,
* update the new note's "seen" and "unread" properties to match those of the
* previous note.
*
* This allows updated unread notes which have been "seen" to retain that
* property if the user has already seen them.
*/
export function mergeNotifications(
prevNotes: Note[],
nextNotes: Note[]
Expand Down

0 comments on commit 77ba83e

Please sign in to comment.