migration
This commit is contained in:
parent
32b9c4a14d
commit
7d4ced15c6
90 changed files with 311 additions and 1165 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { defineStore } from 'pinia'
|
||||
|
||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
import { useUsersStore } from 'src/stores/users.js'
|
||||
|
||||
import { dismissAnnouncement, getAnnouncements } from 'src/api/user.js'
|
||||
|
||||
|
|
@ -16,7 +17,7 @@ export const useAnnouncementsStore = defineStore('announcements', {
|
|||
}),
|
||||
getters: {
|
||||
unreadAnnouncementCount() {
|
||||
if (!window.vuex.state.users.currentUser) {
|
||||
if (!useUsersStore().currentUser) {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ export const useAnnouncementsStore = defineStore('announcements', {
|
|||
async fetchAnnouncements() {
|
||||
if (!this.supportsAnnouncements) return
|
||||
|
||||
const currentUser = window.vuex.state.users.currentUser
|
||||
const currentUser = useUsersStore().currentUser
|
||||
const isAdmin =
|
||||
currentUser &&
|
||||
currentUser.privileges.has('announcements_manage_announcements')
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { defineStore } from 'pinia'
|
||||
|
||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
import { useUsersStore } from 'src/stores/users.js'
|
||||
|
||||
const PASSWORD_STRATEGY = 'password'
|
||||
const TOKEN_STRATEGY = 'token'
|
||||
|
|
@ -63,7 +64,7 @@ export const useAuthFlowStore = defineStore('authFlow', {
|
|||
},
|
||||
async login({ access_token: accessToken }) {
|
||||
useOAuthStore().setToken(accessToken)
|
||||
await window.vuex.dispatch('loginUser', accessToken, { root: true })
|
||||
useUsersStore().loginUser(accessToken, { root: true })
|
||||
this.resetState()
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { defineStore } from 'pinia'
|
|||
|
||||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
import { useUsersStore } from 'src/stores/users.js'
|
||||
|
||||
import { listEmojiPacks } from 'src/api/public.js'
|
||||
import { ensureFinalFallback } from 'src/i18n/languages.js'
|
||||
|
|
@ -194,7 +195,7 @@ export const useEmojiStore = defineStore('emoji', {
|
|||
},
|
||||
|
||||
async getAdminPacks(instance, listFunction) {
|
||||
const currentUser = window.vuex.state.users.currentUser
|
||||
const currentUser = useUsersStore().currentUser
|
||||
|
||||
if (!currentUser.rights.admin) return
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import {
|
|||
} from '../modules/default_config_state.js'
|
||||
|
||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||
import { useUsersStore } from 'src/stores/users.js'
|
||||
|
||||
import { fetchKnownDomains } from 'src/api/public.js'
|
||||
|
||||
|
|
@ -212,7 +213,7 @@ export const useInstanceStore = defineStore('instance', {
|
|||
async getKnownDomains() {
|
||||
try {
|
||||
const { data } = await fetchKnownDomains({
|
||||
credentials: window.vuex.state.users.currentUser.credentials,
|
||||
credentials: useUsersStore().currentUser.credentials,
|
||||
})
|
||||
this.knownDomains = data
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { deserialize } from '../services/theme_data/iss_deserializer.js'
|
|||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
import { useUsersStore } from 'src/stores/users.js'
|
||||
|
||||
import {
|
||||
CURRENT_VERSION,
|
||||
|
|
@ -245,7 +246,7 @@ export const useInterfaceStore = defineStore('interface', {
|
|||
const mobileLayout = width <= 800
|
||||
const normalOrMobile = mobileLayout ? 'mobile' : 'normal'
|
||||
const { thirdColumnMode } = useMergedConfigStore().mergedConfig
|
||||
if (thirdColumnMode === 'none' || !window.vuex.state.users.currentUser) {
|
||||
if (thirdColumnMode === 'none' || !useUsersStore().currentUser) {
|
||||
this.layoutType = normalOrMobile
|
||||
} else {
|
||||
const wideLayout = width >= 1300
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/updat
|
|||
|
||||
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
import { useUsersStore } from 'src/stores/users.js'
|
||||
|
||||
import { updateProfileJSON } from 'src/api/user.js'
|
||||
import { storage } from 'src/lib/storage.js'
|
||||
|
|
@ -807,7 +808,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
pushSyncConfig({ force = false } = {}) {
|
||||
const needPush = this.dirty || force
|
||||
if (!needPush) return
|
||||
this.updateCache({ username: window.vuex.state.users.currentUser.fqn })
|
||||
this.updateCache({ username: useUsersStore().currentUser.fqn })
|
||||
const params = { pleroma_settings_store: { 'pleroma-fe': this.cache } }
|
||||
updateProfileJSON({
|
||||
params,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { defineStore } from 'pinia'
|
|||
import { toRaw } from 'vue'
|
||||
|
||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
import { useUsersStore } from 'src/stores/users.js'
|
||||
|
||||
import { updateProfileJSON } from 'src/api/user.js'
|
||||
import { storage } from 'src/lib/storage.js'
|
||||
|
|
@ -328,7 +329,7 @@ export const useUserHighlightStore = defineStore('user_highlight', {
|
|||
pushHighlight({ force = false } = {}) {
|
||||
const needPush = this.dirty || force
|
||||
if (!needPush) return
|
||||
this.updateCache({ username: window.vuex.state.users.currentUser.fqn })
|
||||
this.updateCache({ username: useUsersStore().currentUser.fqn })
|
||||
const params = {
|
||||
pleroma_settings_store: { user_highlight: this.cache },
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,18 +59,16 @@ const getNotificationPermission = async () => {
|
|||
return Notification.permission
|
||||
}
|
||||
|
||||
export const defaultState = {
|
||||
loggingIn: false,
|
||||
lastLoginName: null,
|
||||
currentUser: null,
|
||||
users: new Map(),
|
||||
usersByName: new Map(),
|
||||
usersByURL: new Map(),
|
||||
relationships: new Map(),
|
||||
}
|
||||
|
||||
export const useUsersStore = defineStore('users', {
|
||||
state: defaultState,
|
||||
state: () => ({
|
||||
loggingIn: false,
|
||||
lastLoginName: null,
|
||||
currentUser: null,
|
||||
users: new Map(),
|
||||
usersByName: new Map(),
|
||||
usersByURL: new Map(),
|
||||
relationships: new Map(),
|
||||
}),
|
||||
getters: {
|
||||
loggedIn: (state) => !!state.currentUser,
|
||||
findUser: (state) => (query) => {
|
||||
|
|
@ -141,7 +139,7 @@ export const useUsersStore = defineStore('users', {
|
|||
},
|
||||
addNewUsers(users, timestamp) {
|
||||
users.forEach((user) => {
|
||||
const existing = users.get(user.id) ?? {}
|
||||
const existing = this.users.get(user.id) ?? {}
|
||||
|
||||
const { relationship, ...old } = existing
|
||||
const { relationshop, ...neu } = user
|
||||
|
|
@ -150,6 +148,10 @@ export const useUsersStore = defineStore('users', {
|
|||
this.users.set(user.id, newUser)
|
||||
this.usersByName.set(user.screen_name.toLowerCase(), newUser)
|
||||
this.usersByURL.set(user.url.toLowerCase(), newUser)
|
||||
|
||||
if (user.id === this.currentUser.id) {
|
||||
this.currentUser = newUser
|
||||
}
|
||||
})
|
||||
},
|
||||
updateUserRelationship(relationships) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue