mirror of
https://github.com/revanced/revanced-website.git
synced 2025-04-30 06:34:35 +02:00
typescript lol
This commit is contained in:
parent
10c3dad90f
commit
ec2e8adfec
@ -1,5 +1,6 @@
|
||||
import { navigating, page } from '$app/stores';
|
||||
import { derived, type Readable } from 'svelte/store';
|
||||
import { derived } from 'svelte/store';
|
||||
import type { Readable } from 'svelte/store';
|
||||
|
||||
export interface RouterEvent {
|
||||
// URL of the current page or the page we are navigating to.
|
||||
@ -15,17 +16,17 @@ function makeStore(): Readable<RouterEvent> {
|
||||
// `location` does not exist on the server.
|
||||
// Return a derived store based on `page` for SSR.
|
||||
// Server will never navigate so this is fine.
|
||||
return derived(page, $page => {
|
||||
return derived(page, ($page) => {
|
||||
return { navigating: false, target_url: $page.url };
|
||||
});
|
||||
} else {
|
||||
// On client.
|
||||
let current = new URL(location);
|
||||
let current = new URL(location as any);
|
||||
|
||||
// Return store that responds to navigation events.
|
||||
// The `navigating` store immediately "pushes" `null`.
|
||||
// This in turn causes this derived store to immediately "push" the current URL.
|
||||
return derived(navigating, $nav => {
|
||||
return derived(navigating, ($nav) => {
|
||||
let navigating = false;
|
||||
// $nav is null when navigation finishes.
|
||||
if ($nav != null && $nav.to != null) {
|
||||
|
@ -5,10 +5,11 @@
|
||||
|
||||
import next from '$lib/assets/icons/next.svg';
|
||||
import previous from '$lib/assets/icons/previous.svg';
|
||||
import type { APILogo } from '$lib/types';
|
||||
|
||||
export let name = '';
|
||||
export let selected: Array<string>;
|
||||
export let variants;
|
||||
export let selected: string[];
|
||||
export let variants: APILogo[];
|
||||
export let clicked = false;
|
||||
export let hideDetails = false;
|
||||
|
||||
@ -17,7 +18,7 @@
|
||||
|
||||
let i = 0;
|
||||
$: current = variants[i];
|
||||
let interval = null;
|
||||
let interval = 0;
|
||||
onMount(() => {
|
||||
if (!hasVariants) {
|
||||
return;
|
||||
@ -28,12 +29,12 @@
|
||||
} else {
|
||||
i += 1;
|
||||
}
|
||||
}, 2500);
|
||||
}, 2500) as unknown as number; // stfu typescript
|
||||
|
||||
return () => clearInterval(interval);
|
||||
});
|
||||
|
||||
function select_logo(id) {
|
||||
function select_logo(id: string) {
|
||||
clicked = !clicked;
|
||||
if (selected.includes(id)) {
|
||||
selected = selected.filter((e) => e !== id);
|
||||
|
19
src/lib/types.ts
Normal file
19
src/lib/types.ts
Normal file
@ -0,0 +1,19 @@
|
||||
export interface APILogo {
|
||||
id: string;
|
||||
gdrive_direct_url: string;
|
||||
}
|
||||
|
||||
export interface LogoAPIResponse {
|
||||
[key: string]: {
|
||||
logos: APILogo[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface Logo {
|
||||
name: string;
|
||||
variants: APILogo[];
|
||||
}
|
||||
|
||||
// export interface Selected {
|
||||
|
||||
// }
|
@ -1,7 +1,7 @@
|
||||
import { dev } from "$app/environment";
|
||||
import { dev } from '$app/environment';
|
||||
|
||||
// console.log, but only if in dev environment.
|
||||
export function dev_log(part: string, ...args) {
|
||||
export function dev_log(part: string, ...args: string[]) {
|
||||
if (dev) {
|
||||
console.log(`[${part}]:`, ...args);
|
||||
}
|
||||
|
@ -2,14 +2,19 @@
|
||||
import { onMount } from 'svelte';
|
||||
import { fly } from 'svelte/transition';
|
||||
import { expoOut } from 'svelte/easing';
|
||||
import type { Logo, LogoAPIResponse } from '$lib/types';
|
||||
|
||||
import Modal from '$lib/components/atoms/Dialogue.svelte';
|
||||
import LogoOption from '$lib/components/atoms/LogoOption.svelte';
|
||||
import Button from '$lib/components/atoms/Button.svelte';
|
||||
|
||||
interface Selected {
|
||||
[key: string] : string[];
|
||||
}
|
||||
|
||||
let modalOpen = false;
|
||||
let selected = {};
|
||||
function calc_ui_selected_count(v) {
|
||||
let selected: Selected = {};
|
||||
function calc_ui_selected_count(v: Selected) {
|
||||
let n = 0;
|
||||
for (const item of Object.values(v)) {
|
||||
if (item.length != 0) {
|
||||
@ -22,15 +27,15 @@
|
||||
|
||||
// afn please don't do this lol this is shitty code
|
||||
$: ui_selected_count = calc_ui_selected_count(selected);
|
||||
let logos = [];
|
||||
let logo_ids = [];
|
||||
let logos: Logo[] = [];
|
||||
let logo_ids: string[] = [];
|
||||
let transitionDirection = 5;
|
||||
let logoAmount = 4;
|
||||
let currentPage = 0;
|
||||
let logoPages = 1;
|
||||
let min = 0;
|
||||
let max = logoAmount;
|
||||
let token: string = '';
|
||||
let token = '';
|
||||
let submit = false;
|
||||
$: finalPage = currentPage >= logoPages;
|
||||
|
||||
@ -59,7 +64,7 @@
|
||||
window['submit_poll'] = submitBallot;
|
||||
|
||||
const response = await fetch('https://poll.revanced.app/logos');
|
||||
const json = await response.json();
|
||||
const json: LogoAPIResponse = await response.json();
|
||||
|
||||
for (const name of Object.keys(json)) {
|
||||
// lol the performance
|
||||
|
Loading…
x
Reference in New Issue
Block a user