remove backfill indexdb
This commit is contained in:
@@ -26,6 +26,7 @@ import {
|
||||
DarkMode,
|
||||
Tag,
|
||||
HStack,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import {
|
||||
IconArrowBackUpDouble,
|
||||
@@ -33,6 +34,7 @@ import {
|
||||
IconDeviceFloppy,
|
||||
IconDownload,
|
||||
IconHistory,
|
||||
IconLink,
|
||||
IconShare2,
|
||||
IconVersions,
|
||||
} from "@tabler/icons-react";
|
||||
@@ -83,7 +85,7 @@ export default function DropdownTitle() {
|
||||
setNewFlowName(event.target.value);
|
||||
submitError && setSubmitError("");
|
||||
};
|
||||
|
||||
const toast = useToast();
|
||||
const onSubmit = async () => {
|
||||
if (!curFlowID) {
|
||||
alert("Flow ID is required");
|
||||
@@ -194,6 +196,31 @@ export default function DropdownTitle() {
|
||||
<SharedTopbarButton />
|
||||
</HStack>
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
const cloudHost = userSettingsTable?.settings?.cloudHost!;
|
||||
|
||||
if (workflow?.cloudID) {
|
||||
navigator.clipboard.writeText(
|
||||
`${cloudHost}/workflow/${workflow.cloudID}`,
|
||||
);
|
||||
toast({
|
||||
title: "Link copied",
|
||||
status: "success",
|
||||
duration: 2000,
|
||||
});
|
||||
} else {
|
||||
setIsOpenNewVersion(true);
|
||||
}
|
||||
}}
|
||||
icon={<IconLink size={20} />}
|
||||
iconSpacing={1}
|
||||
alignItems={"center"}
|
||||
>
|
||||
<HStack>
|
||||
<p>Copy share link</p>
|
||||
</HStack>
|
||||
</MenuItem>
|
||||
</MenuList>
|
||||
</Menu>
|
||||
}
|
||||
|
||||
@@ -61,86 +61,4 @@ export async function loadDBs() {
|
||||
loadMedia(),
|
||||
loadWorkflowVersions(),
|
||||
]);
|
||||
if (localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL") !== "true") {
|
||||
await backfillIndexdb();
|
||||
localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL", "true");
|
||||
}
|
||||
}
|
||||
|
||||
export async function backfillIndexdb() {
|
||||
const backfillWorkflows = async () => {
|
||||
try {
|
||||
const all = await workflowsTable?.getRecords();
|
||||
all && (await indexdb.workflows.bulkPut(Object.values(all)));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
const backfillFolders = async () => {
|
||||
try {
|
||||
const all = await foldersTable?.getRecords();
|
||||
all && (await indexdb.folders.bulkPut(Object.values(all)));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
const backfillMedia = async () => {
|
||||
try {
|
||||
const all = await mediaTable?.getRecords();
|
||||
all && (await indexdb.media.bulkPut(Object.values(all)));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
const backfillChangelogs = async () => {
|
||||
try {
|
||||
const all = await changelogsTable?.getRecords();
|
||||
all && (await indexdb.changelogs.bulkPut(Object.values(all)));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
const backfillTags = async () => {
|
||||
try {
|
||||
const all = await tagsTable?.getRecords();
|
||||
all && (await indexdb.tags.bulkPut(Object.values(all)));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
const backfillUserSettings = async () => {
|
||||
try {
|
||||
const tableInstance = userSettingsTable!;
|
||||
const backupData = await tableInstance.getRecords().then((data) => {
|
||||
if (!data[tableInstance.DEFAULT_USER]) {
|
||||
// legacy
|
||||
return data;
|
||||
}
|
||||
return data[tableInstance.DEFAULT_USER];
|
||||
});
|
||||
await indexdb.userSettings.put({
|
||||
...tableInstance.defaultSettings,
|
||||
...backupData,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
const backfillWorkflowVersions = async () => {
|
||||
try {
|
||||
const all = await workflowVersionsTable?.getRecords();
|
||||
all && (await indexdb.workflowVersions.bulkPut(Object.values(all)));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
await Promise.all([
|
||||
backfillWorkflows(),
|
||||
backfillFolders(),
|
||||
backfillMedia(),
|
||||
backfillChangelogs(),
|
||||
backfillTags(),
|
||||
backfillUserSettings(),
|
||||
backfillWorkflowVersions(),
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user