Skip to content

Commit

Permalink
Fix showing/hiding animations with persistent settings
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoTheThird committed Mar 21, 2022
1 parent 862b7fa commit e5e8bb4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
9 changes: 9 additions & 0 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//Store imports
import {
animationType,
animationHidden,
footerData,
osSelectOptions,
installConfigData,
Expand Down Expand Up @@ -36,6 +37,14 @@
import routes from "./routes.mjs";
//Messages
//Settings messages
ipcRenderer
.invoke("getSettingsValue", "never.udev")
.then(show => animationHidden.set(!show));
ipcRenderer.on("settings:animations", (e, show) =>
animationHidden.set(!show)
);
//Routing messages
ipcRenderer.on("user:write:working", (e, animation) => {
animationType.set(animation);
Expand Down
4 changes: 1 addition & 3 deletions src/lib/menuManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,8 @@ class MenuManager {
checked: settings.get("animations"),
type: "checkbox",
click: () => {
if (settings.get("animations")) {
window.send("animations:hide");
}
settings.set("animations", !settings.get("animations"));
window.send("settings:animations", settings.get("animations"));
}
},
{
Expand Down
1 change: 1 addition & 0 deletions src/stores.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { writable } from "svelte/store";

//working view
export const animationType = writable("");
export const animationHidden = writable(false);

//wait for device view
export const deviceSelectOptions = writable([]);
Expand Down
12 changes: 7 additions & 5 deletions src/ui/partials/Animation.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<script>
import { onMount } from "svelte";
import { animationType } from "../../stores.mjs";
import { animationType, animationHidden } from "../../stores.mjs";
import { tsParticles } from "tsparticles";
import CircuitBoard from "./CircuitBoard.svelte";
import Squares from "./Squares.svelte";
onMount(updateAnimations);
animationType.subscribe(updateAnimations);
animationHidden.subscribe(updateAnimations);
function updateAnimations() {
if (
$animationType === "particles" &&
!$animationHidden &&
document.getElementById("tsparticles")
) {
document.getElementById("tsparticles").style = "display: inherit";
Expand Down Expand Up @@ -59,20 +61,20 @@
-->
<div id="tsparticles" class="animation" />

{#if $animationType === "circuit"}
{#if !$animationHidden && $animationType === "circuit"}
<div class="animation">
<CircuitBoard />
</div>
{/if}
{#if $animationType === "squares"}
{#if !$animationHidden && $animationType === "squares"}
<div class="animation">
<Squares />
</div>
{/if}
{#if $animationType === "download"}
{#if !$animationHidden && $animationType === "download"}
<div class="download-animation animation" />
{/if}
{#if $animationType === "push"}
{#if !$animationHidden && $animationType === "push"}
<div class="push-animation animation" />
{/if}

Expand Down

0 comments on commit e5e8bb4

Please sign in to comment.