Skip to content

Commit 1c96b35

Browse files
committed
refactor(guess-the-word): use legacy naming for old format of saved words
1 parent 4f074ec commit 1c96b35

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const LOCAL_STORAGE_OLD_KEY = "discovered-words";
2-
const LOCAL_STORAGE_KEY = `dev-challenges/guess-the-word/${LOCAL_STORAGE_OLD_KEY}`;
1+
const LOCAL_STORAGE_LEGACY_KEY = "discovered-words";
2+
const LOCAL_STORAGE_KEY = `dev-challenges/guess-the-word/${LOCAL_STORAGE_LEGACY_KEY}`;
33

44
export const DISCOVERED_WORDS = Object.freeze({
5-
LOCAL_STORAGE_OLD_KEY,
5+
LOCAL_STORAGE_LEGACY_KEY,
66
LOCAL_STORAGE_KEY,
77
});

vanilla/guess-the-word/src/services/saved-words/old-format-adapter.js renamed to vanilla/guess-the-word/src/services/saved-words/legacy-adapter.js

File renamed without changes.

vanilla/guess-the-word/src/services/saved-words/load.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ const loadWordItem = ({ word, difficulties, completed }) => {
1010

1111
/** @param {(loadedWord: import("./adapter").WordItem) => Promise<void>} onLoadedWord */
1212
export const loadSavedWords = async (onLoadedWord) => {
13-
const oldSavedItem = localStorage.getItem(
14-
DISCOVERED_WORDS.LOCAL_STORAGE_OLD_KEY,
13+
const legacyItem = localStorage.getItem(
14+
DISCOVERED_WORDS.LOCAL_STORAGE_LEGACY_KEY,
1515
);
1616
const savedItem = localStorage.getItem(DISCOVERED_WORDS.LOCAL_STORAGE_KEY);
1717

18-
if (oldSavedItem != null && savedItem == null) {
19-
const sanitized = parseStoredItem(oldSavedItem);
20-
const { savedWordsLegacyAdapter } = await import("./old-format-adapter");
18+
if (legacyItem != null && savedItem == null) {
19+
const sanitized = parseStoredItem(legacyItem);
20+
const { savedWordsLegacyAdapter } = await import("./legacy-adapter");
2121

2222
await savedWordsLegacyAdapter(sanitized, async (wordItem) => {
2323
loadWordItem(wordItem);
@@ -26,7 +26,7 @@ export const loadSavedWords = async (onLoadedWord) => {
2626

2727
const data = Array.from(discoveredWords);
2828

29-
localStorage.removeItem(DISCOVERED_WORDS.LOCAL_STORAGE_OLD_KEY);
29+
localStorage.removeItem(DISCOVERED_WORDS.LOCAL_STORAGE_LEGACY_KEY);
3030
localStorage.setItem(
3131
DISCOVERED_WORDS.LOCAL_STORAGE_KEY,
3232
JSON.stringify(data),

0 commit comments

Comments
 (0)