@@ -61,9 +61,10 @@ import { renderString } from '@modrinth/utils'
6161import { useFetch } from ' @/helpers/fetch.js'
6262import { check } from ' @tauri-apps/plugin-updater'
6363import NavButton from ' @/components/ui/NavButton.vue'
64- import { get as getCreds , login , logout } from ' @/helpers/mr_auth.js'
64+ import { cancelLogin , get as getCreds , login , logout } from ' @/helpers/mr_auth.js'
6565import { get_user } from ' @/helpers/cache.js'
6666import AppSettingsModal from ' @/components/ui/modal/AppSettingsModal.vue'
67+ import AuthGrantFlowWaitModal from ' @/components/ui/modal/AuthGrantFlowWaitModal.vue'
6768import PromotionWrapper from ' @/components/ui/PromotionWrapper.vue'
6869import { hide_ads_window , init_ads_window } from ' @/helpers/ads.js'
6970import FriendsList from ' @/components/ui/friends/FriendsList.vue'
@@ -263,6 +264,8 @@ const incompatibilityWarningModal = ref()
263264
264265const credentials = ref ()
265266
267+ const modrinthLoginFlowWaitModal = ref ()
268+
266269async function fetchCredentials () {
267270 const creds = await getCreds ().catch (handleError)
268271 if (creds && creds .user_id ) {
@@ -272,8 +275,24 @@ async function fetchCredentials() {
272275}
273276
274277async function signIn () {
275- await login ().catch (handleError)
276- await fetchCredentials ()
278+ modrinthLoginFlowWaitModal .value .show ()
279+
280+ try {
281+ await login ()
282+ await fetchCredentials ()
283+ } catch (error) {
284+ if (
285+ typeof error === ' object' &&
286+ typeof error[' message' ] === ' string' &&
287+ error .message .includes (' Login canceled' )
288+ ) {
289+ // Not really an error due to being a result of user interaction, show nothing
290+ } else {
291+ handleError (error)
292+ }
293+ } finally {
294+ modrinthLoginFlowWaitModal .value .hide ()
295+ }
277296}
278297
279298async function logOut () {
@@ -402,6 +421,9 @@ function handleAuxClick(e) {
402421 < Suspense>
403422 < AppSettingsModal ref= " settingsModal" / >
404423 < / Suspense>
424+ < Suspense>
425+ < AuthGrantFlowWaitModal ref= " modrinthLoginFlowWaitModal" @flow- cancel= " cancelLogin" / >
426+ < / Suspense>
405427 < Suspense>
406428 < InstanceCreationModal ref= " installationModal" / >
407429 < / Suspense>
0 commit comments