bug fixes

This commit is contained in:
sairaj mote 2022-11-19 20:12:18 +05:30
parent 1e9c414bad
commit b5fb91bcfd

View File

@ -1753,47 +1753,51 @@
params: {}, params: {},
openedPages: new Set(), openedPages: new Set(),
} }
const generalPages = ['sign_up', 'sign_in', 'loading', 'landing']
async function routeTo(targetPage, options = {}) { async function routeTo(targetPage, options = {}) {
const { firstLoad, hashChange } = options const { firstLoad } = options
let pageId let pageId
let subPageId1 let subPageId1
let subPageId2
let params = {}
let searchParams let searchParams
let params
if (targetPage === '') { if (targetPage === '') {
try { try {
if (floDapps.user.id) if (floDapps.user.id)
pageId = 'chat_page' pageId = 'chat_page'
} catch (e) { } catch (e) {
pageId = 'sign_in' pageId = 'landing'
} }
} else { } else {
if (targetPage.includes('/')) { if (targetPage.includes('/')) {
if (targetPage.includes('?')) { if (targetPage.includes('?')) {
const splitAddress = targetPage.split('?') const splitAddress = targetPage.split('?')
searchParams = splitAddress.pop(); searchParams = splitAddress.pop();
[, pageId, subPageId1, subPageId2] = splitAddress.pop().split('/') [, pageId, subPageId1] = splitAddress.pop().split('/')
} else { } else {
[, pageId, subPageId1, subPageId2] = targetPage.split('/') [, pageId, subPageId1] = targetPage.split('/')
} }
} else { } else {
pageId = targetPage pageId = targetPage
} }
} }
console.log(pageId, subPageId1, subPageId2)
if (!document.querySelector(`#${pageId}`)?.classList.contains('inner-page')) return if (!document.querySelector(`#${pageId}`)?.classList.contains('inner-page')) return
try { try {
if (floDapps.user.id && (['sign_up', 'sign_in', 'loading', 'landing'].includes(pageId))) { if (floDapps.user.id && (generalPages.includes(pageId))) {
history.replaceState(null, null, '#/chat_page'); history.replaceState(null, null, '#/chat_page');
pageId = 'chat_page' pageId = 'chat_page'
} }
} catch (e) { } catch (e) {
if (!(['sign_up', 'sign_in', 'loading', 'landing'].includes(pageId))) return if (!(generalPages.includes(pageId))) return
} }
appState.currentPage = pageId
if (searchParams) { if (searchParams) {
const urlSearchParams = new URLSearchParams('?' + searchParams); const urlSearchParams = new URLSearchParams('?' + searchParams);
params = Object.fromEntries(urlSearchParams.entries()); params = Object.fromEntries(urlSearchParams.entries());
} }
if (params)
appState.params = params
switch (pageId) { switch (pageId) {
case 'sign_in': case 'sign_in':
setTimeout(() => { setTimeout(() => {
@ -2285,8 +2289,8 @@
} }
function getSignedIn(passwordType) { function getSignedIn(passwordType) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
routeTo('landing') routeTo(window.location.hash)
try { if (floGlobals.loaded) {
getPromptInput('Enter password', '', { getPromptInput('Enter password', '', {
isPassword: true, isPassword: true,
}).then(password => { }).then(password => {
@ -2294,7 +2298,7 @@
resolve(password) resolve(password)
} }
}) })
} catch (err) { } else {
if (passwordType === 'PIN/Password') { if (passwordType === 'PIN/Password') {
floGlobals.isPrivKeySecured = true; floGlobals.isPrivKeySecured = true;
getRef('private_key_field').removeAttribute('data-private-key'); getRef('private_key_field').removeAttribute('data-private-key');
@ -2308,9 +2312,7 @@
getRef('private_key_field').customValidation = floCrypto.getPubKeyHex; getRef('private_key_field').customValidation = floCrypto.getPubKeyHex;
getRef('secure_pwd_button').closest('.card').classList.remove('hidden'); getRef('secure_pwd_button').closest('.card').classList.remove('hidden');
} }
if (window.location.hash.includes('sign_in') || window.location.hash.includes('sign_up')) { if (!generalPages.find(page => window.location.hash.includes(page))) {
routeTo(window.location.hash);
} else {
location.hash = floGlobals.isPrivKeySecured ? '#/sign_in' : `#/landing`; location.hash = floGlobals.isPrivKeySecured ? '#/sign_in' : `#/landing`;
} }
getRef('sign_in_button').onclick = () => { getRef('sign_in_button').onclick = () => {