creddy/src/App.svelte

38 lines
1.0 KiB
Svelte
Raw Normal View History

2022-08-14 20:27:41 +00:00
<script>
import { onMount } from 'svelte';
2023-05-01 16:05:46 +00:00
import { listen } from '@tauri-apps/api/event';
2023-04-24 19:05:11 +00:00
import { invoke } from '@tauri-apps/api/tauri';
import { appState, acceptRequest } from './lib/state.js';
2023-04-26 20:05:51 +00:00
import { views, currentView, navigate } from './lib/routing.js';
2023-04-26 20:05:51 +00:00
$views = import.meta.glob('./views/*.svelte', {eager: true});
navigate('Home');
2023-04-26 05:10:14 +00:00
invoke('get_config').then(config => $appState.config = config);
listen('credentials-request', (tauriEvent) => {
2023-04-25 15:49:00 +00:00
$appState.pendingRequests.put(tauriEvent.payload);
});
listen('launch-terminal-request', async (tauriEvent) => {
if ($appState.currentRequest === null) {
let status = await invoke('get_session_status');
if (status === 'locked') {
navigate('Unlock');
}
else if (status === 'empty') {
navigate('EnterCredentials');
}
// else, session is unlocked, so do nothing
// (although we shouldn't even get the event in that case)
}
})
acceptRequest();
2022-08-14 20:27:41 +00:00
</script>
2023-04-24 19:05:11 +00:00
2023-04-26 05:10:14 +00:00
<svelte:component this="{$currentView}" />