|
8 | 8 | let error = $state(""); |
9 | 9 | let goalCalendar = $state([]); |
10 | 10 | let heroSuggestion = $state(null); |
| 11 | + let goals = $state([]); |
11 | 12 | let items = $state([]); |
12 | 13 | let dailyProgress = $state(null); |
13 | 14 | let dailyStreak = $state(0); |
|
16 | 17 |
|
17 | 18 | const DAYS_TO_SHOW = 7; |
18 | 19 |
|
| 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 | +
|
19 | 30 | onMount(async () => { |
20 | 31 | await loadGoalCalendar(); |
21 | 32 | await loadHeroSuggestion(); |
|
75 | 86 |
|
76 | 87 | async function loadGoalCalendar() { |
77 | 88 | 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 | + ]); |
79 | 93 | } catch (e) { |
80 | 94 | error = `Failed to load goal calendar: ${e}`; |
81 | 95 | console.error("Failed to load goal calendar:", e); |
|
103 | 117 | game_mode: "Ranked" |
104 | 118 | } |
105 | 119 | }); |
106 | | - alert("Goal created successfully!"); |
107 | 120 | await loadGoalCalendar(); |
108 | 121 | } catch (e) { |
109 | 122 | error = `Failed to create goal: ${e}`; |
|
277 | 290 | </div> |
278 | 291 | {/if} |
279 | 292 |
|
280 | | - {#if heroSuggestion} |
| 293 | + {#if heroSuggestion && !isSuggestionAdopted} |
281 | 294 | <div class="suggestion-section"> |
282 | 295 | <h2>🎯 Suggested Goal This Week</h2> |
283 | 296 | <div class="suggestion-card"> |
|
0 commit comments