Radish alpha
r
rad:z4D5UCArafTzTQpDZNQRuqswh3ury
Radicle desktop app
Radicle
Git
Check every second for valid authentication when on `/authenticationError`
Open did:key:z6MkkfM3...sVz5 opened 1 year ago
1 file changed +37 -0 4d81bf53 40264d7f
modified src/views/AuthenticationError.svelte
@@ -1,8 +1,45 @@
<script lang="ts">
+
  import { onMount } from "svelte";
+

+
  import { invoke } from "@tauri-apps/api/core";
+

+
  import * as mutexExecutor from "@app/lib/mutexExecutor";
+
  import * as router from "@app/lib/router";
  import Icon from "@app/components/Icon.svelte";

  export let error: string;
  export let hint: string | undefined = undefined;
+

+
  let interval: undefined | ReturnType<typeof setInterval> = undefined;
+

+
  onMount(async () => {
+
    try {
+
      const loadExecutor = mutexExecutor.create();
+
      const checkAuth = new Promise<void>(resolve => {
+
        interval = setInterval(() => {
+
          loadExecutor.run(async () => {
+
            await invoke("authenticate");
+
            resolve();
+
          });
+
        }, 1_000);
+
      });
+
      await checkAuth;
+

+
      void router.loadFromLocation();
+
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
+
    } catch (e: any) {
+
      void router.push({
+
        resource: "authenticationError",
+
        params: {
+
          error: e.err,
+
          hint: e.hint,
+
        },
+
      });
+
    } finally {
+
      clearInterval(interval);
+
      void router.push({ resource: "home" });
+
    }
+
  });
</script>

<style>