Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
codelastnight committed Aug 3, 2023
1 parent 4e48573 commit f6e56a5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
8 changes: 5 additions & 3 deletions src/renderer/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ function startServerConnection() {
}
onMount(() => {
startServerConnection();
async function checkSettings() {
const getpath = await eAPI.dataGet(type);
Expand All @@ -62,9 +60,13 @@ onMount(() => {
}
const getSettings = await eAPI.dataGet('settings');
if (!!getSettings && getSettings.type === 'ok') {
if ('autoplay' in getSettings.data) settings.set(getSettings.data);
if ('frogMode' in getSettings.data) settings.set(getSettings.data);
if ('frogMode' in getSettings.data) console.log('got settings');
}
}
startServerConnection();
checkSettings();
});
Expand Down
14 changes: 6 additions & 8 deletions src/renderer/src/Options.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,10 @@ onMount(() => {
checkSettings();
});
onDestroy(() => {
eAPI.dataSet({
key: 'options',
value: { mute: mute, volume: slider }
});
setSettings();
});
eAPI.handleSaveSetting((_) => {
eAPI.dataSet({
key: 'options',
value: { mute: mute, volume: slider }
});
setSettings();
eAPI.handleClosed();
});
function togglemute() {
Expand All @@ -50,6 +44,9 @@ function togglemute() {
mute = true;
Howler.volume(0);
}
setSettings();
}
function setSettings() {
eAPI.dataSet({ key: 'options', value: { mute: mute, volume: slider } });
}
$: {
Expand Down Expand Up @@ -79,6 +76,7 @@ $: {
max="100"
class="slider"
bind:value={slider}
on:change={setSettings}
id="myRange"
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/src/Titlebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ onMount(() => {
</button>
<button
type="button"
class="hover:bg-gray-700"
class="hover:bg-red-700"
on:click={() => window.api.winClose()}
>
<Fa icon={faClose} />
Expand All @@ -99,7 +99,7 @@ onMount(() => {
<style lang="postcss">
header {
-webkit-app-region: drag;
@apply flex w-full items-center justify-between px-1 py-0.5;
@apply flex w-full items-center justify-between px-2 py-0.5;
@apply h-10;
}
button {
Expand Down
18 changes: 14 additions & 4 deletions src/renderer/src/components/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@ import { settings } from '../store';
import Switch from './Switch.svelte';
import { faWarning } from '@fortawesome/free-solid-svg-icons';
import Fa from 'svelte-fa';
import { onDestroy } from 'svelte';
import { onDestroy, onMount } from 'svelte';
let didMount = false;
onDestroy(() => {
setSettings($settings);
didMount = false;
});
onMount(() => {
didMount = true;
});
$: setSettings($settings);
function setSettings(data) {
if (!didMount) return;
console.log('set');
window.api.dataSet({
key: 'settings',
value: $settings
value: data
});
});
}
</script>

<Dialog bind:isOpen title="options">
Expand Down

0 comments on commit f6e56a5

Please sign in to comment.