mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-27 17:22:36 +03:00
feat(core): selector for editorSetting hooks (#8108)
This commit is contained in:
parent
3837c84791
commit
691bfed185
@ -603,7 +603,9 @@ export const PagePropertiesTableHeader = ({
|
||||
const docBacklinks = docLinksServices.backlinks;
|
||||
const backlinks = useLiveData(docBacklinks.backlinks$);
|
||||
|
||||
const settings = useLiveData(editorSettingService.editorSetting.settings$);
|
||||
const displayDocInfo = useLiveData(
|
||||
editorSettingService.editorSetting.settings$.selector(s => s.displayDocInfo)
|
||||
);
|
||||
|
||||
const { syncing, retrying, serverClock } = useLiveData(
|
||||
workspaceService.workspace.engine.doc.docState$(docService.doc.id)
|
||||
@ -696,7 +698,7 @@ export const PagePropertiesTableHeader = ({
|
||||
{dTimestampElement}
|
||||
</div>
|
||||
<Divider />
|
||||
{settings.displayDocInfo ? (
|
||||
{displayDocInfo ? (
|
||||
<div className={styles.tableHeaderSecondaryRow}>
|
||||
<div className={clsx(!open ? styles.pageInfoDimmed : null)}>
|
||||
{t['com.affine.page-properties.page-info']()}
|
||||
|
@ -191,7 +191,11 @@ export const BlocksuiteDocEditor = forwardRef<
|
||||
|
||||
const [specs, portals] = usePatchSpecs(page, !!shared, 'page');
|
||||
|
||||
const settings = useLiveData(editorSettingService.editorSetting.settings$);
|
||||
const displayBiDirectionalLink = useLiveData(
|
||||
editorSettingService.editorSetting.settings$.selector(
|
||||
s => s.displayBiDirectionalLink
|
||||
)
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -210,7 +214,7 @@ export const BlocksuiteDocEditor = forwardRef<
|
||||
hasViewport={false}
|
||||
/>
|
||||
<div className={styles.docEditorGap} onClick={onClickBlank}></div>
|
||||
{!shared && settings.displayBiDirectionalLink ? (
|
||||
{!shared && displayBiDirectionalLink ? (
|
||||
<BiDirectionalLinkPanel />
|
||||
) : null}
|
||||
</div>
|
||||
|
@ -92,7 +92,9 @@ export const PeekViewModalContainer = forwardRef<
|
||||
const controlsRef = useRef<HTMLDivElement>(null);
|
||||
const prevAnimeMap = useRef<Record<string, AnimeInstance | undefined>>({});
|
||||
const editorSettings = useService(EditorSettingService).editorSetting;
|
||||
const settings = useLiveData(editorSettings.settings$);
|
||||
const fullWidthLayout = useLiveData(
|
||||
editorSettings.settings$.selector(s => s.fullWidthLayout)
|
||||
);
|
||||
|
||||
const animateControls = useCallback((animateIn = false) => {
|
||||
const controls = controlsRef.current;
|
||||
@ -322,7 +324,7 @@ export const PeekViewModalContainer = forwardRef<
|
||||
>
|
||||
<div
|
||||
data-anime-state={animeState}
|
||||
data-full-width-layout={settings.fullWidthLayout}
|
||||
data-full-width-layout={fullWidthLayout}
|
||||
ref={contentClipRef}
|
||||
className={styles.modalContentContainer}
|
||||
>
|
||||
|
@ -187,8 +187,8 @@ export const SignOutConfirmModal = () => {
|
||||
export const AIReloadConfirmModal = () => {
|
||||
const editorSettingService = useService(EditorSettingService);
|
||||
const enableAI = useLiveData(
|
||||
editorSettingService.editorSetting.settings$
|
||||
).enableAI;
|
||||
editorSettingService.editorSetting.settings$.selector(s => s.enableAI)
|
||||
);
|
||||
const [aiState] = useState(enableAI);
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
|
@ -13,7 +13,9 @@ import { RowLayout } from '../row.layout';
|
||||
export const FontStyleSetting = () => {
|
||||
const t = useI18n();
|
||||
const editorSetting = useService(EditorSettingService).editorSetting;
|
||||
const settings = useLiveData(editorSetting.settings$);
|
||||
const fontFamily = useLiveData(
|
||||
editorSetting.settings$.selector(s => s.fontFamily)
|
||||
);
|
||||
|
||||
const options = useMemo(() => getBaseFontStyleOptions(t), [t]);
|
||||
const handleEdit = useCallback(
|
||||
@ -27,7 +29,7 @@ export const FontStyleSetting = () => {
|
||||
<RowLayout label={t['com.affine.mobile.setting.appearance.font']()}>
|
||||
<SettingDropdownSelect<FontFamily>
|
||||
options={options}
|
||||
value={settings.fontFamily}
|
||||
value={fontFamily}
|
||||
onChange={handleEdit}
|
||||
/>
|
||||
</RowLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user