Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: avatar from github map #195

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/home/fetch-github/fetch-avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import { taskManager } from "../home";
// Map to track ongoing avatar fetches
const pendingFetches: Map<string, Promise<Blob | void>> = new Map();

export async function fetchPartnerAvatars(): Promise<GitHubIssue[]> {
const response = await fetch("https://raw.githubusercontent.com/ubiquity/devpool-directory/__STORAGE__/devpool-partner-avatars.json");
Copy link
Member

@0x4007 0x4007 Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mixed feelings on your approach. The normal operating procedure is to create a pull request and link it to this task. Editing a production system is highly risky and prone to breakage. In the future you should work off of your own forks for a proof of concept.

ubiquity/devpool-directory@da89c2b

Mixed feelings, though, because I could see myself doing the same thing given that we're the only users of this directory at the moment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mb, I only did that cause the change was independent from the rest of the system. so it was self contained. even if it failed it wouldnt compromise any other section, but I agree its dumb

const jsonData = await response.json();
return jsonData;
}

// Fetches the avatar for a given organization from GitHub either from cache, indexedDB or GitHub API
export async function fetchAvatar(orgName: string): Promise<Blob | void> {
// Check if the avatar is already cached in memory
Expand Down
6 changes: 5 additions & 1 deletion src/home/getters/get-indexed-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ export function getImageFromCache({ dbName, storeName, orgName }: { dbName: stri
const store = transaction.objectStore(storeName);
const getImage = store.get(`avatarUrl-${orgName}`);
getImage.onsuccess = function () {
resolve(getImage.result?.image || null);
if (getImage.result) {
resolve(getImage.result.image);
} else {
resolve(null);
}
};
transaction.oncomplete = function () {
db.close();
Expand Down
Loading