Skip to content

Commit

Permalink
fix: typo with preview storage key name
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Dec 5, 2023
1 parent b01c8c8 commit 801b624
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/home/fetch-github/fetch-and-display-previews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function fetchAndDisplayPreviews(sorting?: Sorting) {
throw new Error("Could not find issues container");
}
let issues: null | GitHubIssue[] = null;
issues = getLocalStore("gitHubIssuePreview") as GitHubIssue[] | null;
issues = getLocalStore("gitHubIssuesPreview") as GitHubIssue[] | null;
if (issues) {
displayIssues(issues, container, sorting);
issues = await fetchIssuePreviews();
Expand Down
2 changes: 1 addition & 1 deletion src/home/fetch-github/fetch-issues-full.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function fetchIssuesFull(previews: GitHubIssue[]) {
const octokit = new Octokit({ auth: getGitHubAccessToken() });
const urlPattern = /https:\/\/github\.com\/(?<org>[^/]+)\/(?<repo>[^/]+)\/issues\/(?<issue_number>\d+)/;

const cachedIssues = previews || (getLocalStore("gitHubIssuePreview") as GitHubIssue[]);
const cachedIssues = previews || (getLocalStore("gitHubIssuesPreview") as GitHubIssue[]);

const issueFetchPromises = cachedIssues.map((preview) => {
const match = preview.body.match(urlPattern);
Expand Down
2 changes: 1 addition & 1 deletion src/home/fetch-github/fetch-issues-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ export async function fetchIssuePreviews(): Promise<GitHubIssueWithNewFlag[]> {
delete issue.isNew;
return issue;
});
localStorage.setItem("gitHubIssuePreview", JSON.stringify(issuesToSave));
localStorage.setItem("gitHubIssuesPreview", JSON.stringify(issuesToSave));
return freshIssuesWithNewFlag;
}
2 changes: 1 addition & 1 deletion src/home/github-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,5 @@ export interface GitHubIssue {
}

export interface AvatarCache {
[organization: string]: string;
[organization: string]: string | null;
}
2 changes: 1 addition & 1 deletion src/home/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ grid(document.getElementById("grid") as HTMLElement);
authentication()
.then(fetchAndDisplayPreviews)
.then((previews) => {
localStorage.setItem("gitHubIssuesPreviews", JSON.stringify(previews));
localStorage.setItem("gitHubIssuesPreview", JSON.stringify(previews));
const toolbar = document.getElementById("toolbar");
if (!toolbar) throw new Error("toolbar not found");
toolbar.classList.add("ready");
Expand Down
6 changes: 4 additions & 2 deletions src/home/rendering/render-github-issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function renderGitHubIssues(container: HTMLDivElement, issues: GitHubIssu
fetchInProgress.add(organizationName);

// Update the avatarCache synchronously here
avatarCache[organizationName] = "fetching"; // Placeholder value to indicate fetch in progress
avatarCache[organizationName] = null; // Placeholder value to indicate fetch in progress
localStorage.setItem("avatarCache", JSON.stringify(avatarCache));

fetch(`https://api.github.com/orgs/${organizationName}`)
Expand All @@ -110,7 +110,9 @@ export function renderGitHubIssues(container: HTMLDivElement, issues: GitHubIssu
if (data && data.avatar_url) {
avatarCache[organizationName] = data.avatar_url;
localStorage.setItem("avatarCache", JSON.stringify(avatarCache));
image.src = data.avatar_url;
if (data.avatar_url) {
image.src = data.avatar_url;
}
}
})
.catch((error) => {
Expand Down

0 comments on commit 801b624

Please sign in to comment.