Skip to content

Commit

Permalink
Fix some buttons being wrongly tied to canModify
Browse files Browse the repository at this point in the history
  • Loading branch information
mircearoata committed Feb 14, 2024
1 parent 5f04c00 commit 46d0d8b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions frontend/src/lib/components/left-bar/LeftBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import SvgIcon from '$lib/components/SVGIcon.svelte';
import Select from '$lib/components/Select.svelte';
import { canModify, installs, installsMetadata, modsEnabled, profiles, selectedInstall, selectedProfile } from '$lib/store/ficsitCLIStore';
import { canChangeInstall, canModify, installs, installsMetadata, modsEnabled, profiles, selectedInstall, selectedProfile } from '$lib/store/ficsitCLIStore';
import { error, siteURL } from '$lib/store/generalStore';
import { getModalStore } from '$lib/store/skeletonExtensions';
import { OpenExternal } from '$wailsjs/go/app/app';
Expand Down Expand Up @@ -120,7 +120,7 @@
name="installsCombobox"
class="w-full h-8"
buttonClass="bg-surface-200-700-token px-4 text-sm"
disabled={!$canModify}
disabled={!$canChangeInstall}
itemActiveClass="!bg-surface-300/20"
itemClass="bg-surface-50-900-token"
items={_.orderBy($installs)}
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/lib/components/mod-details/ModDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,7 @@
</div>
{#if (!mod || !('offline' in mod)) && !$offline}
<div class="pt-2" use:popup={changelogMenu}>
<button
class="btn px-4 h-10 text-sm w-full bg-secondary-600"
disabled={!$canModify}
>
<button class="btn px-4 h-10 text-sm w-full bg-secondary-600">
<span>Changelogs</span>
<SvgIcon
class="h-5 w-5"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/components/mods-list/ModsListItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import Tooltip from '$lib/components/Tooltip.svelte';
import { CompatibilityState } from '$lib/generated';
import { addQueuedModAction, queuedMods, removeQueuedModAction } from '$lib/store/actionQueue';
import { favoriteMods, lockfileMods, manifestMods, progress, selectedInstallMetadata } from '$lib/store/ficsitCLIStore';
import { canInstallMods, favoriteMods, lockfileMods, manifestMods, progress, selectedInstallMetadata } from '$lib/store/ficsitCLIStore';
import { error, siteURL } from '$lib/store/generalStore';
import { type PartialMod, search } from '$lib/store/modFiltersStore';
import { getAuthor } from '$lib/utils/getModAuthor';
Expand Down Expand Up @@ -139,7 +139,7 @@
return display;
})();
$: controlButtonsDisabled = isDependency || (compatibility.state === CompatibilityState.Broken && compatibility.source === 'version' && !isInstalled);
$: controlButtonsDisabled = !$canInstallMods || isDependency || (compatibility.state === CompatibilityState.Broken && compatibility.source === 'version' && !isInstalled);
$: installButtonDisabled = controlButtonsDisabled || queuedEnable || inProgress;
$: enableButtonDisabled = controlButtonsDisabled || queuedInstall || inProgress;
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/lib/store/ficsitCLIStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ export const canModify = derived([isGameRunning, progress, isLaunchingGame, inst
return !$isGameRunning && !$progress && !$isLaunchingGame && $installs.length > 0 && $selectedInstallMetadata?.state === ficsitcli.InstallState.VALID;
});

export const canChangeInstall = derived([isGameRunning, progress, isLaunchingGame, installs], ([$isGameRunning, $progress, $isLaunchingGame, $installs]) => {
return !$isGameRunning && !$progress && !$isLaunchingGame && $installs.length > 0;
});

export const canInstallMods = derived([isGameRunning, isLaunchingGame, installs, selectedInstallMetadata], ([$isGameRunning, $isLaunchingGame, $installs, $selectedInstallMetadata]) => {
return !$isGameRunning && !$isLaunchingGame && $installs.length > 0 && $selectedInstallMetadata?.state === ficsitcli.InstallState.VALID;
});

export const updates = writable<ficsitcli.Update[]>([]);
export const unignoredUpdates = derived([updates, ignoredUpdates], ([$updates, $ignoredUpdates]) => $updates.filter((u) => !$ignoredUpdates[u.item]?.includes(u.newVersion)));
export const updateCheckInProgress = writable(false);
Expand Down

0 comments on commit 46d0d8b

Please sign in to comment.