Skip to content

Commit

Permalink
Merge pull request #23 from Keyrxng/notfis-personal-image
Browse files Browse the repository at this point in the history
chore: fetch personal pp and remove notifications
  • Loading branch information
0x4007 committed Mar 6, 2024
2 parents 7821a2e + aec6f8a commit 7f35ce4
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 59 deletions.
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -36,4 +36,3 @@ open http://localhost:8080
#### Mobile

![screenshot 2](https://github.com/ubiquity/devpool-directory-ui/assets/4975670/b7861ce7-1f1f-49a9-b8e2-ebb20724ee67)

9 changes: 4 additions & 5 deletions src/home/fetch-github/fetch-and-display-previews.ts
Expand Up @@ -23,8 +23,10 @@ export async function fetchAndDisplayPreviewsFromCache(sorting?: Sorting, option
tasks: [],
};
}
const cachedTasks = _cachedTasks.tasks.map((task) => ({ ...task, isNew: false, isModified: false })) as TaskMaybeFull[];

const cachedTasks = _cachedTasks.tasks as TaskMaybeFull[];
taskManager.syncTasks(cachedTasks);

if (!cachedTasks.length) {
// load from network if there are no cached issues
return fetchAndDisplayPreviewsFromNetwork(sorting, options);
Expand Down Expand Up @@ -71,8 +73,7 @@ export function verifyGitHubIssueState(cachedTasks: TaskMaybeFull[], fetchedPrev
if (cachedTask) {
if (taskWithFullTest(cachedTask)) {
const cachedFullIssue = cachedTask.full;
const isModified = new Date(cachedFullIssue.updated_at) < new Date(fetched.preview.updated_at);
const task = { ...fetched, full: cachedFullIssue, isNew: false, isModified };
const task = { ...fetched, full: cachedFullIssue };
return task;
} else {
// no full issue in task
Expand All @@ -82,8 +83,6 @@ export function verifyGitHubIssueState(cachedTasks: TaskMaybeFull[], fetchedPrev
}
return {
preview: fetched.preview,
isNew: true,
isModified: false,
} as TaskNoFull;
});
}
Expand Down
16 changes: 16 additions & 0 deletions src/home/fetch-github/fetch-avatar.ts
Expand Up @@ -39,5 +39,21 @@ export async function fetchAvatar(orgName: string) {
}
} catch (error) {
console.error(`Failed to fetch avatar for organization ${orgName}: ${error}`);
const {
data: { avatar_url: avatarUrl },
} = await octokit.rest.users.getByUsername({ username: orgName });
if (avatarUrl) {
// Fetch the image as a Blob and save it to IndexedDB
const response = await fetch(avatarUrl);
const blob = await response.blob();
await saveImageToCache({
dbName: "GitHubAvatars",
storeName: "ImageStore",
keyName: "name",
orgName: `avatarUrl-${orgName}`,
avatarBlob: blob,
});
organizationImageCache.set(orgName, blob);
}
}
}
13 changes: 1 addition & 12 deletions src/home/getters/get-local-store.ts
Expand Up @@ -17,16 +17,5 @@ export function getLocalStore(key: string): TaskStorageItems | OAuthToken | null

export function setLocalStore(key: string, value: TaskStorageItems | OAuthToken) {
// remove state from issues before saving to local storage
if ("tasks" in value && value.tasks.length && "isNew" in value.tasks[0] && "isModified" in value.tasks[0]) {
const tasksWithoutState = value.tasks.map(({ preview, full }) => ({
preview,
full,
}));
localStorage[key] = JSON.stringify({
...value,
tasks: tasksWithoutState,
});
} else {
localStorage[key] = JSON.stringify(value);
}
localStorage[key] = JSON.stringify(value);
}
7 changes: 0 additions & 7 deletions src/home/rendering/render-github-issues.ts
Expand Up @@ -37,13 +37,6 @@ function everyNewIssue({ taskPreview, container }: { taskPreview: TaskMaybeFull;
issueElement.setAttribute("data-preview-id", taskPreview.preview.id.toString());
issueElement.classList.add("issue-element-inner");

if (taskPreview.isNew) {
issueWrapper.classList.add("new-task");
}
if (taskPreview.isModified) {
issueWrapper.classList.add("modified-task");
}

const urlPattern = /https:\/\/github\.com\/([^/]+)\/([^/]+)\//;
const match = taskPreview.preview.body.match(urlPattern);
const organizationName = match?.[1];
Expand Down
20 changes: 3 additions & 17 deletions static/style/inverted-style.css
Expand Up @@ -180,6 +180,9 @@
display: flex;
align-items: center;
height: 16px;
text-overflow: ellipsis;
overflow: hidden;
display: inline-block;
}
input[type="radio"] {
background-color: unset;
Expand Down Expand Up @@ -318,23 +321,6 @@
.full {
display: unset !important;
}
.new-task,
.modified-task {
position: relative;
}
.new-task::before,
.modified-task::before {
content: "";
display: inline-block;
position: absolute;
height: 100%;
width: 4px;
left: 0;
background-color: #00ffff;
}
.modified-task::before {
background-color: #ffff00;
}
@media screen and (max-width: 804px) {
.mid {
display: none !important;
Expand Down
20 changes: 3 additions & 17 deletions static/style/style.css
Expand Up @@ -180,6 +180,9 @@
display: flex;
align-items: center;
height: 16px;
text-overflow: ellipsis;
overflow: hidden;
display: inline-block;
}
input[type="radio"] {
background-color: unset;
Expand Down Expand Up @@ -318,23 +321,6 @@
.full {
display: unset !important;
}
.new-task,
.modified-task {
position: relative;
}
.new-task::before,
.modified-task::before {
content: "";
display: inline-block;
position: absolute;
height: 100%;
width: 4px;
left: 0;
background-color: #0ff;
}
.modified-task::before {
background-color: #ff0;
}
@media screen and (max-width: 804px) {
.mid {
display: none !important;
Expand Down

0 comments on commit 7f35ce4

Please sign in to comment.