Skip to content

Commit

Permalink
use sessionStorage instead of prefs for shouldDiscardData (#74)
Browse files Browse the repository at this point in the history
* use sessionStorage for `shouldDiscardData`

* rename prefs to session storage keys
  • Loading branch information
horrible-little-slime committed Apr 13, 2024
1 parent 505c521 commit b60cd00
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/excavator-projects/projects/designerSweatpants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function spadeSweatpants(encounter: string, page: string) {
if (!sweat) return null;

const location = toNormalisedString(myLocation());
if (shouldDiscardData("_excavatorSweatpantsLocations", location)) return null;
if (shouldDiscardData("DesignerSweatpants", location)) return null;

return {
location,
Expand Down
2 changes: 1 addition & 1 deletion packages/excavator-projects/projects/mummingTrunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function spadeMummingTrunk(encounter: string, page: string) {
);

if (!match) return null;
if (shouldDiscardData("_excavatorMummingTrunk", `${fam.id}:${match[0]}`))
if (shouldDiscardData("MummingTrunk", `${fam.id}:${match[0]}`))
return null;

return {
Expand Down
6 changes: 3 additions & 3 deletions packages/excavator-projects/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
myLocation,
myPath,
Path,
setProperty,
sessionStorage,
} from "kolmafia";

const ALTERING_EFFECTS = Effect.get([
Expand Down Expand Up @@ -90,9 +90,9 @@ export function notNull<T>(value: T | null): value is T {
}

export function shouldDiscardData(property: string, data: string) {
const sentData = getProperty(property).split("|");
const sentData = (sessionStorage.getItem(property) ?? "").split("|");
if (sentData.includes(data)) return true;

setProperty(property, [...sentData, data].join("|"));
sessionStorage.setItem(property, [...sentData, data].join("|"));
return false;
}

0 comments on commit b60cd00

Please sign in to comment.