mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 20:38:52 +00:00
refactor(electron): sqlite db data workflow (remove symlink & fs watcher) (#2491)
This commit is contained in:
@@ -25,24 +25,22 @@ import { CameraIcon } from './icons';
|
||||
import { WorkspaceLeave } from './leave';
|
||||
import { StyledInput } from './style';
|
||||
|
||||
const useDBFilePathMeta = (workspaceId: string) => {
|
||||
const [meta, setMeta] = useState<{
|
||||
path: string;
|
||||
realPath: string;
|
||||
}>();
|
||||
const useShowOpenDBFile = (workspaceId: string) => {
|
||||
const [show, setShow] = useState(false);
|
||||
useEffect(() => {
|
||||
if (window.apis && window.events) {
|
||||
window.apis.db.getDBFilePath(workspaceId).then(meta => {
|
||||
setMeta(meta);
|
||||
if (window.apis && window.events && environment.isDesktop) {
|
||||
window.apis.workspace.getMeta(workspaceId).then(meta => {
|
||||
setShow(!!meta.secondaryDBPath);
|
||||
});
|
||||
return window.events.db.onDBFilePathChange(meta => {
|
||||
if (meta.workspaceId === workspaceId) {
|
||||
setMeta(meta);
|
||||
return window.events.workspace.onMetaChange(newMeta => {
|
||||
if (newMeta.workspaceId === workspaceId) {
|
||||
const meta = newMeta.meta;
|
||||
setShow(!!meta.secondaryDBPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [workspaceId]);
|
||||
return meta;
|
||||
return show;
|
||||
};
|
||||
|
||||
export const GeneralPanel: React.FC<PanelProps> = ({
|
||||
@@ -58,9 +56,7 @@ export const GeneralPanel: React.FC<PanelProps> = ({
|
||||
const isOwner = useIsWorkspaceOwner(workspace);
|
||||
const t = useAFFiNEI18N();
|
||||
|
||||
const dbPathMeta = useDBFilePathMeta(workspace.id);
|
||||
const showOpenFolder =
|
||||
environment.isDesktop && dbPathMeta?.path !== dbPathMeta?.realPath;
|
||||
const showOpenFolder = useShowOpenDBFile(workspace.id);
|
||||
|
||||
const handleUpdateWorkspaceName = (name: string) => {
|
||||
setName(name);
|
||||
|
||||
Reference in New Issue
Block a user