Skip to content

Commit

Permalink
add automatin warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Gcat101 committed Mar 5, 2024
1 parent 1060e07 commit a433764
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/lib/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default {
LOCATOR_REGEX: '([^/@$]*)/([^/@$]*)(@[^/@$]*)?(\\$[^@$]*)?',
DOCS_URL_REGEX: 'github.com/([^/]+/[^/]+)/blob/(.*)',
KJSPKG_README: 'https://github.com/Modern-Modpacks/kjspkg#kjspkg',
DISCORD_URL: 'https://discord.modernmodpacks.site',
// MR_VALID: 'https://api.modrinth.com/v2/project/',
// MR_TARGET: 'https://modrinth.com/mod/'
AUTOMATIN_URL: 'https://tizudev.vercel.app/automatin/api/1025316079226064966/kjspkg',
Expand Down
8 changes: 8 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ export async function initPackageList(): Promise<boolean> {

return true;
}
export async function isAutomatinUp(): Promise<Boolean> {
try {
await fetch(consts.AUTOMATIN_URL);
return true;
} catch (err) {
return false;
}
}

export function filterPkgsByAuthor(authorCheck: string | undefined) : [string, string][] {
return get(packageStatusStore).search.d.filter((p : [string, string]) => {
Expand Down
14 changes: 12 additions & 2 deletions src/routes/s/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
generateInputString,
getNonEmptyOrgsWithPackageCount,
initPackageList,
isAutomatinUp,
parseInputString
} from '$lib/utils';
import { IconCheck, IconClearAll, IconHome, IconLayoutDashboard } from '@tabler/icons-svelte';
Expand Down Expand Up @@ -64,7 +65,7 @@
<title>{$currentSearchStore || 'Search'} - KJSPKG Lookup</title>
</svelte:head>

<div class="flex flex-wrap gap-2">
<div class="flex flex-wrap gap-2 mb-2">
{#if $currentSearchStore}
<button
class="variant-soft-secondary btn w-fit hover:variant-filled-primary"
Expand Down Expand Up @@ -96,8 +97,17 @@
</button>
</div>

{#await isAutomatinUp() then automatinUp}
{#if !automatinUp}
<div class="variant-filled-error rounded p-2 px-3">
<h1 class="h4 font-bold">Our statistics database seems to be down ¯\_(ツ)_/¯</h1>
<p>Download and view counts might be missing. Please report this to <a class="anchor" href={consts.DISCORD_URL}>our Discord server</a>.</p>
</div>
{/if}
{/await}

<div
class="sticky top-[-1px] z-10 justify-between border-surface-600 bg-surface-900 p-2 pt-[calc(1rem_+_1px)] backdrop-blur rounded-bl-container-token rounded-br-container-token md:flex"
class="sticky top-[-1px] z-10 justify-between border-surface-600 bg-surface-900 p-2 backdrop-blur rounded-bl-container-token rounded-br-container-token md:flex"
bind:this={optionsHeader}
>
<h1 class="h3">
Expand Down

0 comments on commit a433764

Please sign in to comment.