Skip to content

Commit

Permalink
feat: handle org header label
Browse files Browse the repository at this point in the history
  • Loading branch information
zugdev committed Oct 30, 2024
1 parent 8152967 commit 7faad19
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/home/fetch-github/fetch-and-display-previews.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { GitHubIssue } from "../github-types";
import { taskManager } from "../home";
import { applyAvatarsToIssues, renderGitHubIssues } from "../rendering/render-github-issues";
import { renderOrgHeaderLabel } from "../rendering/render-org-header";
import { closeModal } from "../rendering/render-preview-modal";
import { Sorting } from "../sorting/generate-sorting-buttons";
import { sortIssuesController } from "../sorting/sort-issues-controller";
Expand Down Expand Up @@ -65,6 +66,8 @@ function filterIssuesByOrganization(issues: GitHubIssue[]): GitHubIssue[] {
window.location.href = "/";
}

renderOrgHeaderLabel(urlOrgName);

return filteredIssues;
}

Expand Down
30 changes: 30 additions & 0 deletions src/home/rendering/render-org-header.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { organizationImageCache } from "../fetch-github/fetch-issues-full";

export function renderOrgHeaderLabel(orgName: string): void {
const brandingDiv = document.getElementById("branding");
if (!brandingDiv) return;

// Fetch the organization logo from the cache
const logoBlob = organizationImageCache.get(orgName);

if (logoBlob) {
// Convert Blob to a URL
const logoUrl = URL.createObjectURL(logoBlob);

const img = document.createElement("img");
img.src = logoUrl;
img.alt = `${orgName} Logo`;
img.id = "logo";
img.style.width = "24.469px"; // same size as default SVG
img.style.height = "28px";
img.style.objectFit = "contain";

// Replace the existing SVG with the new image
const svgLogo = brandingDiv.querySelector("svg#logo");
if (svgLogo) brandingDiv.replaceChild(img, svgLogo);
}

// Update the organization name inside the span with class 'full'
const orgNameSpan = brandingDiv.querySelector("span.full");
if (orgNameSpan) orgNameSpan.textContent = `${orgName} | `;
}

0 comments on commit 7faad19

Please sign in to comment.