Skip to content

Commit a06eaab

Browse files
authored
Merge pull request #6 from kiing-dom/fix/issues-2-persist-problem-solved
fix: actually solved state problem
2 parents 9c0019a + 85247ff commit a06eaab

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

content.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,21 @@ function waitForContentAndStore() {
4949
observer.disconnect();
5050
const data = await getProblemData();
5151
if (!data) return; // Don't store invalid/undefined problems
52-
browser.storage.local.set({ [data.slug]: data }).then(() => {
53-
console.log("Saved to storage:", data);
54-
}).catch((err) => {
55-
console.error("Storage error:", err);
52+
// Preserve existing status and solvedAt if present
53+
browser.storage.local.get(data.slug).then((existing) => {
54+
const prev = existing[data.slug] || {};
55+
if (prev.status === "Solved") {
56+
data.status = prev.status;
57+
data.solvedAt = prev.solvedAt;
58+
}
59+
browser.storage.local.set({ [data.slug]: data }).then(() => {
60+
console.log("Saved to storage:", data);
61+
}).catch((err) => {
62+
console.error("Storage error:", err);
63+
});
64+
// Start watching for submission result after we have the slug
65+
waitForSubmissionResult(data.slug);
5666
});
57-
// Start watching for submission result after we have the slug
58-
waitForSubmissionResult(data.slug);
5967
}
6068
});
6169

0 commit comments

Comments
 (0)