smoother login flow
This commit is contained in:
parent
350b01800a
commit
3ce3a177d2
2 changed files with 6 additions and 3 deletions
|
@ -3,7 +3,7 @@
|
|||
import { fade } from 'svelte/transition';
|
||||
import { fetchEntries, formatter } from '../util';
|
||||
|
||||
let entriesPromise = $state(fetchEntries());
|
||||
let entriesPromise = $state(fetchEntries(true));
|
||||
|
||||
let interval: Parameters<typeof clearInterval>[0] = undefined;
|
||||
|
||||
|
@ -76,7 +76,7 @@
|
|||
<div class="py-2 text-xs text-gray-400/50">{entry.id}</div>
|
||||
<a
|
||||
href={entry.href}
|
||||
class="line-clamp-1 block px-2 py-1 text-nowrap text-ellipsis text-gray-200 capitalize underline decoration-transparent decoration-1 transition-colors hover:decoration-pink-600"
|
||||
class="line-clamp-1 block px-2 py-1 text-nowrap text-ellipsis text-gray-300 capitalize underline decoration-transparent decoration-1 transition-colors hover:decoration-pink-600"
|
||||
target="_blank"
|
||||
title={entry.name}
|
||||
referrerpolicy="no-referrer">{entry.name}</a
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { userstate } from './shared.svelte';
|
||||
import type { SelectEntry } from './server/pt-api';
|
||||
|
||||
export async function fetchEntries(): Promise<SelectEntry[]> {
|
||||
export async function fetchEntries(retry: boolean = false): Promise<SelectEntry[]> {
|
||||
try {
|
||||
const response = await fetch('/api/entries', {
|
||||
method: 'GET',
|
||||
|
@ -12,6 +12,9 @@ export async function fetchEntries(): Promise<SelectEntry[]> {
|
|||
if (response.status === 401) {
|
||||
userstate.checkIsLoggedIn();
|
||||
}
|
||||
if(retry) {
|
||||
return fetchEntries(false);
|
||||
}
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue