Skip to content

Commit

Permalink
Changes that are stuck in #256
Browse files Browse the repository at this point in the history
  • Loading branch information
maiertech committed Jul 19, 2024
1 parent 2e8bcce commit 82231c4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions unime/src/routes/prompt/accept-connection/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import LL from '$i18n/i18n-svelte';
import { fade } from 'svelte/transition';
import type { ValidationResult } from '@bindings/user_prompt/ValidationResult';
import type { CurrentUserPrompt } from '@bindings/user_prompt/CurrentUserPrompt';
import { createPopover, melt } from '@melt-ui/svelte';
import Button from '$lib/components/atoms/Button.svelte';
Expand All @@ -29,15 +29,16 @@
let loading = false;
let client_name = $state.current_user_prompt.client_name;
// TypeScript does not know that the `current_user_prompt` is of type `accept-connection`.
// Extract the type from `CurrentUserPrompt`.
type IsAcceptConnectionPrompt<T> = T extends { type: 'accept-connection' } ? T : never;
type AcceptConnectionPrompt = IsAcceptConnectionPrompt<CurrentUserPrompt>;
const previously_connected = $state.current_user_prompt.previously_connected;
const { client_name, domain_validation, logo_uri, previously_connected, redirect_uri } =
$state.current_user_prompt as AcceptConnectionPrompt;
const domain_validation: ValidationResult = $state.current_user_prompt.domain_validation;
const hostname = new URL($state.current_user_prompt.redirect_uri).hostname;
const imageId = $state.current_user_prompt?.logo_uri ? hash($state.current_user_prompt?.logo_uri) : '_';
$: ({ hostname } = new URL(redirect_uri));
$: imageId = logo_uri ? hash(logo_uri) : '_';
// When an error is received, cancel the flow and redirect to the "me" page
error.subscribe((err) => {
Expand All @@ -57,7 +58,7 @@
<TopNavBar title={$LL.SCAN.CONNECTION_REQUEST.NAVBAR_TITLE()} on:back={() => history.back()} disabled={loading} />

<div class="flex grow flex-col items-center justify-center space-y-6 p-4">
{#if $state.current_user_prompt.logo_uri}
{#if logo_uri}
<div
class="flex h-[75px] w-[75px] items-center justify-center overflow-hidden rounded-3xl bg-white p-2 dark:bg-silver"
>
Expand Down

0 comments on commit 82231c4

Please sign in to comment.