Skip to content

Commit

Permalink
fix: detectSnapshot snapshot id
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Nov 10, 2024
1 parent e2f5466 commit 6b937a8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/store/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const useSnapshotStore = defineStore('snapshot', () => {
exportSnapshotAsImportId(snapshot.value);
}
if (autoUpload.value && snapshot.value && importId.value) {
detectSnapshot(importId.value);
detectSnapshot(snapshot.value.id, importId.value);
}
});
const nodes = computed(() => {
Expand Down
21 changes: 15 additions & 6 deletions src/utils/export.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { saveAs } from 'file-saver';
import pLimit from 'p-limit';
import { uploadAsset } from './github';
import { delay } from './others';
import { delay, obj2usp } from './others';
import { screenshotStorage } from './snapshot';
import Compressor from 'compressorjs';
import type { Snapshot } from './types';
Expand Down Expand Up @@ -102,7 +102,7 @@ export const exportSnapshotAsImportId = async (snapshot: Snapshot) => {
).then((r) => {
snapshotImportId[snapshot.id] = r.id;
importSnapshotId[r.id] = snapshot.id;
detectFetchSnapshot(r.id);
detectFetchSnapshot(snapshot.id, r.id);
return r.id;
})
);
Expand Down Expand Up @@ -135,10 +135,19 @@ export const batchCreateZipUrl = async (snapshots: Snapshot[]) => {
}, []);
};

const detectFetchSnapshot = async (importId: number | string) => {
return fetch(`https://detect.gkd.li/api/detectSnapshot?importId=` + importId);
const detectFetchSnapshot = async (id: number, importId: number | string) => {
return fetch(
`https://detect.gkd.li/api/detectSnapshot?` +
obj2usp({
id,
importId,
}).toString(),
);
};
export const detectSnapshot = async (importId: number | string | undefined) => {
export const detectSnapshot = async (
id: number,
importId: number | string | undefined,
) => {
if (!importId) return;
if (!Number.isSafeInteger(+importId)) {
return;
Expand All @@ -148,5 +157,5 @@ export const detectSnapshot = async (importId: number | string | undefined) => {
if (importSnapshotId[importId]) {
return;
}
await detectFetchSnapshot(importId);
await detectFetchSnapshot(id, importId);
};

0 comments on commit 6b937a8

Please sign in to comment.