Открыть боковую панель
Teknokomo
universo-react
Коммиты
633a5bab
Не подтверждена
Коммит
633a5bab
создал
Мар 06, 2024
по автору
EYHN
Просмотр файлов
fix(core): fix cmdk not show current page (#6031)
владелец
5d63ca0b
Изменения
2
Скрыть пробелы
Построчно
Рядом
packages/common/infra/src/livedata/react.ts
Просмотр файла @
633a5bab
...
@@ -7,10 +7,14 @@ function noopSubscribe() {
...
@@ -7,10 +7,14 @@ function noopSubscribe() {
return
()
=>
{};
return
()
=>
{};
}
}
function
n
oop
GetSnapshot
()
{
function
n
ull
GetSnapshot
()
{
return
null
;
return
null
;
}
}
function
undefinedGetSnapshot
()
{
return
undefined
;
}
/**
/**
* subscribe LiveData and return the value.
* subscribe LiveData and return the value.
*/
*/
...
@@ -25,7 +29,11 @@ export function useLiveData<Input extends LiveData<any> | null | undefined>(
...
@@ -25,7 +29,11 @@ export function useLiveData<Input extends LiveData<any> | null | undefined>(
:
never
{
:
never
{
return
useSyncExternalStore
(
return
useSyncExternalStore
(
liveData
?
liveData
.
reactSubscribe
:
noopSubscribe
,
liveData
?
liveData
.
reactSubscribe
:
noopSubscribe
,
liveData
?
liveData
.
reactGetSnapshot
:
noopGetSnapshot
liveData
?
liveData
.
reactGetSnapshot
:
liveData
===
undefined
?
undefinedGetSnapshot
:
nullGetSnapshot
);
);
}
}
...
...
packages/frontend/core/src/layouts/workspace-layout.tsx
Просмотр файла @
633a5bab
import
{
useBlockSuiteDocMeta
}
from
'
@affine/core/hooks/use-block-suite-page-meta
'
;
import
{
useWorkspaceStatus
}
from
'
@affine/core/hooks/use-workspace-status
'
;
import
{
useWorkspaceStatus
}
from
'
@affine/core/hooks/use-workspace-status
'
;
import
{
assertExists
}
from
'
@blocksuite/global/utils
'
;
import
{
assertExists
}
from
'
@blocksuite/global/utils
'
;
import
{
import
{
...
@@ -10,12 +9,12 @@ import {
...
@@ -10,12 +9,12 @@ import {
useSensor
,
useSensor
,
useSensors
,
useSensors
,
}
from
'
@dnd-kit/core
'
;
}
from
'
@dnd-kit/core
'
;
import
{
Workspace
}
from
'
@toeverything/infra
'
;
import
{
PageRecordList
,
useLiveData
,
Workspace
}
from
'
@toeverything/infra
'
;
import
{
useService
}
from
'
@toeverything/infra/di
'
;
import
{
useService
}
from
'
@toeverything/infra/di
'
;
import
{
useAtom
,
useAtomValue
,
useSetAtom
}
from
'
jotai
'
;
import
{
useAtom
,
useAtomValue
,
useSetAtom
}
from
'
jotai
'
;
import
type
{
PropsWithChildren
,
ReactNode
}
from
'
react
'
;
import
type
{
PropsWithChildren
,
ReactNode
}
from
'
react
'
;
import
{
lazy
,
Suspense
,
useCallback
,
useEffect
,
useState
}
from
'
react
'
;
import
{
lazy
,
Suspense
,
useCallback
,
useEffect
,
useState
}
from
'
react
'
;
import
{
useParams
}
from
'
react-router-dom
'
;
import
{
matchPath
,
useParams
}
from
'
react-router-dom
'
;
import
{
Map
as
YMap
}
from
'
yjs
'
;
import
{
Map
as
YMap
}
from
'
yjs
'
;
import
{
openQuickSearchModalAtom
,
openSettingModalAtom
}
from
'
../atoms
'
;
import
{
openQuickSearchModalAtom
,
openSettingModalAtom
}
from
'
../atoms
'
;
...
@@ -37,6 +36,7 @@ import { useAppSettingHelper } from '../hooks/affine/use-app-setting-helper';
...
@@ -37,6 +36,7 @@ import { useAppSettingHelper } from '../hooks/affine/use-app-setting-helper';
import
{
useSidebarDrag
}
from
'
../hooks/affine/use-sidebar-drag
'
;
import
{
useSidebarDrag
}
from
'
../hooks/affine/use-sidebar-drag
'
;
import
{
useNavigateHelper
}
from
'
../hooks/use-navigate-helper
'
;
import
{
useNavigateHelper
}
from
'
../hooks/use-navigate-helper
'
;
import
{
useRegisterWorkspaceCommands
}
from
'
../hooks/use-register-workspace-commands
'
;
import
{
useRegisterWorkspaceCommands
}
from
'
../hooks/use-register-workspace-commands
'
;
import
{
Workbench
}
from
'
../modules/workbench
'
;
import
{
import
{
AllWorkspaceModals
,
AllWorkspaceModals
,
CurrentWorkspaceModals
,
CurrentWorkspaceModals
,
...
@@ -55,16 +55,15 @@ export const QuickSearch = () => {
...
@@ -55,16 +55,15 @@ export const QuickSearch = () => {
openQuickSearchModalAtom
openQuickSearchModalAtom
);
);
const
currentWorkspace
=
useService
(
Workspace
);
const
workbench
=
useService
(
Workbench
);
const
{
pageId
}
=
useParams
();
const
currentPath
=
useLiveData
(
workbench
.
location
.
map
(
l
=>
l
.
pathname
));
const
blockSuiteWorkspace
=
currentWorkspace
.
blockSuiteWorkspace
;
const
pageRecordList
=
useService
(
PageRecordList
);
const
pageMeta
=
useBlockSuiteDocMeta
(
const
currentPathId
=
matchPath
(
'
/:pageId
'
,
currentPath
)?.
params
.
pageId
;
currentWorkspace
.
blockSuiteWorkspace
// TODO: getting pageid from route is fragile, get current page from context
).
find
(
meta
=>
meta
.
id
===
pageId
);
const
currentPage
=
useLiveData
(
currentPathId
?
pageRecordList
.
record
(
currentPathId
)
:
null
if
(
!
blockSuiteWorkspace
)
{
);
return
null
;
const
pageMeta
=
useLiveData
(
currentPage
?.
meta
);
}
return
(
return
(
<
CMDKQuickSearchModal
<
CMDKQuickSearchModal
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать