Skip to content

Commit f59953a

Browse files
committed
fix: hide suggested goal if already chosen
1 parent bb93214 commit f59953a

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

meta/tasks/upnext/hide-suggested-goal-if-already-chosen.md renamed to meta/tasks/done/hide-suggested-goal-if-already-chosen.md

File renamed without changes.

src/routes/+page.svelte

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
let error = $state("");
99
let goalCalendar = $state([]);
1010
let heroSuggestion = $state(null);
11+
let goals = $state([]);
1112
let items = $state([]);
1213
let dailyProgress = $state(null);
1314
let dailyStreak = $state(0);
@@ -16,6 +17,16 @@
1617
1718
const DAYS_TO_SHOW = 7;
1819
20+
let isSuggestionAdopted = $derived(
21+
heroSuggestion !== null &&
22+
goals.some(
23+
(g) =>
24+
g.hero_id === heroSuggestion.hero_id &&
25+
g.metric === "LastHits" &&
26+
g.target_time_minutes === 10
27+
)
28+
);
29+
1930
onMount(async () => {
2031
await loadGoalCalendar();
2132
await loadHeroSuggestion();
@@ -75,7 +86,10 @@
7586
7687
async function loadGoalCalendar() {
7788
try {
78-
goalCalendar = await invoke("get_goals_calendar", { days: DAYS_TO_SHOW });
89+
[goalCalendar, goals] = await Promise.all([
90+
invoke("get_goals_calendar", { days: DAYS_TO_SHOW }),
91+
invoke("get_goals"),
92+
]);
7993
} catch (e) {
8094
error = `Failed to load goal calendar: ${e}`;
8195
console.error("Failed to load goal calendar:", e);
@@ -103,7 +117,6 @@
103117
game_mode: "Ranked"
104118
}
105119
});
106-
alert("Goal created successfully!");
107120
await loadGoalCalendar();
108121
} catch (e) {
109122
error = `Failed to create goal: ${e}`;
@@ -277,7 +290,7 @@
277290
</div>
278291
{/if}
279292

280-
{#if heroSuggestion}
293+
{#if heroSuggestion && !isSuggestionAdopted}
281294
<div class="suggestion-section">
282295
<h2>🎯 Suggested Goal This Week</h2>
283296
<div class="suggestion-card">

0 commit comments

Comments
 (0)