Merge pull request #172 from pieterdd/simplify-login
Simplify login screen
This commit is contained in:
2 files changed
+28
-4
No files matched your search
@@ -99,3 +99,28 @@ export async function validateInstance(instance: string): Promise<boolean> {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function mayBeIncompatible(minVersion: string, availableVersion: string) {
|
||||||
|
if (minVersion.valueOf() === availableVersion.valueOf()) return false;
|
||||||
|
|
||||||
|
const versionFormatter = /[\d.]/;
|
||||||
|
if (!minVersion.match(versionFormatter) || !availableVersion.match(availableVersion)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const splitMinVersion = minVersion.split('.');
|
||||||
|
const splitAvailableVersion = availableVersion.split('.');
|
||||||
|
|
||||||
|
if (splitMinVersion.length !== splitAvailableVersion.length) return true;
|
||||||
|
|
||||||
|
for (let i = 0; i < splitMinVersion.length; ++i) {
|
||||||
|
const minVersionDigit = parseInt(splitMinVersion[i]);
|
||||||
|
const availableVersionDigit = parseInt(splitAvailableVersion[i]);
|
||||||
|
|
||||||
|
if (availableVersionDigit === undefined) return true;
|
||||||
|
if (minVersionDigit < availableVersionDigit) return false;
|
||||||
|
if (availableVersionDigit < minVersionDigit) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@@ -3,10 +3,9 @@
|
|||||||
import { setUser } from '$lib/auth.js'
|
import { setUser } from '$lib/auth.js'
|
||||||
import { Note, toast } from 'mono-svelte'
|
import { Note, toast } from 'mono-svelte'
|
||||||
import { DEFAULT_INSTANCE_URL, LINKED_INSTANCE_URL } from '$lib/instance.js'
|
import { DEFAULT_INSTANCE_URL, LINKED_INSTANCE_URL } from '$lib/instance.js'
|
||||||
import { getClient, validateInstance } from '$lib/lemmy.js'
|
import { getClient, mayBeIncompatible, site, validateInstance } from '$lib/lemmy.js'
|
||||||
import { Button, TextInput } from 'mono-svelte'
|
import { Button, TextInput } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
AtSymbol,
|
|
||||||
Icon,
|
Icon,
|
||||||
Identification,
|
Identification,
|
||||||
QuestionMarkCircle,
|
QuestionMarkCircle,
|
||||||
@@ -65,7 +64,7 @@
|
|||||||
<form on:submit|preventDefault={logIn} class="flex flex-col gap-5">
|
<form on:submit|preventDefault={logIn} class="flex flex-col gap-5">
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<h1 class="font-bold text-3xl">Log In</h1>
|
<h1 class="font-bold text-3xl">Log In</h1>
|
||||||
<p>Enter the fediverse</p>
|
{#if $site && mayBeIncompatible(MINIMUM_VERSION, $site.version.replace("v", ""))}
|
||||||
<Note>
|
<Note>
|
||||||
This version of Photon supports instances running
|
This version of Photon supports instances running
|
||||||
<span style="font-family: monospace;">
|
<span style="font-family: monospace;">
|
||||||
@@ -73,13 +72,13 @@
|
|||||||
</span>
|
</span>
|
||||||
or higher.
|
or higher.
|
||||||
</Note>
|
</Note>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row w-full items-center gap-2">
|
<div class="flex flex-row w-full items-center gap-2">
|
||||||
<TextInput
|
<TextInput
|
||||||
id="username"
|
id="username"
|
||||||
bind:value={data.username}
|
bind:value={data.username}
|
||||||
label="Username"
|
label="Username"
|
||||||
placeholder="Example"
|
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in new issue
Block a user