Merge remote-tracking branch 'origin/develop' into timed-user-mutes
This commit is contained in:
commit
385f921c41
72 changed files with 1336 additions and 851 deletions
|
|
@ -211,6 +211,7 @@ const api = {
|
|||
statusId = false,
|
||||
bookmarkFolderId = false
|
||||
}) {
|
||||
if (timeline === 'favourites' && !store.rootState.instance.pleromaPublicFavouritesAvailable) return
|
||||
if (store.state.fetchers[timeline]) return
|
||||
|
||||
const fetcher = store.state.backendInteractor.startFetchingTimeline({
|
||||
|
|
@ -281,6 +282,7 @@ const api = {
|
|||
// Bookmark folders
|
||||
startFetchingBookmarkFolders (store) {
|
||||
if (store.state.fetchers.bookmarkFolders) return
|
||||
if (!store.rootState.instance.pleromaBookmarkFoldersAvailable) return
|
||||
const fetcher = store.state.backendInteractor.startFetchingBookmarkFolders({ store })
|
||||
store.commit('addFetcher', { fetcherName: 'bookmarkFolders', fetcher })
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,86 +0,0 @@
|
|||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
|
||||
const PASSWORD_STRATEGY = 'password'
|
||||
const TOKEN_STRATEGY = 'token'
|
||||
|
||||
// MFA strategies
|
||||
const TOTP_STRATEGY = 'totp'
|
||||
const RECOVERY_STRATEGY = 'recovery'
|
||||
|
||||
// initial state
|
||||
const state = {
|
||||
settings: {},
|
||||
strategy: PASSWORD_STRATEGY,
|
||||
initStrategy: PASSWORD_STRATEGY // default strategy from config
|
||||
}
|
||||
|
||||
const resetState = (state) => {
|
||||
state.strategy = state.initStrategy
|
||||
state.settings = {}
|
||||
}
|
||||
|
||||
// getters
|
||||
const getters = {
|
||||
settings: (state) => {
|
||||
return state.settings
|
||||
},
|
||||
requiredPassword: (state) => {
|
||||
return state.strategy === PASSWORD_STRATEGY
|
||||
},
|
||||
requiredToken: (state) => {
|
||||
return state.strategy === TOKEN_STRATEGY
|
||||
},
|
||||
requiredTOTP: (state) => {
|
||||
return state.strategy === TOTP_STRATEGY
|
||||
},
|
||||
requiredRecovery: (state) => {
|
||||
return state.strategy === RECOVERY_STRATEGY
|
||||
}
|
||||
}
|
||||
|
||||
// mutations
|
||||
const mutations = {
|
||||
setInitialStrategy (state, strategy) {
|
||||
if (strategy) {
|
||||
state.initStrategy = strategy
|
||||
state.strategy = strategy
|
||||
}
|
||||
},
|
||||
requirePassword (state) {
|
||||
state.strategy = PASSWORD_STRATEGY
|
||||
},
|
||||
requireToken (state) {
|
||||
state.strategy = TOKEN_STRATEGY
|
||||
},
|
||||
requireMFA (state, { settings }) {
|
||||
state.settings = settings
|
||||
state.strategy = TOTP_STRATEGY // default strategy of MFA
|
||||
},
|
||||
requireRecovery (state) {
|
||||
state.strategy = RECOVERY_STRATEGY
|
||||
},
|
||||
requireTOTP (state) {
|
||||
state.strategy = TOTP_STRATEGY
|
||||
},
|
||||
abortMFA (state) {
|
||||
resetState(state)
|
||||
}
|
||||
}
|
||||
|
||||
// actions
|
||||
const actions = {
|
||||
|
||||
async login ({ state, dispatch }, { access_token: accessToken }) {
|
||||
useOAuthStore().setToken(accessToken)
|
||||
await dispatch('loginUser', accessToken, { root: true })
|
||||
resetState(state)
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters,
|
||||
mutations,
|
||||
actions
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@ import api from './api.js'
|
|||
import config from './config.js'
|
||||
import profileConfig from './profileConfig.js'
|
||||
import adminSettings from './adminSettings.js'
|
||||
import authFlow from './auth_flow.js'
|
||||
import drafts from './drafts.js'
|
||||
import chats from './chats.js'
|
||||
|
||||
|
|
@ -19,7 +18,6 @@ export default {
|
|||
config,
|
||||
profileConfig,
|
||||
adminSettings,
|
||||
authFlow,
|
||||
drafts,
|
||||
chats
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ const defaultState = {
|
|||
emoji: {},
|
||||
emojiFetched: false,
|
||||
unicodeEmojiAnnotations: {},
|
||||
pleromaBackend: true,
|
||||
pleromaExtensionsAvailable: true,
|
||||
postFormats: [],
|
||||
restrictedNicknames: [],
|
||||
safeDM: true,
|
||||
|
|
@ -156,6 +156,8 @@ const defaultState = {
|
|||
pleromaChatMessagesAvailable: false,
|
||||
pleromaCustomEmojiReactionsAvailable: false,
|
||||
pleromaBookmarkFoldersAvailable: false,
|
||||
pleromaPublicFavouritesAvailable: true,
|
||||
statusNotificationTypeAvailable: true,
|
||||
gopherAvailable: false,
|
||||
mediaProxyAvailable: false,
|
||||
suggestionsEnabled: false,
|
||||
|
|
@ -163,6 +165,7 @@ const defaultState = {
|
|||
quotingAvailable: false,
|
||||
groupActorAvailable: false,
|
||||
blockExpiration: false,
|
||||
localBubbleInstances: [], // Akkoma
|
||||
|
||||
// Html stuff
|
||||
instanceSpecificPanelContent: '',
|
||||
|
|
@ -341,7 +344,10 @@ const instance = {
|
|||
|
||||
async getCustomEmoji ({ commit, state }) {
|
||||
try {
|
||||
const res = await window.fetch('/api/pleroma/emoji.json')
|
||||
let res = await window.fetch('/api/v1/pleroma/emoji')
|
||||
if (!res.ok) {
|
||||
res = await window.fetch('/api/pleroma/emoji.json')
|
||||
}
|
||||
if (res.ok) {
|
||||
const result = await res.json()
|
||||
const values = Array.isArray(result) ? Object.assign({}, ...result) : result
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ export const defaultState = () => ({
|
|||
conversationsObject: {},
|
||||
maxId: 0,
|
||||
favorites: new Set(),
|
||||
pleromaScrobblesAvailable: true, // not reported in nodeinfo
|
||||
timelines: {
|
||||
mentions: emptyTl(),
|
||||
public: emptyTl(),
|
||||
|
|
@ -50,7 +51,8 @@ export const defaultState = () => ({
|
|||
tag: emptyTl(),
|
||||
dms: emptyTl(),
|
||||
bookmarks: emptyTl(),
|
||||
list: emptyTl()
|
||||
list: emptyTl(),
|
||||
bubble: emptyTl()
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -108,12 +110,21 @@ const sortTimeline = (timeline) => {
|
|||
}
|
||||
|
||||
const getLatestScrobble = (state, user) => {
|
||||
const scrobblesSupport = state.pleromaScrobblesAvailable
|
||||
if (!scrobblesSupport) return
|
||||
|
||||
if (state.scrobblesNextFetch[user.id] && state.scrobblesNextFetch[user.id] > Date.now()) {
|
||||
return
|
||||
}
|
||||
|
||||
state.scrobblesNextFetch[user.id] = Date.now() + 24 * 60 * 60 * 1000
|
||||
if (!scrobblesSupport) return
|
||||
apiService.fetchScrobbles({ accountId: user.id }).then((scrobbles) => {
|
||||
if (scrobbles?.error) {
|
||||
state.pleromaScrobblesAvailable = false
|
||||
return
|
||||
}
|
||||
|
||||
if (scrobbles.length > 0) {
|
||||
user.latestScrobble = scrobbles[0]
|
||||
|
||||
|
|
|
|||
|
|
@ -607,6 +607,7 @@ const users = {
|
|||
return new Promise((resolve, reject) => {
|
||||
const commit = store.commit
|
||||
const dispatch = store.dispatch
|
||||
const rootState = store.rootState
|
||||
commit('beginLogin')
|
||||
store.rootState.api.backendInteractor.verifyCredentials(accessToken)
|
||||
.then((data) => {
|
||||
|
|
@ -673,8 +674,10 @@ const users = {
|
|||
// Start fetching notifications
|
||||
dispatch('startFetchingNotifications')
|
||||
|
||||
// Start fetching chats
|
||||
dispatch('startFetchingChats')
|
||||
if (rootState.instance.pleromaChatMessagesAvailable) {
|
||||
// Start fetching chats
|
||||
dispatch('startFetchingChats')
|
||||
}
|
||||
}
|
||||
|
||||
dispatch('startFetchingLists')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue