fix redirect_after_login

master v0.1.0-preview.8
Niko PLP 4 months ago
parent e4b96d96e5
commit b4ea570146
  1. 23
      ng-app/src/lib/FullLayout.svelte
  2. 9
      ng-app/src/lib/MobileBottomBarItem.svelte
  3. 1
      ng-app/src/routes/User.svelte
  4. 11
      ng-app/src/routes/WalletLogin.svelte
  5. 3
      ng-app/src/store.ts

@ -35,6 +35,9 @@
import Message from "./components/Message.svelte";
import Signature from "./popups/Signature.svelte";
import {
get,
} from "svelte/store";
// @ts-ignore
import { t } from "svelte-i18n";
@ -47,7 +50,7 @@
in_private_store, show_doc_popup, cur_doc_popup, open_doc_popup } from "../tab";
import {
active_session, redirect_after_login, toasts, check_has_camera, toast_error,
reset_toasts,
reset_toasts, redirect_if_wallet_is, active_wallet,
display_error, openModalCreate
} from "../store";
import ZeraIcon from "./icons/ZeraIcon.svelte";
@ -368,6 +371,7 @@
let shareMenu;
let toolsMenu;
let unsub;
let unsub2;
async function scrollToTop() {
await tick();
if (top) top.scrollIntoView();
@ -398,19 +402,22 @@
reset_toasts();
}
});
unsub2 = active_session.subscribe((as) => {
if(!as) {
$redirect_after_login = $location;
$redirect_if_wallet_is = get(active_wallet)?.id
push("#/");
}
})
});
onDestroy(() => {
if (unsub) unsub();
if (unsub2) unsub2();
});
active_session.subscribe((as) => { if(!as) {
//console.log($location);
if ($location!="/user") {
$redirect_after_login = $location;
}
push("#/");
} })
$: activeUrl = "#" + $location;

@ -13,6 +13,7 @@
import { getContext } from "svelte";
import type { ComponentType } from "svelte";
import { Icon } from "svelte-heros-v2";
import { onMount, onDestroy, tick } from "svelte";
export let href: string = "";
export let icon: ComponentType;
@ -22,9 +23,15 @@
};
let sidebarUrl = "";
activeUrlStore.subscribe((value) => {
let unsub;
onMount( () => {
unsub = activeUrlStore.subscribe((value) => {
sidebarUrl = value;
});
});
onDestroy( () => {
if (unsub) unsub();
});
$: active = sidebarUrl ? href === sidebarUrl : false;
</script>

@ -88,6 +88,7 @@
});
async function logout() {
await close_active_wallet();
}

@ -34,7 +34,8 @@
has_wallets,
display_error,
wallet_from_import,
redirect_after_login
redirect_after_login,
redirect_if_wallet_is
} from "../store";
import { CheckBadge, ExclamationTriangle, QrCode } from "svelte-heros-v2";
@ -110,10 +111,18 @@
async function loggedin() {
step = "loggedin";
if ($redirect_after_login) {
if (!$redirect_if_wallet_is || $redirect_if_wallet_is == $active_wallet?.id) {
let redir=$redirect_after_login;
$redirect_after_login=undefined;
$redirect_if_wallet_is=undefined;
push("#"+redir);
} else {
$redirect_after_login=undefined;
$redirect_if_wallet_is=undefined;
push("#/");
}
} else {
push("#/");
}

@ -162,6 +162,7 @@ export const connections: Writable<Record<string, any>> = writable({});
export const active_session = writable(undefined);
export const redirect_after_login = writable(undefined);
export const redirect_if_wallet_is = writable(undefined);
export const connection_status: Writable<"disconnected" | "connected" | "connecting" | "starting"> = writable("starting");
@ -285,6 +286,8 @@ export const set_active_session = function(session) {
export { writable, readonly, derived };
export const close_active_wallet = async function() {
redirect_after_login.set(undefined);
redirect_if_wallet_is.set(undefined);
if (next_reconnect) {
clearTimeout(next_reconnect);
next_reconnect = null;

Loading…
Cancel
Save