Skip to content

Commit

Permalink
Merge pull request #235 from Suwayomi/main
Browse files Browse the repository at this point in the history
update complex stores to state
  • Loading branch information
Robonau authored Oct 29, 2024
2 parents d3454df + 06869a5 commit c640bc2
Show file tree
Hide file tree
Showing 58 changed files with 1,587 additions and 1,169 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/TriStateSlide.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// Types
import type { CssClasses, SvelteEvent } from '@skeletonlabs/skeleton';
import type { TriState } from '$lib/util';
import type { TriState } from '$lib/util.svelte';
// Base Styles
const cBase = 'inline-block';
Expand Down
16 changes: 8 additions & 8 deletions src/lib/components/lightswitch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
-->

<script lang="ts">
import { Meta } from '$lib/simpleStores';
import { gmState } from '$lib/simpleStores.svelte';
import type { CssClasses } from '@skeletonlabs/skeleton';
let title = 'Toggle light or dark mode.';
Expand Down Expand Up @@ -44,9 +44,9 @@
};
// State
let trackBg = $derived(!$Meta.dark ? bgLight : bgDark);
let thumbBg = $derived(!$Meta.dark ? bgDark : bgLight);
let thumbPosition = $derived(!$Meta.dark ? 'translate-x-[100%]' : '');
let trackBg = $derived(!gmState.value.dark ? bgLight : bgDark);
let thumbBg = $derived(!gmState.value.dark ? bgDark : bgLight);
let thumbPosition = $derived(!gmState.value.dark ? 'translate-x-[100%]' : '');
// Reactive
let classesTrack = $derived(
`cursor-pointer ${cTransition} ${width} ${height} ${ring} ${rounded} ${trackBg} ${className ?? ''}`
Expand All @@ -55,16 +55,16 @@
`aspect-square scale-[0.8] flex justify-center items-center ${cTransition} ${height} ${rounded} ${thumbBg} ${thumbPosition}`
);
let classesIcon = $derived(
`w-[70%] aspect-square ${!$Meta.dark ? fillLight : fillDark}`
`w-[70%] aspect-square ${!gmState.value.dark ? fillLight : fillDark}`
);
</script>

<button
class="lightswitch-track {classesTrack}"
onclick={() => ($Meta.dark = !$Meta.dark)}
onclick={() => (gmState.value.dark = !gmState.value.dark)}
role="switch"
aria-label="Light Switch"
aria-checked={!$Meta.dark}
aria-checked={!gmState.value.dark}
{title}
tabindex="0"
>
Expand All @@ -74,7 +74,7 @@
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
>
<path d={!$Meta.dark ? svgPath.sun : svgPath.moon} />
<path d={!gmState.value.dark ? svgPath.sun : svgPath.moon} />
</svg>
</div>
</button>
11 changes: 5 additions & 6 deletions src/lib/gql/graphqlClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ import type {
updateTrack
} from './Mutations';
import type { ResultOf, VariablesOf } from '$lib/gql/graphql';
import { get } from 'svelte/store';
import { lastFetched } from '../../../src/routes/(app)/browse/extensions/ExtensionsStores';
import { Meta } from '$lib/simpleStores';
import { introspection } from '../../graphql-env';
import { gmState } from '$lib/simpleStores.svelte';
// import type { downloadChanged } from './Subscriptions';

export const client = new Client({
Expand Down Expand Up @@ -752,11 +751,11 @@ function fetchExtensionsUpdater(
) {
if (!data?.fetchExtensions) return;
let filteredExtensions = data.fetchExtensions.extensions;
if (!get(Meta).nsfw)
if (!gmState.value.nsfw)
filteredExtensions = filteredExtensions.filter((e) => !e.isNsfw);
filteredExtensions.forEach((e) => {
cache.writeFragment(ExtensionTypeFragment, e, {
isNsfw: get(Meta).nsfw ? null : false
isNsfw: gmState.value.nsfw ? null : false
});
});
lastFetched.set(new Date());
Expand Down Expand Up @@ -875,7 +874,7 @@ function updateExtentionsList<T extends { pkgName: string }>(
cache.updateQuery(
{
query: getExtensions,
variables: { isNsfw: get(Meta).nsfw ? null : false }
variables: { isNsfw: gmState.value.nsfw ? null : false }
},
(extensionsData) => {
if (!extensionsData) return extensionsData;
Expand All @@ -901,7 +900,7 @@ function updateSourcesList<T extends { pkgName: string }>(
cache.updateQuery(
{
query: getSources,
variables: { isNsfw: get(Meta).nsfw ? null : false }
variables: { isNsfw: gmState.value.nsfw ? null : false }
},
(sourcesData) => {
if (!sourcesData) return sourcesData;
Expand Down
Loading

0 comments on commit c640bc2

Please sign in to comment.