clean code
This commit is contained in:
parent
35370a6482
commit
377a55574d
@ -4,9 +4,9 @@ import { redirect } from '@sveltejs/kit';
|
|||||||
|
|
||||||
export const load = async ({parent}) => {
|
export const load = async ({parent}) => {
|
||||||
|
|
||||||
const data = await parent();
|
const { user } = await parent();
|
||||||
|
|
||||||
if (data?.user) {
|
if (user) {
|
||||||
redirect(303, '/home');
|
redirect(303, '/home');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,9 @@
|
|||||||
import { userRegion, getCache, setCache } from '$lib/store';
|
import { getCache, setCache } from '$lib/store';
|
||||||
import defaultAvatar from '$lib/images/senator/default-avatar.png';
|
import defaultAvatar from '$lib/images/senator/default-avatar.png';
|
||||||
import { getPartyForPoliticians } from '$lib/utils';
|
import { getPartyForPoliticians } from '$lib/utils';
|
||||||
import { redirect } from '@sveltejs/kit';
|
import { redirect } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
|
||||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
|
||||||
|
|
||||||
let apiURL;
|
|
||||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let images = {};
|
let images = {};
|
||||||
// Function to load images only when they are viewed
|
// Function to load images only when they are viewed
|
||||||
async function loadImages() {
|
async function loadImages() {
|
||||||
@ -30,22 +23,11 @@ async function loadImages() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
userRegion.subscribe(value => {
|
|
||||||
|
|
||||||
if (usRegion.includes(value)) {
|
|
||||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
|
||||||
} else {
|
|
||||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
export const load = async ({ parent}) => {
|
export const load = async ({ parent}) => {
|
||||||
|
|
||||||
const data = await parent();
|
const { user, apiKey, apiURL } = await parent();
|
||||||
|
|
||||||
if (!data?.user) {
|
if (!user) {
|
||||||
redirect(303, '/');
|
redirect(303, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user