diff --git a/src/app/components/LogInEmail.svelte b/src/app/components/LogInEmail.svelte index 597ad074..eecc9042 100644 --- a/src/app/components/LogInEmail.svelte +++ b/src/app/components/LogInEmail.svelte @@ -19,6 +19,7 @@ import LogInOTP from "@app/components/LogInOTP.svelte" import LogInSelect from "@app/components/LogInSelect.svelte" import {deleteDeactivatedPomadeSessions, loginWithPomade} from "@app/util/pomade" + import {getPomadeLoginFailureMessage, POMADE_NETWORK_ERROR_MESSAGE} from "@app/util/pomadeErrors" import {pushModal, clearModals} from "@app/util/modal" import {setChecked} from "@app/util/notifications" import {pushToast} from "@app/util/toast" @@ -44,7 +45,7 @@ return pushToast({ theme: "error", - message: "Sorry, we were unable to log you in.", + message: getPomadeLoginFailureMessage(messages), }) } @@ -64,10 +65,17 @@ pushToast({ theme: "error", - message: "Sorry, we were unable to log you in.", + message: getPomadeLoginFailureMessage(res.messages), }) } } + } catch (error) { + console.error("Login error:", error) + + pushToast({ + theme: "error", + message: POMADE_NETWORK_ERROR_MESSAGE, + }) } finally { loading = false } diff --git a/src/app/components/LogInOTP.svelte b/src/app/components/LogInOTP.svelte index b0d71e19..a5658e5d 100644 --- a/src/app/components/LogInOTP.svelte +++ b/src/app/components/LogInOTP.svelte @@ -15,6 +15,7 @@ import ModalSubtitle from "@lib/components/ModalSubtitle.svelte" import ModalFooter from "@lib/components/ModalFooter.svelte" import LogInOTPConfirm from "@app/components/LogInOTPConfirm.svelte" + import {POMADE_NETWORK_ERROR_MESSAGE} from "@app/util/pomadeErrors" import {pushModal} from "@app/util/modal" import {pushToast} from "@app/util/toast" @@ -35,11 +36,20 @@ if (ok) { pushModal(LogInOTPConfirm, {email, peersByPrefix}) } else { + console.error("Pomade challenge request failed during OTP login") + pushToast({ theme: "error", - message: "Sorry, we were unable to request a login code.", + message: POMADE_NETWORK_ERROR_MESSAGE, }) } + } catch (error) { + console.error(error) + + pushToast({ + theme: "error", + message: POMADE_NETWORK_ERROR_MESSAGE, + }) } finally { loading = false } diff --git a/src/app/components/LogInOTPConfirm.svelte b/src/app/components/LogInOTPConfirm.svelte index d0ce449a..4b16a49f 100644 --- a/src/app/components/LogInOTPConfirm.svelte +++ b/src/app/components/LogInOTPConfirm.svelte @@ -15,10 +15,11 @@ import ModalFooter from "@lib/components/ModalFooter.svelte" import StringMultiInput from "@lib/components/StringMultiInput.svelte" import LogInSelect from "@app/components/LogInSelect.svelte" - import {pushToast} from "@app/util/toast" - import {setChecked} from "@app/util/notifications" import {pushModal, clearModals} from "@app/util/modal" + import {setChecked} from "@app/util/notifications" import {deleteDeactivatedPomadeSessions, loginWithPomade} from "@app/util/pomade" + import {getPomadeLoginFailureMessage, POMADE_NETWORK_ERROR_MESSAGE} from "@app/util/pomadeErrors" + import {pushToast} from "@app/util/toast" type Props = { email: string @@ -44,7 +45,7 @@ return pushToast({ theme: "error", - message: "Sorry, we were unable to log you in.", + message: getPomadeLoginFailureMessage(messages), }) } @@ -64,10 +65,17 @@ pushToast({ theme: "error", - message: "Sorry, we were unable to log you in.", + message: getPomadeLoginFailureMessage(res.messages), }) } } + } catch (error) { + console.error("Login error:", error) + + pushToast({ + theme: "error", + message: POMADE_NETWORK_ERROR_MESSAGE, + }) } finally { loading = false } diff --git a/src/app/components/LogInSelect.svelte b/src/app/components/LogInSelect.svelte index 9da7c432..8d416afd 100644 --- a/src/app/components/LogInSelect.svelte +++ b/src/app/components/LogInSelect.svelte @@ -14,6 +14,7 @@ import ModalFooter from "@lib/components/ModalFooter.svelte" import Profile from "@app/components/Profile.svelte" import {deleteDeactivatedPomadeSessions, loginWithPomade} from "@app/util/pomade" + import {getPomadeLoginFailureMessage, POMADE_NETWORK_ERROR_MESSAGE} from "@app/util/pomadeErrors" import {setChecked} from "@app/util/notifications" import {clearModals} from "@app/util/modal" import {pushToast} from "@app/util/toast" @@ -46,9 +47,16 @@ pushToast({ theme: "error", - message: "Sorry, we were unable to log you in.", + message: getPomadeLoginFailureMessage(res.messages), }) } + } catch (error) { + console.error("Login error:", error) + + pushToast({ + theme: "error", + message: POMADE_NETWORK_ERROR_MESSAGE, + }) } finally { loading = false } diff --git a/src/app/util/pomadeErrors.ts b/src/app/util/pomadeErrors.ts new file mode 100644 index 00000000..595e1b73 --- /dev/null +++ b/src/app/util/pomadeErrors.ts @@ -0,0 +1,11 @@ +export const POMADE_INVALID_LOGIN_MESSAGE = "Invalid login information" +export const POMADE_NETWORK_ERROR_MESSAGE = "Network error, please try again" + +type PomadeMessage = { + res?: unknown +} + +export const getPomadeLoginFailureMessage = (messages: PomadeMessage[]) => + messages.some(message => message.res !== undefined) + ? POMADE_INVALID_LOGIN_MESSAGE + : POMADE_NETWORK_ERROR_MESSAGE diff --git a/src/lib/components/FieldInline.svelte b/src/lib/components/FieldInline.svelte index 235a1a7b..01bfdf6a 100644 --- a/src/lib/components/FieldInline.svelte +++ b/src/lib/components/FieldInline.svelte @@ -9,16 +9,22 @@ const {...props}: Props = $props() -
- {#if props.info} - {@render props.info?.()} +
+ {@render props.info()} +
+ {/if}Show badge for unread alerts
- -Show badge for unread alerts
+ {/snippet} + {#snippet input()} + + {/snippet} +Play sound for new activity
- -Play sound for new activity
+ {/snippet} + {#snippet input()} + + {/snippet} +Enable push notifications
- -Enable push notifications
+ {/snippet} + {#snippet input()} + + {/snippet} +Notify me about new activity
- -Always notify me when mentioned
- -Notify me about new messages
- -Notify me about new activity
+ {/snippet} + {#snippet input()} + + {/snippet} +Always notify me when mentioned
+ {/snippet} + {#snippet input()} + + {/snippet} +Notify me about new messages
+ {/snippet} + {#snippet input()} + + {/snippet} +Send Delay
{/snippet} {#snippet input()} {/snippet} -Media Server
{/snippet} + {#snippet secondary()} + + {/snippet} {#snippet input()} -Choose a media server type and url for files you upload to {PLATFORM_NAME}.
diff --git a/src/routes/settings/privacy/+page.svelte b/src/routes/settings/privacy/+page.svelte index 4ab74fa6..4b864bb8 100644 --- a/src/routes/settings/privacy/+page.svelte +++ b/src/routes/settings/privacy/+page.svelte @@ -1,6 +1,7 @@