Skip to content
Merged
Changes from 2 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
19 changes: 7 additions & 12 deletions src/app/pages/officers/officers.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@ export class OfficersComponent {
// TODO: Fetch this from the back end.
newAdmin = structuredClone(executives.find(e => e.startYear === year));
if (!newAdmin) {
throw new Error(`Administration for year ${year} not found.`);
// Fall back to the most recent administration if current year not found.
const mostRecent = executives.reduce((latest, exec) =>
Comment thread
jbriones1 marked this conversation as resolved.
Outdated
exec.startYear > latest.startYear ? exec : latest
);
newAdmin = structuredClone(mostRecent);
}
const actualYear = newAdmin.startYear;
// FIXME: Remove this once admins are properly fetched.
newAdmin.members = newAdmin.members.map(exec => {
return {
...exec,
photoName: this.toLocalUrl(exec.photoName)
photoName: `images/executives/${actualYear}/${exec.photoName}`
Comment thread
jbriones1 marked this conversation as resolved.
Outdated
};
});
// end of FIXME:
Expand All @@ -45,14 +50,4 @@ export class OfficersComponent {
* Will probably need some way to remove older cached entries if memory becomes an issue.
*/
private cachedAdmins = new Map<number, ExecutiveAdministration>();

/**
* Changes the files name to one that can be used to set the background image.
*
* @param fileName - The file name to change. Must be in the `public/images/` folder
* @returns File name in the CSS URL form.
*/
private toLocalUrl(fileName: string): string {
return `images/executives/${this.currentYear()}/${fileName}`;
}
}