diff --git a/src/api/oauth.js b/src/api/oauth.js index ce4c2f6fc..2c3c446e5 100644 --- a/src/api/oauth.js +++ b/src/api/oauth.js @@ -91,6 +91,7 @@ export const getClientToken = ({ clientId, clientSecret, instance }) => { formData, }) } + export const verifyOTPCode = ({ app, instance, mfaToken, code }) => { const formData = new window.FormData() diff --git a/src/api/user.js b/src/api/user.js index ebbd8b473..5adc53cda 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -81,6 +81,7 @@ const MASTODON_MUTE_CONVERSATION = (id) => `/api/v1/statuses/${id}/mute` const MASTODON_UNMUTE_CONVERSATION = (id) => `/api/v1/statuses/${id}/unmute` const MASTODON_DOMAIN_BLOCKS_URL = '/api/v1/domain_blocks' const MASTODON_LISTS_URL = '/api/v1/lists' +const MASTODON_ANNOUNCEMENTS_URL = '/api/v1/announcements' const MASTODON_ANNOUNCEMENTS_DISMISS_URL = (id) => `/api/v1/announcements/${id}/dismiss` const PLEROMA_EMOJI_REACT_URL = (id, emoji) => @@ -335,13 +336,6 @@ export const dismissNotification = ({ credentials, id }) => credentials, }) -export const dismissAnnouncement = ({ id, credentials }) => - promisedRequest({ - url: MASTODON_ANNOUNCEMENTS_DISMISS_URL(id), - credentials, - method: 'POST', - }) - export const markNotificationsAsSeen = ({ id, credentials, @@ -363,6 +357,18 @@ export const markNotificationsAsSeen = ({ }) } +// #Announcements +export const getAnnouncements = ({ credentials }) => + promisedRequest({ url: MASTODON_ANNOUNCEMENTS_URL, credentials }) + +export const dismissAnnouncement = ({ id, credentials }) => + promisedRequest({ + url: MASTODON_ANNOUNCEMENTS_DISMISS_URL(id), + credentials, + method: 'POST', + }) + + // #Imports export const importMutes = ({ file, credentials }) => { const formData = new FormData() diff --git a/src/boot/after_store.js b/src/boot/after_store.js index 895fe910c..95fb3e9ea 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -566,10 +566,6 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => { getInstanceConfig({ store }), ]).catch((e) => Promise.reject(e)) - // Start fetching things that don't need to block the UI - store.dispatch('fetchMutes') - store.dispatch('loadDrafts') - useAnnouncementsStore().startFetchingAnnouncements() getTOS({ store }) getStickers({ store }) diff --git a/src/modules/users.js b/src/modules/users.js index 5573928b4..d743324b0 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -28,6 +28,7 @@ import { useMergedConfigStore } from 'src/stores/merged_config.js' import { useOAuthStore } from 'src/stores/oauth.js' import { useSyncConfigStore } from 'src/stores/sync_config.js' import { useUserHighlightStore } from 'src/stores/user_highlight.js' +import { useAnnouncementsStore } from 'src/stores/announcements.js' import { revokeToken } from 'src/api/oauth.js' import { @@ -832,8 +833,11 @@ const users = { startPolling() } - // Get user mutes + // Start fetching things that don't need to block the UI + useAnnouncementsStore().startFetchingAnnouncements() + dispatch('fetchMutes') + dispatch('loadDrafts') useInterfaceStore().setLayoutWidth(windowWidth()) useInterfaceStore().setLayoutHeight(windowHeight()) diff --git a/src/stores/announcements.js b/src/stores/announcements.js index 4668b286a..6339bba52 100644 --- a/src/stores/announcements.js +++ b/src/stores/announcements.js @@ -2,7 +2,7 @@ import { defineStore } from 'pinia' import { useOAuthStore } from 'src/stores/oauth.js' -import { getAnnouncements } from 'src/api/public.js' +import { getAnnouncements, dismissAnnouncement } from 'src/api/user.js' const FETCH_ANNOUNCEMENT_INTERVAL_MS = 1000 * 60 * 5 @@ -36,10 +36,6 @@ export const useAnnouncementsStore = defineStore('announcements', { currentUser.privileges.has('announcements_manage_announcements') try { - if (currentUser) { - this.userActions = await import('src/api/user.js') - } - if (isAdmin) { this.adminActions = await import('src/api/admin.js') } else { @@ -86,8 +82,7 @@ export const useAnnouncementsStore = defineStore('announcements', { } }, markAnnouncementAsRead(id) { - return this.userActions - .dismissAnnouncement({ + return dismissAnnouncement({ id, credentials: useOAuthStore().token, })