Skip to content

Commit

Permalink
Merge pull request #238 from Suwayomi/main
Browse files Browse the repository at this point in the history
fix state and pre load init page data
  • Loading branch information
Robonau authored Nov 9, 2024
2 parents a88329c + ed6e17a commit c519ecf
Show file tree
Hide file tree
Showing 40 changed files with 803 additions and 368 deletions.
14 changes: 7 additions & 7 deletions src/lib/components/lightswitch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
};
// State
let trackBg = $derived(!gmState.dark ? bgLight : bgDark);
let thumbBg = $derived(!gmState.dark ? bgDark : bgLight);
let thumbPosition = $derived(!gmState.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 ${!gmState.dark ? fillLight : fillDark}`
`w-[70%] aspect-square ${!gmState.value.dark ? fillLight : fillDark}`
);
</script>

<button
class="lightswitch-track {classesTrack}"
onclick={() => (gmState.dark = !gmState.dark)}
onclick={() => (gmState.value.dark = !gmState.value.dark)}
role="switch"
aria-label="Light Switch"
aria-checked={!gmState.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={!gmState.dark ? svgPath.sun : svgPath.moon} />
<path d={!gmState.value.dark ? svgPath.sun : svgPath.moon} />
</svg>
</div>
</button>
8 changes: 4 additions & 4 deletions src/lib/gql/graphqlClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -751,11 +751,11 @@ function fetchExtensionsUpdater(
) {
if (!data?.fetchExtensions) return;
let filteredExtensions = data.fetchExtensions.extensions;
if (!gmState.nsfw)
if (!gmState.value.nsfw)
filteredExtensions = filteredExtensions.filter((e) => !e.isNsfw);
filteredExtensions.forEach((e) => {
cache.writeFragment(ExtensionTypeFragment, e, {
isNsfw: gmState.nsfw ? null : false
isNsfw: gmState.value.nsfw ? null : false
});
});
lastFetched.set(new Date());
Expand Down Expand Up @@ -874,7 +874,7 @@ function updateExtentionsList<T extends { pkgName: string }>(
cache.updateQuery(
{
query: getExtensions,
variables: { isNsfw: gmState.nsfw ? null : false }
variables: { isNsfw: gmState.value.nsfw ? null : false }
},
(extensionsData) => {
if (!extensionsData) return extensionsData;
Expand All @@ -900,7 +900,7 @@ function updateSourcesList<T extends { pkgName: string }>(
cache.updateQuery(
{
query: getSources,
variables: { isNsfw: gmState.nsfw ? null : false }
variables: { isNsfw: gmState.value.nsfw ? null : false }
},
(sourcesData) => {
if (!sourcesData) return sourcesData;
Expand Down
Loading

0 comments on commit c519ecf

Please sign in to comment.