fix circular imports from routing
This commit is contained in:
parent
35271049dd
commit
12d9d733a5
@ -3,19 +3,17 @@ 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';
|
||||
import { views, currentView, navigate } from './lib/routing.js';
|
||||
|
||||
|
||||
$views = import.meta.glob('./views/*.svelte', {eager: true});
|
||||
navigate('Home');
|
||||
|
||||
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>
|
||||
|
||||
|
||||
|
@ -1,14 +1,10 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { writable, get } from 'svelte/store';
|
||||
|
||||
|
||||
const VIEWS = import.meta.glob('../views/*.svelte', {eager: true});
|
||||
export let views = writable();
|
||||
export let currentView = writable();
|
||||
|
||||
export function navigate(viewName) {
|
||||
let view = VIEWS[`../views/${viewName}.svelte`].default;
|
||||
currentView.set(view);
|
||||
}
|
||||
|
||||
export function getView(viewName) {
|
||||
return VIEWS[`../views/${viewName}.svelte`].default;
|
||||
let v = get(views)[`./views/${viewName}.svelte`].default;
|
||||
currentView.set(v)
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import { navigate, currentView } from '../lib/routing.js';
|
||||
import { navigate } from '../lib/routing.js';
|
||||
|
||||
export let target;
|
||||
export let hotkey = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user