mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 05:14:54 +00:00
refactor(editor): request refresh after finding stale bitmap (#10438)
This ensures a bitmap will be eventually generated after tile got invalidated.
This commit is contained in:
@@ -67,17 +67,10 @@ export class ViewportTurboRendererExtension extends LifeCycleWatcher {
|
||||
);
|
||||
});
|
||||
|
||||
const debouncedRefresh = debounce(
|
||||
() => {
|
||||
this.refresh().catch(console.error);
|
||||
},
|
||||
1000, // During this period, fallback to DOM
|
||||
{ leading: false, trailing: true }
|
||||
);
|
||||
this.disposables.add(
|
||||
this.std.store.slots.blockUpdated.on(() => {
|
||||
this.invalidate();
|
||||
debouncedRefresh();
|
||||
this.debouncedRefresh();
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -115,6 +108,14 @@ export class ViewportTurboRendererExtension extends LifeCycleWatcher {
|
||||
}
|
||||
}
|
||||
|
||||
debouncedRefresh = debounce(
|
||||
() => {
|
||||
this.refresh().catch(console.error);
|
||||
},
|
||||
1000, // During this period, fallback to DOM
|
||||
{ leading: false, trailing: true }
|
||||
);
|
||||
|
||||
invalidate() {
|
||||
this.layoutVersion++;
|
||||
this.layoutCache = null;
|
||||
@@ -190,7 +191,10 @@ export class ViewportTurboRendererExtension extends LifeCycleWatcher {
|
||||
}
|
||||
|
||||
private drawCachedBitmap(layout: ViewportLayout) {
|
||||
if (!this.tile) return; // version mismatch
|
||||
if (!this.tile) {
|
||||
this.debouncedRefresh();
|
||||
return; // version mismatch
|
||||
}
|
||||
|
||||
const bitmap = this.tile.bitmap;
|
||||
const ctx = this.canvas.getContext('2d');
|
||||
|
||||
Reference in New Issue
Block a user