logged out state handling

This commit is contained in:
Jackson Harper
2023-03-20 21:21:31 +08:00
parent 7be896e988
commit 4524b66dc7
2 changed files with 21 additions and 0 deletions

View File

@ -211,11 +211,20 @@ async function saveApiRequest(currentTab, query, field, input) {
try {
const result = await gqlRequest(omnivoreGraphqlURL + 'graphql', requestBody)
console.log(
'result: ',
field,
result,
result[field],
result[field]['errorCodes']
)
if (result[field]['errorCodes']) {
if (result[field]['errorCodes'][0] === 'UNAUTHORIZED') {
browserApi.tabs.sendMessage(currentTab.id, {
action: ACTIONS.UpdateStatus,
payload: {
target: 'logged_out',
status: 'logged_out',
message: 'You are not logged in.',
ctx: toolbarCtx,
@ -232,6 +241,7 @@ async function saveApiRequest(currentTab, query, field, input) {
},
})
}
return
}
const url = result[field] ? result[field]['url'] : undefined
@ -543,6 +553,7 @@ function onExtensionClick(tabId) {
function checkAuthOnFirstClickPostInstall(tabId) {
return getStorageItem('postInstallClickComplete').then(
async (postInstallClickComplete) => {
return true
if (postInstallClickComplete) return true
if (

View File

@ -92,9 +92,16 @@
height: 360px !important;
`
fragment.appendChild(iframeEl)
document.body.appendChild(fragment)
return fragment
}
function displayLoggedOutView() {
console.log('displaying logged out view')
createCtaModal(ctx.omnivoreURL)
}
function cancelAutoDismiss() {
doNotHide = true
if (hideToastTimeout) clearTimeout(hideToastTimeout)
@ -112,6 +119,9 @@
console.log('updated ctx: ', ctx)
switch (payload.target) {
case 'logged_out':
displayLoggedOutView()
break
case 'page':
{
const statusBox = currentToastEl.shadowRoot.querySelector(