fix: type import (#2715)

This commit is contained in:
Himself65
2023-06-07 22:47:02 +08:00
committed by GitHub
parent 008a05a470
commit 7f2006488e
24 changed files with 60 additions and 91 deletions

View File

@@ -50,8 +50,10 @@ rootWorkspacesMetadataAtom.onMount = setAtom => {
}, 0);
if (environment.isDesktop) {
// @ts-expect-error
window.apis?.workspace.list().then(workspaceIDs => {
if (abortController.signal.aborted) return;
// @ts-expect-error
const newMetadata = workspaceIDs.map(w => ({
id: w[0],
flavour: WorkspaceFlavour.LOCAL,
@@ -59,6 +61,7 @@ rootWorkspacesMetadataAtom.onMount = setAtom => {
setAtom(metadata => {
return [
...metadata,
// @ts-expect-error
...newMetadata.filter(m => !metadata.find(m2 => m2.id === m.id)),
];
});

View File

@@ -122,6 +122,7 @@ const useDefaultDBLocation = () => {
const [defaultDBLocation, setDefaultDBLocation] = useState('');
useEffect(() => {
// @ts-expect-error
window.apis?.db.getDefaultStorageLocation().then(dir => {
setDefaultDBLocation(dir);
});
@@ -147,6 +148,7 @@ const SetDBLocationContent = ({
if (result?.filePath) {
onConfirmLocation(result.filePath);
} else if (result?.error) {
// @ts-expect-error
toast(t[result.error]());
}
};
@@ -277,6 +279,7 @@ export const CreateWorkspaceModal = ({
setStep('set-syncing-mode');
} else if (result.error || result.canceled) {
if (result.error) {
// @ts-expect-error
toast(t[result.error]());
}
onClose();

View File

@@ -18,6 +18,7 @@ export const ExportPanel = () => {
if (id) {
const result = await window.apis?.dialog.saveDBFileAs(id);
if (result?.error) {
// @ts-expect-error
toast(t[result.error]());
} else if (!result?.canceled) {
toast(t['Export success']());

View File

@@ -27,9 +27,11 @@ const useShowOpenDBFile = (workspaceId: string) => {
const [show, setShow] = useState(false);
useEffect(() => {
if (window.apis && window.events && environment.isDesktop) {
// @ts-expect-error
window.apis.workspace.getMeta(workspaceId).then(meta => {
setShow(!!meta.secondaryDBPath);
});
// @ts-expect-error
return window.events.workspace.onMetaChange(newMeta => {
if (newMeta.workspaceId === workspaceId) {
const meta = newMeta.meta;
@@ -73,6 +75,7 @@ export const GeneralPanel: React.FC<PanelProps> = ({
if (!result?.error && !result?.canceled) {
toast(t['Move folder success']());
} else if (result?.error) {
// @ts-expect-error
toast(t[result.error]());
}
} catch (err) {