Weired fucking fix for the userstore data not being instantly loaded....
ref #1
This commit is contained in:
parent
4f5b7f38fb
commit
cd3508dcb6
|
@ -1,8 +1,11 @@
|
|||
<script>
|
||||
import { page } from '$app/stores';
|
||||
import Apiclient from '$lib/Apiclient';
|
||||
import UserStore from '$lib/UserStore';
|
||||
import { onDestroy } from 'svelte';
|
||||
|
||||
let shortcode = $page.query.get('shortcode');
|
||||
|
||||
$: urlDetails = {
|
||||
shortcode: 'Loading...',
|
||||
url: 'Loading...',
|
||||
|
@ -10,13 +13,20 @@
|
|||
visits: 'Loading...'
|
||||
};
|
||||
$: urlVisists = [];
|
||||
let visitQuery;
|
||||
|
||||
Apiclient.getUrlDetails(shortcode).then((res) => {
|
||||
urlDetails = res;
|
||||
});
|
||||
let visitQuery = Apiclient.getUrlVisits(shortcode).then((res) => {
|
||||
urlVisists = res;
|
||||
const unsubscribe = UserStore.subscribe((value) => {
|
||||
if (value.isLoggedIn) {
|
||||
Apiclient.getUrlDetails(shortcode).then((res) => {
|
||||
urlDetails = res;
|
||||
});
|
||||
visitQuery = Apiclient.getUrlVisits(shortcode).then((res) => {
|
||||
urlVisists = res;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onDestroy(unsubscribe);
|
||||
</script>
|
||||
|
||||
<h2 class="text-3xl font-bold text-gray-800 dark:text-gray-100 pb-6">Details: {shortcode}</h2>
|
||||
|
|
Loading…
Reference in New Issue