Skip to content

Commit

Permalink
fix(service-providers): (snapshot) fetch images without cache (#1786)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrious authored Nov 21, 2022
1 parent 188d2b3 commit e8787a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions cspell.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
"Magix",
"quickstart",
"signup",
"dataurl",

// wechat
"wechat",
Expand Down
15 changes: 9 additions & 6 deletions service-providers/fastboard/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,23 +333,26 @@ export class Fastboard extends IServiceWhiteboard {
return [];
}

type snapshot_t = typeof import("@netless/white-snapshot").snapshot;
type src2dataurl_t = typeof import("@netless/white-snapshot").src2dataurl;

const displayer: Displayer = {
state: app.manager,
fillSceneSnapshot: app.manager.mainView.fillSceneSnapshot.bind(app.manager.mainView),
};
const scenes = app.manager.sceneState.scenes;
const actions: Array<
(snapshot: (...args: any) => Promise<HTMLCanvasElement | null>) => Promise<void>
> = Array(scenes.length);
const actions: Array<(snapshot: snapshot_t, src2dataurl: src2dataurl_t) => Promise<void>> =
Array(scenes.length);
const canvases: Array<Promise<HTMLCanvasElement | null>> = Array(scenes.length);

scenes.forEach((scene, i) => {
canvases[i] = new Promise(resolve => {
actions[i] = async snapshot => {
actions[i] = async (snapshot, src2dataurl) => {
try {
const canvas = await snapshot(displayer, {
scenePath: app.manager.mainViewSceneDir + scene.name,
crossorigin: true,
src2dataurl: src => src2dataurl(src, true),
});
resolve(canvas);
} catch (e) {
Expand All @@ -362,9 +365,9 @@ export class Fastboard extends IServiceWhiteboard {
});

Promise.resolve().then(async () => {
const { snapshot } = await import("@netless/white-snapshot");
const { snapshot, src2dataurl } = await import("@netless/white-snapshot");
for (const act of actions) {
await act(snapshot);
await act(snapshot, src2dataurl);
}
});

Expand Down

0 comments on commit e8787a7

Please sign in to comment.