feat: remove getRecords;fix image duplication issue

This commit is contained in:
yanle
2024-01-29 21:01:03 +08:00
parent 0f8e30cf20
commit 6358cbd293
3 changed files with 8 additions and 19 deletions
+5 -2
View File
@@ -452,7 +452,7 @@ export default function App() {
window.addEventListener("beforeunload", handleBeforeUnload);
api.addEventListener("executed", (e: any) => {
const handleExecuted = (e: any) => {
e.detail?.output?.images?.forEach(
(im: { filename: string; subfolder: string; type: string }) => {
if (im.type === "output") {
@@ -467,12 +467,15 @@ export default function App() {
}
},
);
});
};
api.addEventListener("executed", handleExecuted);
return () => {
// window.removeEventListener("message", authTokenListener);
window.removeEventListener("keydown", shortcutListener);
window.removeEventListener("change", fileInputListener);
window.removeEventListener("beforeunload", handleBeforeUnload);
window.removeEventListener("executed", handleExecuted);
clearInterval(autoSaveTimer.current);
};
}, []);
+2 -12
View File
@@ -20,21 +20,11 @@ export class ChangelogsTable extends TableBase<Changelog> {
.equals(workflowID)
.reverse()
.sortBy("createTime");
if (objects?.length) return objects;
const records = await this.getRecords();
return Object.values(records)
.filter((c) => c.workflowID === workflowID)
.sort((a, b) => b.createTime - a.createTime);
return objects;
}
public async getLastestByWorkflowID(workflowID: string): Promise<Changelog> {
const objects = await this.listByWorkflowID(workflowID);
if (objects?.length) return objects[0];
const records = await this.getRecords();
const all = Object.values(records)
.filter((c) => c.workflowID === workflowID)
.sort((a, b) => b.createTime - a.createTime);
return all[0];
return objects[0];
}
public async create(input: {
json: string;
+1 -5
View File
@@ -15,11 +15,7 @@ export class MediaTable extends TableBase<Media> {
.equals(workflowID)
.reverse()
.sortBy("createTime");
if (medias.length > 0) return medias;
const records = await this.getRecords();
return Object.values(records)
.filter((c) => c.workflowID === workflowID)
.sort((a, b) => b.createTime - a.createTime);
return medias;
}
public async create(input: {