use OAuthStore directly
This commit is contained in:
parent
529a2d100b
commit
3984a5aefa
44 changed files with 226 additions and 256 deletions
|
|
@ -3,10 +3,10 @@ import { Socket } from 'phoenix'
|
|||
import { WSConnectionStatus } from '../services/api/api.service.js'
|
||||
import { maybeShowChatNotification } from '../services/chat_utils/chat_utils.js'
|
||||
|
||||
import { useCredentialsStore } from 'src/stores/credentials.js'
|
||||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
import { useShoutStore } from 'src/stores/shout.js'
|
||||
|
||||
import {
|
||||
|
|
@ -98,7 +98,7 @@ const api = {
|
|||
const timelineData = rootState.statuses.timelines.friends
|
||||
|
||||
const serv = useInstanceStore().server.replace('http', 'ws')
|
||||
const credentials = useCredentialsStore().current
|
||||
const credentials = useOAuthStore().token
|
||||
const url = getMastodonSocketURI({ credentials }, serv)
|
||||
|
||||
state.mastoUserSocket = ProcessedWS({
|
||||
|
|
@ -266,7 +266,7 @@ const api = {
|
|||
statusId,
|
||||
bookmarkFolderId,
|
||||
tag,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
|
||||
store.commit('addFetcher', { fetcherName: timeline, fetcher })
|
||||
|
|
@ -282,7 +282,7 @@ const api = {
|
|||
store,
|
||||
timeline,
|
||||
...rest,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
},
|
||||
|
||||
|
|
@ -291,7 +291,7 @@ const api = {
|
|||
if (store.state.fetchers.notifications) return
|
||||
const fetcher = notificationsFetcher.startFetching({
|
||||
store,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
store.commit('addFetcher', { fetcherName: 'notifications', fetcher })
|
||||
},
|
||||
|
|
@ -306,7 +306,7 @@ const api = {
|
|||
if (store.state.fetchers.followRequests) return
|
||||
const fetcher = followRequestFetcher.startFetchingFollowRequests({
|
||||
store,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
|
||||
store.commit('addFetcher', { fetcherName: 'followRequests', fetcher })
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import {
|
|||
} from '../services/entity_normalizer/entity_normalizer.service.js'
|
||||
import { promiseInterval } from '../services/promise_interval/promise_interval.js'
|
||||
|
||||
import { useCredentialsStore } from 'src/stores/credentials.js'
|
||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
|
||||
import {
|
||||
chats,
|
||||
|
|
@ -68,7 +68,7 @@ const chatsModule = {
|
|||
},
|
||||
fetchChats({ dispatch, rootState }) {
|
||||
return chats({
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then(({ chatList }) => {
|
||||
dispatch('addNewChats', { chats: chatList })
|
||||
return chats
|
||||
|
|
@ -125,14 +125,14 @@ const chatsModule = {
|
|||
readChat({
|
||||
id,
|
||||
lastReadId,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteChatMessage({ rootState, commit }, value) {
|
||||
deleteChatMessage({
|
||||
...value,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
commit('deleteChatMessage', { commit, ...value })
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ import {
|
|||
maybeShowNotification,
|
||||
} from '../services/notification_utils/notification_utils.js'
|
||||
|
||||
import { useCredentialsStore } from 'src/stores/credentials.js'
|
||||
import { useI18nStore } from 'src/stores/i18n.js'
|
||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
import { useReportsStore } from 'src/stores/reports.js'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ export const notifications = {
|
|||
commit('dismissNotification', { id })
|
||||
dismissNotification({
|
||||
id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
},
|
||||
updateNotification({ commit }, { id, updater }) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { get, set } from 'lodash'
|
||||
|
||||
import { useCredentialsStore } from 'src/stores/credentials.js'
|
||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
|
||||
import {
|
||||
updateNotificationSettings,
|
||||
|
|
@ -12,7 +12,7 @@ const defaultApi = ({ rootState, commit }, { path, value }) => {
|
|||
set(params, path, value)
|
||||
return updateProfile({
|
||||
params,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((result) => {
|
||||
commit('addNewUsers', [result])
|
||||
commit('setCurrentUser', result)
|
||||
|
|
@ -24,7 +24,7 @@ const notificationsApi = ({ rootState, commit }, { path, value, oldValue }) => {
|
|||
set(settings, path, value)
|
||||
return updateNotificationSettings({
|
||||
settings,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((result) => {
|
||||
if (result.status === 'success') {
|
||||
commit('confirmProfileOption', { name, value })
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ import {
|
|||
unretweet,
|
||||
} from '../services/api/api.service.js'
|
||||
|
||||
import { useCredentialsStore } from 'src/stores/credentials.js'
|
||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
|
||||
const emptyTl = (userId = 0) => ({
|
||||
statuses: [],
|
||||
|
|
@ -632,7 +632,7 @@ const statuses = {
|
|||
fetchStatusSource({ rootState }, status) {
|
||||
return fetchStatusSource({
|
||||
id: status.id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
},
|
||||
fetchStatusHistory(_, status) {
|
||||
|
|
@ -641,7 +641,7 @@ const statuses = {
|
|||
deleteStatus({ rootState, commit }, status) {
|
||||
deleteStatus({
|
||||
id: status.id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
.then(() => {
|
||||
commit('setDeleted', { status })
|
||||
|
|
@ -667,7 +667,7 @@ const statuses = {
|
|||
commit('setFavorited', { status, value: true })
|
||||
favorite({
|
||||
id: status.id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((status) =>
|
||||
commit('setFavoritedConfirm', {
|
||||
status,
|
||||
|
|
@ -680,7 +680,7 @@ const statuses = {
|
|||
commit('setFavorited', { status, value: false })
|
||||
unfavorite({
|
||||
id: status.id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((status) =>
|
||||
commit('setFavoritedConfirm', {
|
||||
status,
|
||||
|
|
@ -691,7 +691,7 @@ const statuses = {
|
|||
fetchPinnedStatuses({ rootState, dispatch }, userId) {
|
||||
fetchPinnedStatuses({
|
||||
id: userId,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((statuses) =>
|
||||
dispatch('addNewStatuses', {
|
||||
statuses,
|
||||
|
|
@ -705,25 +705,25 @@ const statuses = {
|
|||
pinStatus({ rootState, dispatch }, statusId) {
|
||||
return pinOwnStatus({
|
||||
id: statusId,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((status) => dispatch('addNewStatuses', { statuses: [status] }))
|
||||
},
|
||||
unpinStatus({ rootState, dispatch }, statusId) {
|
||||
return unpinOwnStatus({
|
||||
id: statusId,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((status) => dispatch('addNewStatuses', { statuses: [status] }))
|
||||
},
|
||||
muteConversation({ rootState, commit }, { id: statusId }) {
|
||||
return muteConversation({
|
||||
id: statusId,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((status) => commit('setMutedStatus', status))
|
||||
},
|
||||
unmuteConversation({ rootState, commit }, { id: statusId }) {
|
||||
return unmuteConversation({
|
||||
id: statusId,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((status) => commit('setMutedStatus', status))
|
||||
},
|
||||
retweet({ rootState, commit }, status) {
|
||||
|
|
@ -731,7 +731,7 @@ const statuses = {
|
|||
commit('setRetweeted', { status, value: true })
|
||||
retweet({
|
||||
id: status.id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((status) =>
|
||||
commit('setRetweetedConfirm', {
|
||||
status: status.retweeted_status,
|
||||
|
|
@ -744,7 +744,7 @@ const statuses = {
|
|||
commit('setRetweeted', { status, value: false })
|
||||
unretweet({
|
||||
id: status.id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((status) =>
|
||||
commit('setRetweetedConfirm', {
|
||||
status,
|
||||
|
|
@ -757,7 +757,7 @@ const statuses = {
|
|||
bookmarkStatus({
|
||||
id: status.id,
|
||||
folder_id: status.bookmark_folder_id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((status) => {
|
||||
commit('setBookmarkedConfirm', { status })
|
||||
})
|
||||
|
|
@ -766,7 +766,7 @@ const statuses = {
|
|||
commit('setBookmarked', { status, value: false })
|
||||
unbookmarkStatus({
|
||||
id: status.id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((status) => {
|
||||
commit('setBookmarkedConfirm', { status })
|
||||
})
|
||||
|
|
@ -781,11 +781,11 @@ const statuses = {
|
|||
Promise.all([
|
||||
fetchFavoritedByUsers({
|
||||
id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}),
|
||||
fetchRebloggedByUsers({
|
||||
id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}),
|
||||
]).then(([favoritedByUsers, rebloggedByUsers]) => {
|
||||
commit('addFavs', {
|
||||
|
|
@ -808,7 +808,7 @@ const statuses = {
|
|||
reactWithEmoji({
|
||||
id,
|
||||
emoji,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then(() => {
|
||||
dispatch('fetchEmojiReactionsBy', id)
|
||||
})
|
||||
|
|
@ -829,7 +829,7 @@ const statuses = {
|
|||
fetchEmojiReactionsBy({ rootState, commit }, id) {
|
||||
return fetchEmojiReactions({
|
||||
id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((emojiReactions) => {
|
||||
commit('addEmojiReactionsBy', {
|
||||
id,
|
||||
|
|
@ -841,7 +841,7 @@ const statuses = {
|
|||
fetchFavs({ rootState, commit }, id) {
|
||||
fetchFavoritedByUsers({
|
||||
id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((favoritedByUsers) =>
|
||||
commit('addFavs', {
|
||||
id,
|
||||
|
|
@ -853,7 +853,7 @@ const statuses = {
|
|||
fetchRepeats({ rootState, commit }, id) {
|
||||
fetchRebloggedByUsers({
|
||||
id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((rebloggedByUsers) =>
|
||||
commit('addRepeats', {
|
||||
id,
|
||||
|
|
@ -870,7 +870,7 @@ const statuses = {
|
|||
offset,
|
||||
following,
|
||||
type,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((data) => {
|
||||
store.commit('addNewUsers', data.accounts)
|
||||
store.commit(
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import {
|
|||
} from '../services/window_utils/window_utils'
|
||||
|
||||
import { useBookmarkFoldersStore } from 'src/stores/bookmark_folders.js'
|
||||
import { useCredentialsStore } from 'src/stores/credentials.js'
|
||||
import { useEmojiStore } from 'src/stores/emoji.js'
|
||||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||
|
|
@ -133,7 +132,7 @@ const localMuteUser = (store, args) => {
|
|||
return muteUser({
|
||||
id,
|
||||
expiresIn,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((relationship) => {
|
||||
store.commit('updateUserRelationship', [relationship])
|
||||
store.commit('addMuteId', id)
|
||||
|
|
@ -154,7 +153,7 @@ const hideReblogs = (store, userId) => {
|
|||
return followUser({
|
||||
id: userId,
|
||||
reblogs: false,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((relationship) => {
|
||||
store.commit('updateUserRelationship', [relationship])
|
||||
})
|
||||
|
|
@ -164,7 +163,7 @@ const showReblogs = (store, userId) => {
|
|||
return followUser({
|
||||
id: userId,
|
||||
reblogs: true,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((relationship) =>
|
||||
store.commit('updateUserRelationship', [relationship]),
|
||||
)
|
||||
|
|
@ -173,14 +172,14 @@ const showReblogs = (store, userId) => {
|
|||
const muteDomain = (store, domain) => {
|
||||
return muteDomain({
|
||||
domain,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then(() => store.commit('addDomainMute', domain))
|
||||
}
|
||||
|
||||
const unmuteDomain = (store, domain) => {
|
||||
return unmuteDomain({
|
||||
domain,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then(() => store.commit('removeDomainMute', domain))
|
||||
}
|
||||
|
||||
|
|
@ -404,7 +403,7 @@ const users = {
|
|||
fetchUser(store, id) {
|
||||
return fetchUser({
|
||||
id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((user) => {
|
||||
store.commit('addNewUsers', [user])
|
||||
return user
|
||||
|
|
@ -413,7 +412,7 @@ const users = {
|
|||
fetchUserByName(store, name) {
|
||||
return fetchUserByName({
|
||||
name,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((user) => {
|
||||
store.commit('addNewUsers', [user])
|
||||
return user
|
||||
|
|
@ -423,7 +422,7 @@ const users = {
|
|||
if (store.state.currentUser) {
|
||||
fetchUserRelationship({
|
||||
id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((relationships) =>
|
||||
store.commit('updateUserRelationship', relationships),
|
||||
)
|
||||
|
|
@ -433,7 +432,7 @@ const users = {
|
|||
if (store.state.currentUser) {
|
||||
fetchUserInLists({
|
||||
id,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((inLists) => store.commit('updateUserInLists', { id, inLists }))
|
||||
}
|
||||
},
|
||||
|
|
@ -443,7 +442,7 @@ const users = {
|
|||
const maxId = store.state.currentUser.blockIdsMaxId
|
||||
return fetchBlocks({
|
||||
maxId,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((blocks) => {
|
||||
if (reset) {
|
||||
store.commit('saveBlockIds', map(blocks, 'id'))
|
||||
|
|
@ -481,7 +480,7 @@ const users = {
|
|||
const maxId = store.state.currentUser.muteIdsMaxId
|
||||
return fetchMutes({
|
||||
maxId,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((mutes) => {
|
||||
if (reset) {
|
||||
store.commit('saveMuteIds', map(mutes, 'id'))
|
||||
|
|
@ -515,7 +514,7 @@ const users = {
|
|||
},
|
||||
fetchDomainMutes(store) {
|
||||
return fetchDomainMutes({
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((domainMutes) => {
|
||||
store.commit('saveDomainMutes', domainMutes)
|
||||
return domainMutes
|
||||
|
|
@ -539,7 +538,7 @@ const users = {
|
|||
return fetchFriends({
|
||||
id,
|
||||
maxId,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((friends) => {
|
||||
commit('addNewUsers', friends)
|
||||
commit('saveFriendIds', { id, friendIds: map(friends, 'id') })
|
||||
|
|
@ -552,7 +551,7 @@ const users = {
|
|||
return fetchFollowers({
|
||||
id,
|
||||
maxId,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((followers) => {
|
||||
commit('addNewUsers', followers)
|
||||
commit('saveFollowerIds', { id, followerIds: map(followers, 'id') })
|
||||
|
|
@ -569,7 +568,7 @@ const users = {
|
|||
return followUser({
|
||||
id,
|
||||
notify: true,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((relationship) =>
|
||||
commit('updateUserRelationship', [relationship]),
|
||||
)
|
||||
|
|
@ -578,7 +577,7 @@ const users = {
|
|||
return followUser({
|
||||
id,
|
||||
notify: false,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((relationship) =>
|
||||
commit('updateUserRelationship', [relationship]),
|
||||
)
|
||||
|
|
@ -644,7 +643,7 @@ const users = {
|
|||
searchUsers({ rootState, commit }, { query }) {
|
||||
return searchUsers({
|
||||
query,
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((users) => {
|
||||
commit('addNewUsers', users)
|
||||
return users
|
||||
|
|
@ -679,7 +678,7 @@ const users = {
|
|||
},
|
||||
getCaptcha(store) {
|
||||
return getCaptcha({
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
},
|
||||
|
||||
|
|
@ -704,7 +703,6 @@ const users = {
|
|||
store.dispatch('disconnectFromSocket')
|
||||
oauth.clearToken()
|
||||
store.dispatch('stopFetchingTimeline', 'friends')
|
||||
useCredentialsStore().setCredentials(null)
|
||||
store.dispatch('stopFetchingNotifications')
|
||||
useListsStore().stopFetching()
|
||||
useBookmarkFoldersStore().stopFetching()
|
||||
|
|
@ -721,9 +719,11 @@ const users = {
|
|||
return new Promise((resolve, reject) => {
|
||||
const commit = store.commit
|
||||
const dispatch = store.dispatch
|
||||
|
||||
commit('beginLogin')
|
||||
|
||||
verifyCredentials({
|
||||
credentials: useCredentialsStore().current,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
.then((data) => {
|
||||
if (!data.error) {
|
||||
|
|
@ -753,9 +753,6 @@ const users = {
|
|||
useInterfaceStore().setNotificationPermission(permission),
|
||||
)
|
||||
|
||||
// Update credentials
|
||||
useCredentialsStore().setCredentials(accessToken)
|
||||
|
||||
// Do server-side storage migrations
|
||||
|
||||
// Debug snippet to clean up storage and reset migrations
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue