Skip to content

Commit

Permalink
chore(blocks): set readonly to database on mobile (#8975)
Browse files Browse the repository at this point in the history
  • Loading branch information
L-Sun committed Dec 16, 2024
1 parent 13d3d83 commit d90ff22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions packages/blocks/src/database-block/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
type ViewMeta,
} from '@blocksuite/data-view';
import { propertyPresets } from '@blocksuite/data-view/property-presets';
import { IS_MOBILE } from '@blocksuite/global/env';
import { assertExists } from '@blocksuite/global/utils';
import { type BlockModel, nanoid, Text } from '@blocksuite/store';
import { computed, type ReadonlySignal } from '@preact/signals-core';
Expand Down Expand Up @@ -69,8 +70,10 @@ export class DatabaseBlockDataSource extends DataSourceBase {
});

readonly$: ReadonlySignal<boolean> = computed(() => {
return this._model.doc.awarenessStore.isReadonly(
this._model.doc.blockCollection
return (
this._model.doc.readonly ||
// TODO(@L-Sun): use block level readonly
IS_MOBILE
);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/blocks/src/database-block/database-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<
return html` <affine-database-title
style="overflow: hidden"
.titleText="${this.model.title}"
.readonly="${this.doc.readonly}"
.readonly="${this.dataSource.readonly$.value}"
.onPressEnterKey="${addRow}"
></affine-database-title>`;
};
Expand Down Expand Up @@ -365,7 +365,7 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<
}

private renderDatabaseOps() {
if (this.doc.readonly) {
if (this.dataSource.readonly$.value) {
return nothing;
}
return html` <div class="database-ops" @click="${this._clickDatabaseOps}">
Expand Down

0 comments on commit d90ff22

Please sign in to comment.