fix(web): runtime issue (#5493)
This commit is contained in:
parent
259700c45f
commit
05e9697dff
1 changed files with 11 additions and 8 deletions
|
@ -83,28 +83,31 @@ export class AssetStore {
|
||||||
|
|
||||||
subscribe = this.store$.subscribe;
|
subscribe = this.store$.subscribe;
|
||||||
|
|
||||||
|
private addPendingChanges(...changes: PendingChange[]) {
|
||||||
|
// prevent websocket events from happening before local client events
|
||||||
|
setTimeout(() => {
|
||||||
|
this.pendingChanges.push(...changes);
|
||||||
|
this.processPendingChanges();
|
||||||
|
}, 1_000);
|
||||||
|
}
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
this.unsubscribers.push(
|
this.unsubscribers.push(
|
||||||
websocketStore.onUploadSuccess.subscribe((value) => {
|
websocketStore.onUploadSuccess.subscribe((value) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
this.pendingChanges.push({ type: 'add', value });
|
this.addPendingChanges({ type: 'add', value });
|
||||||
this.processPendingChanges();
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
websocketStore.onAssetTrash.subscribe((ids) => {
|
websocketStore.onAssetTrash.subscribe((ids) => {
|
||||||
if (ids) {
|
if (ids) {
|
||||||
for (const id of ids) {
|
this.addPendingChanges(...ids.map((id) => ({ type: 'trash', value: id }) as PendingChange));
|
||||||
this.pendingChanges.push({ type: 'trash', value: id });
|
|
||||||
}
|
|
||||||
this.processPendingChanges();
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
websocketStore.onAssetDelete.subscribe((value) => {
|
websocketStore.onAssetDelete.subscribe((value) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
this.pendingChanges.push({ type: 'delete', value });
|
this.addPendingChanges({ type: 'delete', value });
|
||||||
this.processPendingChanges();
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue