<script>
import { emit, listen } from '@tauri-apps/api/event';
import { invoke } from '@tauri-apps/api/tauri';

import { appState } from './lib/state.js';
import { navigate, currentView } from './lib/routing.js';


invoke('get_config').then(config => $appState.config = config);

listen('credentials-request', (tauriEvent) => {
    $appState.pendingRequests.put(tauriEvent.payload);
});

// can't set this in routing.js directly for some reason
if (!$currentView) {
    navigate('Home');
}
</script>


<svelte:component this="{$currentView}" />
