Skip to content

Commit

Permalink
fix(service-providers): remove room writable hack (#1850)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrious committed Mar 6, 2023
1 parent b055247 commit 7c2b546
Showing 1 changed file with 5 additions and 25 deletions.
30 changes: 5 additions & 25 deletions service-providers/fastboard/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
} from "@netless/flat-services";
import { WindowManager } from "@netless/window-manager";
import { ReadonlyVal, Val, combine } from "value-enhancer";
import { AsyncSideEffectManager } from "side-effect-manager";

import { registerColorShortcut } from "./color-shortcut";
import { injectCursor } from "./inject-cursor";
Expand Down Expand Up @@ -39,7 +38,6 @@ export interface FastboardConfig {
}

export class Fastboard extends IServiceWhiteboard {
private asyncSideEffect = new AsyncSideEffectManager();
private toaster: Toaster;
private flatI18n: FlatI18n;
private flatInfo: FlatInfo;
Expand Down Expand Up @@ -130,30 +128,13 @@ export class Fastboard extends IServiceWhiteboard {
}
// room.isWritable follows allowDrawing for now
if (isWritable !== room.isWritable) {
this.asyncSideEffect.add(async () => {
let isDisposed = false;
try {
if (isWritable) {
await app.room.setWritable(true);
} else {
// wait until room isWritable
// remove after the issue is fixed
await app.syncedStore.nextFrame();
if (!isDisposed) {
await app.room.setWritable(false);
}
}
} catch (e) {
if (process.env.NODE_ENV !== "production") {
console.error(e);
}
app.room.setWritable(isWritable).catch(e => {
if (process.env.NODE_ENV !== "production") {
console.error(e);
}
return () => {
isDisposed = true;
};
}, "setWritable");
});
}
}, true),
}),
this._el$.subscribe(el => {
if (el) {
this.ui.mount(el, {
Expand Down Expand Up @@ -338,7 +319,6 @@ export class Fastboard extends IServiceWhiteboard {

public override async destroy(): Promise<void> {
super.destroy();
this.asyncSideEffect.flushAll();
await this.leaveRoom();
}

Expand Down

0 comments on commit 7c2b546

Please sign in to comment.