Skip to content

Commit

Permalink
Fix updates dialog resetting selection if an update check happens whi…
Browse files Browse the repository at this point in the history
…le it is open
  • Loading branch information
mircearoata committed Oct 22, 2024
1 parent dbb5bc0 commit fbcd792
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions frontend/src/lib/components/modals/updates/UpdatesModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
async function updateSelected() {
if($selectedUpdates.length > 0) {
try {
await UpdateMods($selectedUpdates.map((u) => u.item));
$updates = $updates.filter((u) => !$selectedUpdates.includes(u));
await UpdateMods($selectedUpdates);
$updates = $updates.filter((u) => !$selectedUpdates.includes(u.item));
} catch(e) {
if (e instanceof Error) {
$error = e.message;
Expand All @@ -88,10 +88,10 @@
}
function toggleSelected(update: ficsitcli.Update) {
if($selectedUpdates.includes(update)) {
$selectedUpdates = $selectedUpdates.filter((u) => u !== update);
if($selectedUpdates.includes(update.item)) {
$selectedUpdates = $selectedUpdates.filter((u) => u !== update.item);
} else {
$selectedUpdates = [...$selectedUpdates, update];
$selectedUpdates = [...$selectedUpdates, update.item];
}
}
Expand All @@ -103,7 +103,7 @@
function toggleIgnoreUpdate(update: ficsitcli.Update) {
if($unignoredUpdates.includes(update)) {
SetUpdateIgnore(update.item, update.newVersion);
$selectedUpdates = $selectedUpdates.filter((u) => u !== update);
$selectedUpdates = $selectedUpdates.filter((u) => u !== update.item);
} else {
SetUpdateUnignore(update.item, update.newVersion);
}
Expand All @@ -122,9 +122,9 @@
</header>
<section class="px-4 py-1 space-y-2 flex-auto overflow-y-auto">
{#each updatesToDisplay as update}
<button class="btn p-2 grid grid-cols-12 {$selectedUpdates.includes(update) ? '!outline !outline-2 !outline-primary-500 bg-surface-400-500-token' : ''}" on:click={() => toggleSelected(update)}>
<button class="btn p-2 grid grid-cols-12 {$selectedUpdates.includes(update.item) ? '!outline !outline-2 !outline-primary-500 bg-surface-400-500-token' : ''}" on:click={() => toggleSelected(update)}>
<div>
{#if $selectedUpdates.includes(update)}
{#if $selectedUpdates.includes(update.item)}
<SvgIcon class="h-full w-8 mx-auto" icon={mdiDownload} />
{/if}
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/components/modals/updates/updatesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { writable } from 'svelte/store';
import type { ficsitcli } from '$wailsjs/go/models';

Check warning on line 3 in frontend/src/lib/components/modals/updates/updatesStore.ts

View workflow job for this annotation

GitHub Actions / lint-frontend

'ficsitcli' is defined but never used. Allowed unused vars must match /^_/u

// Because skeleton only ever keeps one modal loaded, we want to store this state between modals
export const selectedUpdates = writable<ficsitcli.Update[]>([]);
export const selectedUpdates = writable<string[]>([]);
export const showIgnored = writable(false);

0 comments on commit fbcd792

Please sign in to comment.