Skip to content

Commit

Permalink
Helper set
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenwf committed Oct 2, 2023
1 parent e73d142 commit 09e362c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/thumbnail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { compatVault, CompatVault } from './compat';

export const imageServiceLoader = new ImageServiceLoader();

let helper: ReturnType<typeof createThumbnailHelper> | null = null;
const helpers: Map<CompatVault, ReturnType<typeof createThumbnailHelper>> = new Map();
export function getThumbnail(
input:
| string
Expand All @@ -45,7 +45,11 @@ export function getThumbnail(
...options
}: ImageCandidateRequest & { vault?: CompatVault; dereference?: boolean } = {}
) {
helper = helper || createThumbnailHelper(vault);
let helper = helpers.get(vault);
if (!helper) {
helper = createThumbnailHelper(vault);
helpers.set(vault, helper);
}
return helper.getBestThumbnailAtSize(input, options, dereference);
}

Expand Down

0 comments on commit 09e362c

Please sign in to comment.