diff --git a/src/api/_collectables.js b/src/api/_collectables.js index 6aa6509d..8c51cadc 100644 --- a/src/api/_collectables.js +++ b/src/api/_collectables.js @@ -1,4 +1,4 @@ -import { getShowHiddenSetting } from "../util/utils" +import { getShowHiddenSetting, getShowUnobtainedSetting } from "../util/utils" function getHigherQualityBattlePet(currentPet, newPet) { function getPetsQuality(type) { @@ -26,6 +26,7 @@ export async function parseCollectablesObject(categories, profile, collected_dat var totalPossible = 0; var showHiddenItems = getShowHiddenSetting(); + var showUnobtainedOnly = getShowUnobtainedSetting(); // Build up lookup for items that character has collected_data[collectedProperty].forEach((item) => { @@ -147,6 +148,10 @@ export async function parseCollectablesObject(categories, profile, collected_dat showthis = false; } + if(hasthis && showUnobtainedOnly == "true") { + showthis = false; + } + if (item.allowableRaces && item.allowableRaces.length > 0) { var foundRace = false; @@ -180,9 +185,9 @@ export async function parseCollectablesObject(categories, profile, collected_dat if (hasthis) { totalCollected++; } - totalPossible++; } + }); if (subCat.items.length > 0) { diff --git a/src/api/achievements.js b/src/api/achievements.js index 2b2b9f46..2dfa10cd 100644 --- a/src/api/achievements.js +++ b/src/api/achievements.js @@ -3,7 +3,7 @@ import { getProfile } from '$api/profile' import { getJsonDb } from '$api/_db' import settings from '$util/settings' import Cache from '$api/_cache' -import { getShowHiddenSetting, getShowHiddenFeatSetting } from '../util/utils' +import { getShowHiddenSetting, getShowHiddenFeatSetting, getShowUnobtainedSetting } from '../util/utils' let _cache; export async function getAchievements(region, realm, character) { @@ -40,6 +40,7 @@ function parseAchievementObject(db, earned, character, faction) { console.log(`Parsing achievements.json...`) var showHiddenItems = getShowHiddenSetting(); var showHiddenFeats = getShowHiddenFeatSetting(); + var showOnlyUnobtained = getShowUnobtainedSetting(); let obj = {} , completed = {} @@ -120,8 +121,10 @@ function parseAchievementObject(db, earned, character, faction) { // Always add it if we've completed it, it should show up regardless if its available if (myAchievement.completed) { - added = true; - mySubCat.achievements.push(myAchievement); + if(showOnlyUnobtained == "false") { + added = true; + mySubCat.achievements.push(myAchievement); + } // if this is feats of strength then I want to keep a seperate count for that // since its not a percentage thing @@ -163,7 +166,13 @@ function parseAchievementObject(db, earned, character, faction) { // if we haven't already added it, then this is one that should show up in the page of achievements // so add it if (!added) { - mySubCat.achievements.push(myAchievement); + if(showOnlyUnobtained == "true") { + if(!myAchievement.completed) { + mySubCat.achievements.push(myAchievement); + } + } else { + mySubCat.achievements.push(myAchievement); + } } } }) diff --git a/src/api/titles.js b/src/api/titles.js index 48018e72..01300d27 100644 --- a/src/api/titles.js +++ b/src/api/titles.js @@ -2,7 +2,7 @@ import { getData } from '$api/_blizzard' import { getProfile } from '$api/profile' import { getJsonDb } from '$api/_db' import Cache from '$api/_cache' -import { getShowHiddenSetting } from '../util/utils' +import { getShowHiddenSetting, getShowUnobtainedSetting } from '../util/utils' let _cache; export async function getTitles(region, realm, character) { @@ -45,6 +45,7 @@ function parseTitlesObject(db, profile, earned) { var totalPossible = 0; var showHiddenItems = getShowHiddenSetting(); + var showUnobtainedOnly = getShowUnobtainedSetting(); // Build up lookup for titles that character has earned.forEach((title) => { @@ -80,6 +81,10 @@ function parseTitlesObject(db, profile, earned) { showthis = false; } + if(hasthis && showUnobtainedOnly == "true") { + showthis = false; + } + if (item.gender && item.gender !== profile.genderMapped) { showthis = false; } diff --git a/src/pages/Settings.svelte b/src/pages/Settings.svelte index 44a9560e..b129b987 100644 --- a/src/pages/Settings.svelte +++ b/src/pages/Settings.svelte @@ -68,6 +68,14 @@ localStorage.setItem('showHiddenFeat', $preferences.showHiddenFeat); } + const toggleShowUnobtained = (e) => { + e.preventDefault(); + $preferences.showUnobtainedOnly = $preferences.showUnobtainedOnly == "false" ? "true" : "false"; + + localStorage.setItem('showHiddenUpdated',Date.now()); + localStorage.setItem('showUnobtainedOnly', $preferences.showUnobtainedOnly); + } + function setLocale(e, wowhead_url) { e.preventDefault(); @@ -119,6 +127,11 @@ >{$preferences.showHiddenFeat === "hidden" ? "Show Obtainable Feat of Strengths" : "Hide Obtainable Feat of Strengths"} +
+ {$preferences.showUnobtainedOnly === "false" ? "Show Only Unobtained" : "Show Obtained and Unobtained"} +
+
Locale