Skip to content

Commit 7aaa1f8

Browse files
committed
Fix first visit record
1 parent b0e9885 commit 7aaa1f8

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/routes/+layout.svelte

+10-9
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,16 @@
2424
];
2525
2626
onMount(async () => {
27-
if ((await storage.getItem("first-visit")) !== "false") {
27+
let firstVisit = await storage.getItem("first-visit");
28+
if (firstVisit === null) {
29+
let response = await fetch("https://crates.io/api/v1/crates/tokio");
30+
let data = await response.json();
31+
response = await fetch(
32+
`https://query.rs/index/${data.crate.name}/${data.crate.newest_version}`
33+
);
34+
data = await response.json();
35+
await CrateDocManager.addCrate(data);
36+
2837
// Create first query record
2938
let statistics = await Statistics.load();
3039
await statistics.record(
@@ -36,14 +45,6 @@
3645
},
3746
true
3847
);
39-
40-
let response = await fetch("https://crates.io/api/v1/crates/tokio");
41-
let data = await response.json();
42-
response = await fetch(
43-
`https://query.rs/index/${data.crate.name}/${data.crate.newest_version}`
44-
);
45-
data = await response.json();
46-
await CrateDocManager.addCrate(data);
4748
await storage.setItem("first-visit", "false");
4849
}
4950
});

0 commit comments

Comments
 (0)