mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-17 18:51:14 +01:00
♻️ Refactor icon picker (#724)
This commit is contained in:
32
src/tools/server/images/abstract-icons-repository.ts
Normal file
32
src/tools/server/images/abstract-icons-repository.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
export abstract class AbstractIconRepository {
|
||||
constructor(readonly copyright?: string) {}
|
||||
|
||||
async fetch(): Promise<NormalizedIconRepositoryResult> {
|
||||
try {
|
||||
return await this.fetchInternally();
|
||||
} catch (err) {
|
||||
return {
|
||||
success: false,
|
||||
count: 0,
|
||||
entries: [],
|
||||
name: '',
|
||||
copyright: this.copyright,
|
||||
};
|
||||
}
|
||||
}
|
||||
protected abstract fetchInternally(): Promise<NormalizedIconRepositoryResult>;
|
||||
}
|
||||
|
||||
export type NormalizedIconRepositoryResult = {
|
||||
name: string;
|
||||
success: boolean;
|
||||
count: number;
|
||||
copyright: string | undefined;
|
||||
entries: NormalizedIcon[];
|
||||
};
|
||||
|
||||
export type NormalizedIcon = {
|
||||
url: string;
|
||||
name: string;
|
||||
size: number;
|
||||
};
|
||||
Reference in New Issue
Block a user