Skip to content

Commit

Permalink
added cmd+r refresh for managed data refreshes
Browse files Browse the repository at this point in the history
  • Loading branch information
matryer committed Mar 8, 2021
1 parent c70c0c6 commit 702fd16
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
9 changes: 4 additions & 5 deletions app/frontend/src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script>
import { onMount } from 'svelte'
import { Router } from 'svelte-hash-router'
import { Events } from '@wails/runtime'
import {
Expand All @@ -17,6 +16,7 @@
import Error from './elements/Error.svelte'
import { globalWaiter, wait } from './waiters.svelte'
import KeyboardShortcuts from './elements/KeyboardShortcuts.svelte'
import { sigRefresh } from './signals.svelte'
let err
Expand All @@ -32,8 +32,8 @@
location.hash = `/plugin-details/${params.path}`
})
onMount(() => {
$: if ($sigRefresh) {
console.info("App: refreshing")
const done = wait()
const done2 = wait()
refreshCategories(categories)
Expand All @@ -43,8 +43,7 @@
refreshInstalledPlugins(installedPlugins)
.catch(e => err = e)
.finally(() => done2())
})
}
function openSponsorPage() {
openURL('https://github.com/sponsors/matryer')
Expand Down
6 changes: 5 additions & 1 deletion app/frontend/src/InstalledPluginView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@
import Switch from './elements/Switch.svelte'
import Spinner from './elements/Spinner.svelte'
import Duration from './elements/Duration.svelte'
import { sigRefresh } from './signals.svelte'
let err
$: loadPluginMetadata($params._)
let installedPlugin = null
let refreshInterval
let variableValues = null
$: if ($sigRefresh && $params._) {
loadPluginMetadata($params._)
}
function loadPluginMetadata(installedPluginPath) {
if (!installedPluginPath) { return }
const done1 = wait()
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/PluginView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { params } from 'svelte-hash-router'
import { installedPlugins } from './pagedata.svelte'
import { getPlugin, openURL, installPlugin, refreshInstalledPlugins } from './rpc.svelte'
import { getPlugin, installPlugin, refreshInstalledPlugins } from './rpc.svelte'
import { wait } from './waiters.svelte'
import Error from './elements/Error.svelte'
import Button from './elements/Button.svelte'
Expand Down
15 changes: 5 additions & 10 deletions app/frontend/src/elements/KeyboardShortcuts.svelte
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
<script>
import { categories, installedPlugins } from '../pagedata.svelte'
import { refreshCategories, refreshInstalledPlugins } from '../rpc.svelte'
import { wait } from '../waiters.svelte'
import { fireSigRefresh } from '../signals.svelte'
function handleKeydown(e) {
console.info(e)
if (e.key === 'r' && e.metaKey && !e.shiftKey) {
e.preventDefault()
const done1 = wait()
refreshCategories(categories)
.finally(() => done1())
const done2 = wait()
refreshInstalledPlugins(installedPlugins)
.finally(() => done2())
fireSigRefresh()
}
}
</script>
<svelte:window
on:keydown={handleKeydown}
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/pagedata.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script context='module'>
import { writable } from "svelte/store"
import { writable } from 'svelte/store'
export const categories = writable(null)
export const installedPlugins = writable(null)
Expand Down
11 changes: 11 additions & 0 deletions app/frontend/src/signals.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script context='module'>
import { writable } from "svelte/store"
export const sigRefresh = writable(new Date())
export function fireSigRefresh() {
sigRefresh.set(new Date())
}
</script>

0 comments on commit 702fd16

Please sign in to comment.