migration
This commit is contained in:
parent
32b9c4a14d
commit
7d4ced15c6
90 changed files with 311 additions and 1165 deletions
|
|
@ -21,6 +21,7 @@ import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.j
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useShoutStore } from 'src/stores/shout.js'
|
import { useShoutStore } from 'src/stores/shout.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
// Helper to unwrap reactive proxies
|
// Helper to unwrap reactive proxies
|
||||||
window.toValue = (x) => JSON.parse(JSON.stringify(x))
|
window.toValue = (x) => JSON.parse(JSON.stringify(x))
|
||||||
|
|
@ -153,9 +154,6 @@ export default {
|
||||||
...(navbarColumnStretch ? ['-column-stretch'] : []),
|
...(navbarColumnStretch ? ['-column-stretch'] : []),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
currentUser() {
|
|
||||||
return this.$store.state.users.currentUser
|
|
||||||
},
|
|
||||||
userBackground() {
|
userBackground() {
|
||||||
return this.currentUser.background_image
|
return this.currentUser.background_image
|
||||||
},
|
},
|
||||||
|
|
@ -246,6 +244,7 @@ export default {
|
||||||
'styleDataUsed',
|
'styleDataUsed',
|
||||||
'layoutType',
|
'layoutType',
|
||||||
]),
|
]),
|
||||||
|
...mapState(useUsersStore, ['currentUser']),
|
||||||
...mapState(useInstanceStore, ['styleDataUsed']),
|
...mapState(useInstanceStore, ['styleDataUsed']),
|
||||||
...mapState(useInstanceCapabilitiesStore, [
|
...mapState(useInstanceCapabilitiesStore, [
|
||||||
'suggestionsEnabled',
|
'suggestionsEnabled',
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
class="column -scrollable"
|
class="column -scrollable"
|
||||||
:class="{ '-show-scrollbar': showScrollbars }"
|
:class="{ '-show-scrollbar': showScrollbars }"
|
||||||
>
|
>
|
||||||
<user-panel />
|
<UserPanel />
|
||||||
<template v-if="layoutType !== 'mobile'">
|
<template v-if="layoutType !== 'mobile'">
|
||||||
<NavPanel />
|
<NavPanel />
|
||||||
<InstanceSpecificPanel v-if="showInstanceSpecificPanel" />
|
<InstanceSpecificPanel v-if="showInstanceSpecificPanel" />
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
import { useUserHighlightStore } from 'src/stores/user_highlight.js'
|
import { useUserHighlightStore } from 'src/stores/user_highlight.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import VBodyScrollLock from 'src/directives/body_scroll_lock'
|
import VBodyScrollLock from 'src/directives/body_scroll_lock'
|
||||||
import {
|
import {
|
||||||
|
|
@ -454,7 +455,7 @@ const setConfig = async ({ store }) => {
|
||||||
const checkOAuthToken = async ({ store }) => {
|
const checkOAuthToken = async ({ store }) => {
|
||||||
const oauth = useOAuthStore()
|
const oauth = useOAuthStore()
|
||||||
if (oauth.userToken) {
|
if (oauth.userToken) {
|
||||||
return store.dispatch('loginUser', oauth.userToken)
|
return useUsersStore().loginUser(oauth.userToken)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,11 @@ import TagTimeline from 'src/components/tag_timeline/tag_timeline.vue'
|
||||||
|
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
export default (store) => {
|
export default (store) => {
|
||||||
const validateAuthenticatedRoute = (to, from, next) => {
|
const validateAuthenticatedRoute = (to, from, next) => {
|
||||||
if (store.state.users.currentUser) {
|
if (useUsersStore().currentUser) {
|
||||||
next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
next(
|
next(
|
||||||
|
|
@ -31,7 +32,7 @@ export default (store) => {
|
||||||
path: '/',
|
path: '/',
|
||||||
redirect: () => {
|
redirect: () => {
|
||||||
return (
|
return (
|
||||||
(store.state.users.currentUser
|
(useUsersStore().currentUser
|
||||||
? useInstanceStore().instanceIdentity.redirectRootLogin
|
? useInstanceStore().instanceIdentity.redirectRootLogin
|
||||||
: useInstanceStore().instanceIdentity.redirectRootNoLogin) ||
|
: useInstanceStore().instanceIdentity.redirectRootNoLogin) ||
|
||||||
'/main/all'
|
'/main/all'
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import UserListMenu from 'src/components/user_list_menu/user_list_menu.vue'
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useReportsStore } from 'src/stores/reports'
|
import { useReportsStore } from 'src/stores/reports'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faEllipsisV } from '@fortawesome/free-solid-svg-icons'
|
import { faEllipsisV } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
@ -88,7 +89,7 @@ const AccountActions = {
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: 'chat',
|
name: 'chat',
|
||||||
params: {
|
params: {
|
||||||
username: this.$store.state.users.currentUser.screen_name,
|
username: useUsersStore().currentUser.screen_name,
|
||||||
recipient_id: this.user.id,
|
recipient_id: this.user.id,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'pinia'
|
||||||
|
|
||||||
import AnnouncementEditor from 'src/components/announcement_editor/announcement_editor.vue'
|
import AnnouncementEditor from 'src/components/announcement_editor/announcement_editor.vue'
|
||||||
import localeService from '../../services/locale/locale.service.js'
|
import localeService from '../../services/locale/locale.service.js'
|
||||||
|
|
||||||
import { useAnnouncementsStore } from 'src/stores/announcements.js'
|
import { useAnnouncementsStore } from 'src/stores/announcements.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const Announcement = {
|
const Announcement = {
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -25,9 +26,7 @@ const Announcement = {
|
||||||
announcement: Object,
|
announcement: Object,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState(useUsersStore, ['currentUser']),
|
||||||
currentUser: (state) => state.users.currentUser,
|
|
||||||
}),
|
|
||||||
canEditAnnouncement() {
|
canEditAnnouncement() {
|
||||||
return this.currentUser?.privileges.has(
|
return this.currentUser?.privileges.has(
|
||||||
'announcements_manage_announcements',
|
'announcements_manage_announcements',
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'pinia'
|
||||||
|
|
||||||
import Announcement from 'src/components/announcement/announcement.vue'
|
import Announcement from 'src/components/announcement/announcement.vue'
|
||||||
import AnnouncementEditor from 'src/components/announcement_editor/announcement_editor.vue'
|
import AnnouncementEditor from 'src/components/announcement_editor/announcement_editor.vue'
|
||||||
|
|
||||||
import { useAnnouncementsStore } from 'src/stores/announcements.js'
|
import { useAnnouncementsStore } from 'src/stores/announcements.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const AnnouncementsPage = {
|
const AnnouncementsPage = {
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -26,9 +27,7 @@ const AnnouncementsPage = {
|
||||||
useAnnouncementsStore().fetchAnnouncements()
|
useAnnouncementsStore().fetchAnnouncements()
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState(useUsersStore, ['currentUser']),
|
||||||
currentUser: (state) => state.users.currentUser,
|
|
||||||
}),
|
|
||||||
announcements() {
|
announcements() {
|
||||||
return useAnnouncementsStore().announcements
|
return useAnnouncementsStore().announcements
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,16 @@ import BasicUserCard from 'src/components/basic_user_card/basic_user_card.vue'
|
||||||
import UserTimedFilterModal from 'src/components/user_timed_filter_modal/user_timed_filter_modal.vue'
|
import UserTimedFilterModal from 'src/components/user_timed_filter_modal/user_timed_filter_modal.vue'
|
||||||
|
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const BlockCard = {
|
const BlockCard = {
|
||||||
props: ['userId'],
|
props: ['userId'],
|
||||||
computed: {
|
computed: {
|
||||||
user() {
|
user() {
|
||||||
return this.$store.getters.findUser(this.userId)
|
return useUsersStore().findUser(this.userId)
|
||||||
},
|
},
|
||||||
relationship() {
|
relationship() {
|
||||||
return this.$store.getters.relationship(this.userId)
|
return useUsersStore().relationship(this.userId)
|
||||||
},
|
},
|
||||||
blocked() {
|
blocked() {
|
||||||
return this.relationship.blocking
|
return this.relationship.blocking
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { mapState as mapPiniaState } from 'pinia'
|
import { mapState } from 'pinia'
|
||||||
import { mapState } from 'vuex'
|
|
||||||
|
|
||||||
import ChatListItem from 'src/components/chat_list_item/chat_list_item.vue'
|
import ChatListItem from 'src/components/chat_list_item/chat_list_item.vue'
|
||||||
import ChatNew from 'src/components/chat_new/chat_new.vue'
|
import ChatNew from 'src/components/chat_new/chat_new.vue'
|
||||||
import List from 'src/components/list/list.vue'
|
import List from 'src/components/list/list.vue'
|
||||||
|
|
||||||
import { useChatsStore } from 'src/stores/chats.js'
|
import { useChatsStore } from 'src/stores/chats.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const ChatList = {
|
const ChatList = {
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -14,10 +14,8 @@ const ChatList = {
|
||||||
ChatNew,
|
ChatNew,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState(useUsersStore, ['currentUser']),
|
||||||
currentUser: (state) => state.users.currentUser,
|
...mapState(useChatsStore, ['sortedChatList']),
|
||||||
}),
|
|
||||||
...mapPiniaState(useChatsStore, ['sortedChatList']),
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'pinia'
|
||||||
|
|
||||||
import AvatarList from 'src/components/avatar_list/avatar_list.vue'
|
import AvatarList from 'src/components/avatar_list/avatar_list.vue'
|
||||||
import ChatTitle from 'src/components/chat_title/chat_title.vue'
|
import ChatTitle from 'src/components/chat_title/chat_title.vue'
|
||||||
|
|
@ -6,6 +6,8 @@ import StatusBody from 'src/components/status_content/status_content.vue'
|
||||||
import Timeago from 'src/components/timeago/timeago.vue'
|
import Timeago from 'src/components/timeago/timeago.vue'
|
||||||
import UserAvatar from 'src/components/user_avatar/user_avatar.vue'
|
import UserAvatar from 'src/components/user_avatar/user_avatar.vue'
|
||||||
|
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const ChatListItem = {
|
const ChatListItem = {
|
||||||
name: 'ChatListItem',
|
name: 'ChatListItem',
|
||||||
props: ['chat'],
|
props: ['chat'],
|
||||||
|
|
@ -17,9 +19,7 @@ const ChatListItem = {
|
||||||
StatusBody,
|
StatusBody,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState(useUsersStore, ['currentUser']),
|
||||||
currentUser: (state) => state.users.currentUser,
|
|
||||||
}),
|
|
||||||
attachmentInfo() {
|
attachmentInfo() {
|
||||||
if (this.chat.lastMessage.attachments.length === 0) {
|
if (this.chat.lastMessage.attachments.length === 0) {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { mapState as mapPiniaState } from 'pinia'
|
import { mapState } from 'pinia'
|
||||||
import { defineAsyncComponent } from 'vue'
|
import { defineAsyncComponent } from 'vue'
|
||||||
import { mapState } from 'vuex'
|
|
||||||
|
|
||||||
import Attachment from 'src/components/attachment/attachment.vue'
|
import Attachment from 'src/components/attachment/attachment.vue'
|
||||||
import ChatMessageDate from 'src/components/chat_message_date/chat_message_date.vue'
|
import ChatMessageDate from 'src/components/chat_message_date/chat_message_date.vue'
|
||||||
|
|
@ -20,6 +19,7 @@ import UserPopover from 'src/components/user_popover/user_popover.vue'
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useInterfaceStore } from 'src/stores/interface'
|
import { useInterfaceStore } from 'src/stores/interface'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
@ -79,7 +79,7 @@ const ChatMessage = {
|
||||||
return this.isStatus ? this.message.user.id : this.message.account_id
|
return this.isStatus ? this.message.user.id : this.message.account_id
|
||||||
},
|
},
|
||||||
author() {
|
author() {
|
||||||
return this.$store.getters.findUser(this.authorId)
|
return useUsersStore().findUser(this.authorId)
|
||||||
},
|
},
|
||||||
isCurrentUser() {
|
isCurrentUser() {
|
||||||
// mini-hack/optimizaiton:
|
// mini-hack/optimizaiton:
|
||||||
|
|
@ -108,17 +108,13 @@ const ChatMessage = {
|
||||||
if (this.message.in_reply_to_screen_name) {
|
if (this.message.in_reply_to_screen_name) {
|
||||||
return this.message.in_reply_to_screen_name
|
return this.message.in_reply_to_screen_name
|
||||||
} else {
|
} else {
|
||||||
const user = this.$store.getters.findUser(
|
const user = useUsersStore().findUser(this.message.in_reply_to_user_id)
|
||||||
this.message.in_reply_to_user_id,
|
|
||||||
)
|
|
||||||
return user?.screen_name_ui
|
return user?.screen_name_ui
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
replyProfileLink() {
|
replyProfileLink() {
|
||||||
if (this.isCustomReply) {
|
if (this.isCustomReply) {
|
||||||
const user = this.$store.getters.findUser(
|
const user = useUsersStore().findUser(this.message.in_reply_to_user_id)
|
||||||
this.message.in_reply_to_user_id,
|
|
||||||
)
|
|
||||||
// FIXME Why user not found sometimes???
|
// FIXME Why user not found sometimes???
|
||||||
return user ? user.statusnet_profile_url : 'NOT_FOUND'
|
return user ? user.statusnet_profile_url : 'NOT_FOUND'
|
||||||
}
|
}
|
||||||
|
|
@ -167,14 +163,12 @@ const ChatMessage = {
|
||||||
},
|
},
|
||||||
|
|
||||||
// Global stuff
|
// Global stuff
|
||||||
...mapPiniaState(useInterfaceStore, {
|
...mapState(useInterfaceStore, {
|
||||||
betterShadow: (store) => store.browserSupport.cssFilter,
|
betterShadow: (store) => store.browserSupport.cssFilter,
|
||||||
}),
|
}),
|
||||||
...mapState({
|
...mapState(useUsersStore, ['currentUser']),
|
||||||
currentUser: (state) => state.users.currentUser,
|
...mapState(useInstanceStore, ['restrictedNicknames']),
|
||||||
restrictedNicknames: (state) => useInstanceStore().restrictedNicknames,
|
...mapState(useMergedConfigStore, ['mergedConfig']),
|
||||||
}),
|
|
||||||
...mapPiniaState(useMergedConfigStore, ['mergedConfig']),
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
import { mapGetters, mapState } from 'vuex'
|
import { mapState } from 'pinia'
|
||||||
|
|
||||||
import BasicUserCard from 'src/components/basic_user_card/basic_user_card.vue'
|
import BasicUserCard from 'src/components/basic_user_card/basic_user_card.vue'
|
||||||
import UserAvatar from 'src/components/user_avatar/user_avatar.vue'
|
import UserAvatar from 'src/components/user_avatar/user_avatar.vue'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { chats } from 'src/api/chats.js'
|
import { chats } from 'src/api/chats.js'
|
||||||
|
|
||||||
|
|
@ -42,10 +43,7 @@ const chatNew = {
|
||||||
return this.suggestions
|
return this.suggestions
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
...mapState({
|
...mapState(useUsersStore, ['currentUser', 'findUser']),
|
||||||
currentUser: (state) => state.users.currentUser,
|
|
||||||
}),
|
|
||||||
...mapGetters(['findUser']),
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
goBack() {
|
goBack() {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import { useChatsStore } from 'src/stores/chats.js'
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
chatMessages,
|
chatMessages,
|
||||||
|
|
@ -164,9 +165,9 @@ const Chat = {
|
||||||
mobileLayout: (store) => store.layoutType === 'mobile',
|
mobileLayout: (store) => store.layoutType === 'mobile',
|
||||||
}),
|
}),
|
||||||
...mapPiniaState(useMergedConfigStore, ['mergedConfig']),
|
...mapPiniaState(useMergedConfigStore, ['mergedConfig']),
|
||||||
|
...mapPiniaState(useUsersStore, ['currentUser']),
|
||||||
...mapState({
|
...mapState({
|
||||||
mastoUserSocketStatus: (state) => state.api.mastoUserSocketStatus,
|
mastoUserSocketStatus: (state) => state.api.mastoUserSocketStatus,
|
||||||
currentUser: (state) => state.users.currentUser,
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
@ -374,7 +375,7 @@ const Chat = {
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
this.$store.commit('addNewUsers', [data.account])
|
this.$store.commit('addNewUsers', [data.account])
|
||||||
data.account = this.$store.getters.findUser(data.account.id)
|
data.account = useUsersStore().findUser(data.account.id)
|
||||||
this.chat = data
|
this.chat = data
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error creating or getting a chat', e)
|
console.error('Error creating or getting a chat', e)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { defineAsyncComponent } from 'vue'
|
||||||
import Select from 'src/components/select/select.vue'
|
import Select from 'src/components/select/select.vue'
|
||||||
|
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['type', 'user', 'status'],
|
props: ['type', 'user', 'status'],
|
||||||
|
|
@ -33,9 +34,7 @@ export default {
|
||||||
return this.status.conversation_muted
|
return this.status.conversation_muted
|
||||||
},
|
},
|
||||||
domainIsMuted() {
|
domainIsMuted() {
|
||||||
return new Set(this.$store.state.users.currentUser.domainMutes).has(
|
return new Set(useUsersStore().currentUser.domainMutes).has(this.domain)
|
||||||
this.domain,
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
shouldConfirm() {
|
shouldConfirm() {
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { defineAsyncComponent } from 'vue'
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useInterfaceStore } from 'src/stores/interface'
|
import { useInterfaceStore } from 'src/stores/interface'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
@ -91,9 +92,7 @@ export default {
|
||||||
sitename: (store) => store.instanceIdentity.name,
|
sitename: (store) => store.instanceIdentity.name,
|
||||||
hideSitename: (store) => store.instanceIdentity.hideSitename,
|
hideSitename: (store) => store.instanceIdentity.hideSitename,
|
||||||
}),
|
}),
|
||||||
currentUser() {
|
...mapState(useUsersStore, ['currentUser']),
|
||||||
return this.$store.state.users.currentUser
|
|
||||||
},
|
|
||||||
shouldConfirmLogout() {
|
shouldConfirmLogout() {
|
||||||
return useMergedConfigStore().mergedConfig.modalOnLogout
|
return useMergedConfigStore().mergedConfig.modalOnLogout
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import ProgressButton from 'src/components/progress_button/progress_button.vue'
|
import ProgressButton from 'src/components/progress_button/progress_button.vue'
|
||||||
|
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const DomainMuteCard = {
|
const DomainMuteCard = {
|
||||||
props: ['domain'],
|
props: ['domain'],
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -7,7 +9,7 @@ const DomainMuteCard = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
user() {
|
user() {
|
||||||
return this.$store.state.users.currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
muted() {
|
muted() {
|
||||||
return this.user.domainMutes.includes(this.domain)
|
return this.user.domainMutes.includes(this.domain)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { defineAsyncComponent } from 'vue'
|
||||||
import Modal from 'src/components/modal/modal.vue'
|
import Modal from 'src/components/modal/modal.vue'
|
||||||
|
|
||||||
import { useEditStatusStore } from 'src/stores/editStatus.js'
|
import { useEditStatusStore } from 'src/stores/editStatus.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const EditStatusModal = {
|
const EditStatusModal = {
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -19,7 +20,7 @@ const EditStatusModal = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isLoggedIn() {
|
isLoggedIn() {
|
||||||
return !!this.$store.state.users.currentUser
|
return !!useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
modalActivated() {
|
modalActivated() {
|
||||||
return useEditStatusStore().modalActivated
|
return useEditStatusStore().modalActivated
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import UserListPopover from 'src/components/user_list_popover/user_list_popover.
|
||||||
|
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faCheck, faMinus, faPlus } from '@fortawesome/free-solid-svg-icons'
|
import { faCheck, faMinus, faPlus } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
@ -40,7 +41,7 @@ const EmojiReactions = {
|
||||||
}, {})
|
}, {})
|
||||||
},
|
},
|
||||||
loggedIn() {
|
loggedIn() {
|
||||||
return !!this.$store.state.users.currentUser
|
return !!useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
remoteInteractionLink() {
|
remoteInteractionLink() {
|
||||||
return useInstanceStore().getRemoteInteractionLink({
|
return useInstanceStore().getRemoteInteractionLink({
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import { useChatsStore } from 'src/stores/chats.js'
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
@ -52,7 +53,7 @@ const ExtraNotifications = {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
currentUser() {
|
currentUser() {
|
||||||
return this.$store.state.users.currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
...mapGetters(['followRequestCount']),
|
...mapGetters(['followRequestCount']),
|
||||||
...mapState(useAnnouncementsStore, {
|
...mapState(useAnnouncementsStore, {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ import FollowButton from 'src/components/follow_button/follow_button.vue'
|
||||||
import RemoteFollow from 'src/components/remote_follow/remote_follow.vue'
|
import RemoteFollow from 'src/components/remote_follow/remote_follow.vue'
|
||||||
import RemoveFollowerButton from 'src/components/remove_follower_button/remove_follower_button.vue'
|
import RemoveFollowerButton from 'src/components/remove_follower_button/remove_follower_button.vue'
|
||||||
|
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const FollowCard = {
|
const FollowCard = {
|
||||||
props: ['user', 'noFollowsYou'],
|
props: ['user', 'noFollowsYou'],
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -13,10 +15,10 @@ const FollowCard = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isMe() {
|
isMe() {
|
||||||
return this.$store.state.users.currentUser.id === this.user.id
|
return useUsersStore().currentUser.id === this.user.id
|
||||||
},
|
},
|
||||||
loggedIn() {
|
loggedIn() {
|
||||||
return this.$store.state.users.currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
relationship() {
|
relationship() {
|
||||||
return this.$store.getters.relationship(this.user.id)
|
return this.$store.getters.relationship(this.user.id)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import Notifications from 'src/components/notifications/notifications.vue'
|
import Notifications from 'src/components/notifications/notifications.vue'
|
||||||
import TabSwitcher from 'src/components/tab_switcher/tab_switcher.jsx'
|
import TabSwitcher from 'src/components/tab_switcher/tab_switcher.jsx'
|
||||||
|
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const tabModeDict = {
|
const tabModeDict = {
|
||||||
mentions: ['mention'],
|
mentions: ['mention'],
|
||||||
statuses: ['status'],
|
statuses: ['status'],
|
||||||
|
|
@ -14,10 +16,9 @@ const tabModeDict = {
|
||||||
const Interactions = {
|
const Interactions = {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
allowFollowingMove:
|
allowFollowingMove: useUsersStore().currentUser.allow_following_move,
|
||||||
this.$store.state.users.currentUser.allow_following_move,
|
|
||||||
filterMode: tabModeDict.mentions,
|
filterMode: tabModeDict.mentions,
|
||||||
canSeeReports: this.$store.state.users.currentUser.privileges.has(
|
canSeeReports: useUsersStore().currentUser.privileges.has(
|
||||||
'reports_manage_reports',
|
'reports_manage_reports',
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { mapState as mapPiniaState } from 'pinia'
|
import { mapState } from 'pinia'
|
||||||
import { mapGetters, mapState } from 'vuex'
|
|
||||||
|
|
||||||
import BasicUserCard from 'src/components/basic_user_card/basic_user_card.vue'
|
import BasicUserCard from 'src/components/basic_user_card/basic_user_card.vue'
|
||||||
import ListsUserSearch from 'src/components/lists_user_search/lists_user_search.vue'
|
import ListsUserSearch from 'src/components/lists_user_search/lists_user_search.vue'
|
||||||
|
|
@ -9,6 +8,7 @@ import UserAvatar from 'src/components/user_avatar/user_avatar.vue'
|
||||||
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useListsStore } from 'src/stores/lists.js'
|
import { useListsStore } from 'src/stores/lists.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faChevronLeft, faSearch } from '@fortawesome/free-solid-svg-icons'
|
import { faChevronLeft, faSearch } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
@ -66,11 +66,8 @@ const ListsNew = {
|
||||||
.map((userId) => this.findUser(userId))
|
.map((userId) => this.findUser(userId))
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
},
|
},
|
||||||
...mapState({
|
...mapState(useUsersStore, ['currentUser', 'findUser']),
|
||||||
currentUser: (state) => state.users.currentUser,
|
...mapState(useListsStore, ['findListTitle', 'findListAccounts']),
|
||||||
}),
|
|
||||||
...mapPiniaState(useListsStore, ['findListTitle', 'findListAccounts']),
|
|
||||||
...mapGetters(['findUser']),
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onInput() {
|
onInput() {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import { mapState as mapPiniaState } from 'pinia'
|
import { mapState } from 'pinia'
|
||||||
import { mapState } from 'vuex'
|
|
||||||
|
|
||||||
import { getListEntries } from 'src/components/navigation/filter.js'
|
import { getListEntries } from 'src/components/navigation/filter.js'
|
||||||
import NavigationEntry from 'src/components/navigation/navigation_entry.vue'
|
import NavigationEntry from 'src/components/navigation/navigation_entry.vue'
|
||||||
|
|
||||||
import { useListsStore } from 'src/stores/lists.js'
|
import { useListsStore } from 'src/stores/lists.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
export const ListsMenuContent = {
|
export const ListsMenuContent = {
|
||||||
props: ['showPin'],
|
props: ['showPin'],
|
||||||
|
|
@ -12,12 +12,10 @@ export const ListsMenuContent = {
|
||||||
NavigationEntry,
|
NavigationEntry,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapPiniaState(useListsStore, {
|
...mapState(useListsStore, {
|
||||||
lists: getListEntries,
|
lists: getListEntries,
|
||||||
}),
|
}),
|
||||||
...mapState({
|
...mapState(useUsersStore, ['currentUser']),
|
||||||
currentUser: (state) => state.users.currentUser,
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { mapState as mapPiniaState } from 'pinia'
|
import { mapState } from 'pinia'
|
||||||
import { mapState } from 'vuex'
|
|
||||||
|
|
||||||
import UnicodeDomainIndicator from 'src/components/unicode_domain_indicator/unicode_domain_indicator.vue'
|
import UnicodeDomainIndicator from 'src/components/unicode_domain_indicator/unicode_domain_indicator.vue'
|
||||||
import UserAvatar from 'src/components/user_avatar/user_avatar.vue'
|
import UserAvatar from 'src/components/user_avatar/user_avatar.vue'
|
||||||
|
|
@ -12,6 +11,7 @@ import {
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useUserHighlightStore } from 'src/stores/user_highlight.js'
|
import { useUserHighlightStore } from 'src/stores/user_highlight.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ const MentionLink = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
user() {
|
user() {
|
||||||
return this.url && this.$store?.getters.findUserByUrl(this.url)
|
return this.url && useUsersStore().findUserByUrl(this.url)
|
||||||
},
|
},
|
||||||
isYou() {
|
isYou() {
|
||||||
// FIXME why user !== currentUser???
|
// FIXME why user !== currentUser???
|
||||||
|
|
@ -156,11 +156,9 @@ const MentionLink = {
|
||||||
shouldFadeDomain() {
|
shouldFadeDomain() {
|
||||||
return this.mergedConfig.mentionLinkFadeDomain
|
return this.mergedConfig.mentionLinkFadeDomain
|
||||||
},
|
},
|
||||||
...mapPiniaState(useMergedConfigStore, ['mergedConfig']),
|
...mapState(useMergedConfigStore, ['mergedConfig']),
|
||||||
...mapPiniaState(useUserHighlightStore, ['highlight']),
|
...mapState(useUserHighlightStore, ['highlight']),
|
||||||
...mapState({
|
...mapState(useUsersStore, ['currentUser']),
|
||||||
currentUser: (state) => state.users.currentUser,
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import { useAnnouncementsStore } from 'src/stores/announcements.js'
|
||||||
import { useChatsStore } from 'src/stores/chats.js'
|
import { useChatsStore } from 'src/stores/chats.js'
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
@ -53,7 +54,7 @@ const MobileNav = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
currentUser() {
|
currentUser() {
|
||||||
return this.$store.state.users.currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
unseenNotifications() {
|
unseenNotifications() {
|
||||||
return unseenNotificationsFromStore(
|
return unseenNotificationsFromStore(
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { debounce } from 'lodash'
|
||||||
|
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { usePostStatusStore } from 'src/stores/post_status.js'
|
import { usePostStatusStore } from 'src/stores/post_status.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faPen } from '@fortawesome/free-solid-svg-icons'
|
import { faPen } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
@ -34,7 +35,7 @@ const MobilePostStatusButton = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isLoggedIn() {
|
isLoggedIn() {
|
||||||
return !!this.$store.state.users.currentUser
|
return useUsersStore().loggedIn
|
||||||
},
|
},
|
||||||
isHidden() {
|
isHidden() {
|
||||||
if (HIDDEN_FOR_PAGES.has(this.$route.name)) {
|
if (HIDDEN_FOR_PAGES.has(this.$route.name)) {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import Popover from 'src/components/popover/popover.vue'
|
||||||
|
|
||||||
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
|
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faChevronDown } from '@fortawesome/free-solid-svg-icons'
|
import { faChevronDown } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
@ -405,7 +406,7 @@ const ModerationTools = {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
isAdmin() {
|
isAdmin() {
|
||||||
return this.$store.state.users.currentUser.role === 'admin'
|
return useUsersStore().currentUser.role === 'admin'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -452,7 +453,7 @@ const ModerationTools = {
|
||||||
},
|
},
|
||||||
privileged(privilege) {
|
privileged(privilege) {
|
||||||
if (this.isAdmin) return true
|
if (this.isAdmin) return true
|
||||||
return this.$store.state.users.currentUser.privileges.has(privilege)
|
return useUsersStore().currentUser.privileges.has(privilege)
|
||||||
},
|
},
|
||||||
setTag(tag, value) {
|
setTag(tag, value) {
|
||||||
useAdminSettingsStore().setUsersTags({
|
useAdminSettingsStore().setUsersTags({
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
import BasicUserCard from 'src/components/basic_user_card/basic_user_card.vue'
|
import BasicUserCard from 'src/components/basic_user_card/basic_user_card.vue'
|
||||||
import UserTimedFilterModal from 'src/components/user_timed_filter_modal/user_timed_filter_modal.vue'
|
import UserTimedFilterModal from 'src/components/user_timed_filter_modal/user_timed_filter_modal.vue'
|
||||||
|
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const MuteCard = {
|
const MuteCard = {
|
||||||
props: ['userId'],
|
props: ['userId'],
|
||||||
computed: {
|
computed: {
|
||||||
user() {
|
user() {
|
||||||
return this.$store.getters.findUser(this.userId)
|
return useUsersStore().findUser(this.userId)
|
||||||
},
|
},
|
||||||
relationship() {
|
relationship() {
|
||||||
return this.$store.getters.relationship(this.userId)
|
return useUsersStore().relationship(this.userId)
|
||||||
},
|
},
|
||||||
muted() {
|
muted() {
|
||||||
return this.relationship.muting
|
return this.relationship.muting
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import { useChatsStore } from 'src/stores/chats.js'
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
@ -128,8 +129,8 @@ const NavPanel = {
|
||||||
pinnedItems: (store) =>
|
pinnedItems: (store) =>
|
||||||
new Set(store.prefsStorage.collections.pinnedNavItems),
|
new Set(store.prefsStorage.collections.pinnedNavItems),
|
||||||
}),
|
}),
|
||||||
|
...mapPiniaState(useUsersStore, ['currentUser']),
|
||||||
...mapState({
|
...mapState({
|
||||||
currentUser: (state) => state.users.currentUser,
|
|
||||||
followRequestCount: (state) => state.api.followRequests.length,
|
followRequestCount: (state) => state.api.followRequests.length,
|
||||||
}),
|
}),
|
||||||
...mapPiniaState(useChatsStore, ['unreadChatsCount']),
|
...mapPiniaState(useChatsStore, ['unreadChatsCount']),
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { mapState as mapPiniaState, mapStores } from 'pinia'
|
import { mapState, mapStores } from 'pinia'
|
||||||
import { mapState } from 'vuex'
|
|
||||||
|
|
||||||
import { routeTo } from 'src/components/navigation/navigation.js'
|
import { routeTo } from 'src/components/navigation/navigation.js'
|
||||||
import OptionalRouterLink from 'src/components/optional_router_link/optional_router_link.vue'
|
import OptionalRouterLink from 'src/components/optional_router_link/optional_router_link.vue'
|
||||||
|
|
||||||
import { useAnnouncementsStore } from 'src/stores/announcements.js'
|
import { useAnnouncementsStore } from 'src/stores/announcements.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faThumbtack } from '@fortawesome/free-solid-svg-icons'
|
import { faThumbtack } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
@ -44,10 +44,8 @@ const NavigationEntry = {
|
||||||
return this.$store.getters
|
return this.$store.getters
|
||||||
},
|
},
|
||||||
...mapStores(useAnnouncementsStore),
|
...mapStores(useAnnouncementsStore),
|
||||||
...mapState({
|
...mapState(useUsersStore, ['currentUser']),
|
||||||
currentUser: (state) => state.users.currentUser,
|
...mapState(useSyncConfigStore, {
|
||||||
}),
|
|
||||||
...mapPiniaState(useSyncConfigStore, {
|
|
||||||
pinnedItems: (store) =>
|
pinnedItems: (store) =>
|
||||||
new Set(store.prefsStorage.collections.pinnedNavItems),
|
new Set(store.prefsStorage.collections.pinnedNavItems),
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
import { useListsStore } from 'src/stores/lists'
|
import { useListsStore } from 'src/stores/lists'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
@ -76,8 +77,8 @@ const NavPanel = {
|
||||||
'pleromaChatMessagesAvailable',
|
'pleromaChatMessagesAvailable',
|
||||||
'localBubble',
|
'localBubble',
|
||||||
]),
|
]),
|
||||||
|
...mapPiniaState(useUsersStore, ['currentUser']),
|
||||||
...mapState({
|
...mapState({
|
||||||
currentUser: (state) => state.users.currentUser,
|
|
||||||
followRequestCount: (state) => state.api.followRequests.length,
|
followRequestCount: (state) => state.api.followRequests.length,
|
||||||
}),
|
}),
|
||||||
pinnedList() {
|
pinnedList() {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
import { mapState } from 'pinia'
|
||||||
import { defineAsyncComponent } from 'vue'
|
import { defineAsyncComponent } from 'vue'
|
||||||
import { mapState } from 'vuex'
|
|
||||||
|
|
||||||
import Report from 'src/components/report/report.vue'
|
import Report from 'src/components/report/report.vue'
|
||||||
import StatusContent from 'src/components/status_content/status_content.vue'
|
import StatusContent from 'src/components/status_content/status_content.vue'
|
||||||
|
|
@ -17,6 +17,7 @@ import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
import { useUserHighlightStore } from 'src/stores/user_highlight.js'
|
import { useUserHighlightStore } from 'src/stores/user_highlight.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { approveUser, denyUser } from 'src/api/user.js'
|
import { approveUser, denyUser } from 'src/api/user.js'
|
||||||
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
||||||
|
|
@ -194,19 +195,19 @@ const Notification = {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
user() {
|
user() {
|
||||||
return this.$store.getters.findUser(this.notification.from_profile.id)
|
return useUsersStore().findUser(this.notification.from_profile.id)
|
||||||
},
|
},
|
||||||
userProfileLink() {
|
userProfileLink() {
|
||||||
return this.generateUserProfileLink(this.user)
|
return this.generateUserProfileLink(this.user)
|
||||||
},
|
},
|
||||||
targetUser() {
|
targetUser() {
|
||||||
return this.$store.getters.findUser(this.notification.target.id)
|
return useUsersStore().findUser(this.notification.target.id)
|
||||||
},
|
},
|
||||||
targetUserProfileLink() {
|
targetUserProfileLink() {
|
||||||
return this.generateUserProfileLink(this.targetUser)
|
return this.generateUserProfileLink(this.targetUser)
|
||||||
},
|
},
|
||||||
needMute() {
|
needMute() {
|
||||||
return this.$store.getters.relationship(this.user.id).muting
|
return useUsersStore().relationship(this.user.id).muting
|
||||||
},
|
},
|
||||||
isStatusNotification() {
|
isStatusNotification() {
|
||||||
return isStatusNotification(this.notification.type)
|
return isStatusNotification(this.notification.type)
|
||||||
|
|
@ -229,9 +230,7 @@ const Notification = {
|
||||||
shouldConfirmDeny() {
|
shouldConfirmDeny() {
|
||||||
return this.mergedConfig.modalOnDenyFollow
|
return this.mergedConfig.modalOnDenyFollow
|
||||||
},
|
},
|
||||||
...mapState({
|
...mapState(useUsersStore, ['currentUser']),
|
||||||
currentUser: (state) => state.users.currentUser,
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import { useAnnouncementsStore } from 'src/stores/announcements.js'
|
||||||
import { useChatsStore } from 'src/stores/chats.js'
|
import { useChatsStore } from 'src/stores/chats.js'
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
@ -251,7 +252,7 @@ const Notifications = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = this.$store
|
const store = this.$store
|
||||||
const credentials = store.state.users.currentUser.credentials
|
const credentials = useUsersStore().currentUser.credentials
|
||||||
store.commit('setNotificationsLoading', { value: true })
|
store.commit('setNotificationsLoading', { value: true })
|
||||||
notificationsFetcher
|
notificationsFetcher
|
||||||
.fetchAndUpdate({
|
.fetchAndUpdate({
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { getToken } from 'src/api/oauth.js'
|
import { getToken } from 'src/api/oauth.js'
|
||||||
|
|
||||||
|
|
@ -17,7 +18,8 @@ const oac = {
|
||||||
code: this.code,
|
code: this.code,
|
||||||
}).then(({ data: result }) => {
|
}).then(({ data: result }) => {
|
||||||
oauthStore.setToken(result.access_token)
|
oauthStore.setToken(result.access_token)
|
||||||
this.$store.dispatch('loginUser', result.access_token)
|
|
||||||
|
useUsersStore().loginUser(result.access_token)
|
||||||
this.$router.push({ name: 'friends' })
|
this.$router.push({ name: 'friends' })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { mapState as mapPiniaState } from 'pinia'
|
import { mapState } from 'pinia'
|
||||||
import { mapState } from 'vuex'
|
|
||||||
|
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { resetPassword } from 'src/api/public.js'
|
import { resetPassword } from 'src/api/public.js'
|
||||||
|
|
||||||
|
|
@ -21,13 +21,11 @@ const passwordReset = {
|
||||||
error: null,
|
error: null,
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState(useUsersStore, ['loggedIn']),
|
||||||
signedIn: (state) => !!state.users.currentUser,
|
...mapState(useInstanceStore, ['mailerEnabled']),
|
||||||
}),
|
|
||||||
...mapPiniaState(useInstanceStore, ['mailerEnabled']),
|
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.signedIn) {
|
if (this.loggedIn) {
|
||||||
this.$router.push({ name: 'root' })
|
this.$router.push({ name: 'root' })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import genRandomSeed from '../../services/random_seed/random_seed.service.js'
|
||||||
|
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { usePollsStore } from 'src/stores/polls.js'
|
import { usePollsStore } from 'src/stores/polls.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Poll',
|
name: 'Poll',
|
||||||
|
|
@ -64,7 +65,7 @@ export default {
|
||||||
return useMergedConfigStore().mergedConfig.scaleMfm
|
return useMergedConfigStore().mergedConfig.scaleMfm
|
||||||
},
|
},
|
||||||
loggedIn() {
|
loggedIn() {
|
||||||
return this.$store.state.users.currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
showResults() {
|
showResults() {
|
||||||
return this.poll.voted || this.expired || !this.loggedIn
|
return this.poll.voted || this.expired || !this.loggedIn
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useMediaViewerStore } from 'src/stores/media_viewer.js'
|
import { useMediaViewerStore } from 'src/stores/media_viewer.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { pollFormToMasto } from 'src/services/poll/poll.service.js'
|
import { pollFormToMasto } from 'src/services/poll/poll.service.js'
|
||||||
|
|
||||||
|
|
@ -571,7 +572,7 @@ const PostStatusForm = {
|
||||||
|
|
||||||
// Global stuff
|
// Global stuff
|
||||||
currentUser() {
|
currentUser() {
|
||||||
return this.$store.state.users.currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
...mapState(useMergedConfigStore, ['mergedConfig']),
|
...mapState(useMergedConfigStore, ['mergedConfig']),
|
||||||
...mapState(useInterfaceStore, {
|
...mapState(useInterfaceStore, {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import Modal from 'src/components/modal/modal.vue'
|
||||||
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
|
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
|
||||||
|
|
||||||
import { usePostStatusStore } from 'src/stores/post_status.js'
|
import { usePostStatusStore } from 'src/stores/post_status.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const PostStatusModal = {
|
const PostStatusModal = {
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -17,7 +18,7 @@ const PostStatusModal = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isLoggedIn() {
|
isLoggedIn() {
|
||||||
return !!this.$store.state.users.currentUser
|
return !!useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
modalActivated() {
|
modalActivated() {
|
||||||
return usePostStatusStore().modalActivated
|
return usePostStatusStore().modalActivated
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faFilter, faFont, faWrench } from '@fortawesome/free-solid-svg-icons'
|
import { faFilter, faFont, faWrench } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
@ -54,7 +55,7 @@ const QuickFilterSettings = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loggedIn() {
|
loggedIn() {
|
||||||
return !!this.$store.state.users.currentUser
|
return !!useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
replyVisibilitySelf: {
|
replyVisibilitySelf: {
|
||||||
get() {
|
get() {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import QuickFilterSettings from 'src/components/quick_filter_settings/quick_filt
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
@ -36,7 +37,7 @@ const QuickViewSettings = {
|
||||||
mobileLayout: (state) => state.layoutType === 'mobile',
|
mobileLayout: (state) => state.layoutType === 'mobile',
|
||||||
}),
|
}),
|
||||||
loggedIn() {
|
loggedIn() {
|
||||||
return !!this.$store.state.users.currentUser
|
return !!useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
conversationDisplay: {
|
conversationDisplay: {
|
||||||
get() {
|
get() {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import Conversation from 'src/components/conversation/conversation.vue'
|
||||||
import FollowCard from 'src/components/follow_card/follow_card.vue'
|
import FollowCard from 'src/components/follow_card/follow_card.vue'
|
||||||
import TabSwitcher from 'src/components/tab_switcher/tab_switcher.jsx'
|
import TabSwitcher from 'src/components/tab_switcher/tab_switcher.jsx'
|
||||||
|
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faCircleNotch, faSearch } from '@fortawesome/free-solid-svg-icons'
|
import { faCircleNotch, faSearch } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
||||||
|
|
@ -34,7 +36,7 @@ const Search = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
users() {
|
users() {
|
||||||
return this.userIds.map((userId) => this.$store.getters.findUser(userId))
|
return this.userIds.map((userId) => useUsersStore().findUser(userId))
|
||||||
},
|
},
|
||||||
visibleStatuses() {
|
visibleStatuses() {
|
||||||
const allStatusesObject = this.$store.state.statuses.allStatusesObject
|
const allStatusesObject = this.$store.state.statuses.allStatusesObject
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import BasicUserCard from 'src/components/basic_user_card/basic_user_card.vue'
|
import BasicUserCard from 'src/components/basic_user_card/basic_user_card.vue'
|
||||||
import ModerationTools from 'src/components/moderation_tools/moderation_tools.vue'
|
import ModerationTools from 'src/components/moderation_tools/moderation_tools.vue'
|
||||||
|
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const AdminUserCard = {
|
const AdminUserCard = {
|
||||||
props: {
|
props: {
|
||||||
userId: {
|
userId: {
|
||||||
|
|
@ -13,7 +15,7 @@ const AdminUserCard = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
user() {
|
user() {
|
||||||
return this.$store.getters.findUser(this.userId)
|
return useUsersStore().findUser(this.userId)
|
||||||
},
|
},
|
||||||
isAdmin() {
|
isAdmin() {
|
||||||
return this.user.rights.admin
|
return this.user.rights.admin
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
import { mapState as mapPiniaState } from 'pinia'
|
import { mapState } from 'pinia'
|
||||||
import { mapState } from 'vuex'
|
|
||||||
|
|
||||||
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
|
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const SharedComputedObject = () => ({
|
const SharedComputedObject = () => ({
|
||||||
...mapPiniaState(useMergedConfigStore, ['mergedConfig']),
|
...mapState(useMergedConfigStore, ['mergedConfig']),
|
||||||
...mapPiniaState(useMergedConfigStore, {
|
...mapState(useMergedConfigStore, {
|
||||||
expertLevel: (store) => store.mergedConfig.expertLevel,
|
expertLevel: (store) => store.mergedConfig.expertLevel,
|
||||||
}),
|
}),
|
||||||
...mapPiniaState(useAdminSettingsStore, {
|
...mapState(useAdminSettingsStore, {
|
||||||
adminConfig: (store) => store.config,
|
adminConfig: (store) => store.config,
|
||||||
adminDraft: (store) => store.draft,
|
adminDraft: (store) => store.draft,
|
||||||
}),
|
}),
|
||||||
...mapState({
|
...mapState(useUsersStore, {
|
||||||
user: (state) => state.users.currentUser,
|
user: (store) => store.currentUser,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import VerticalTabSwitcher from './helpers/vertical_tab_switcher.jsx'
|
||||||
|
|
||||||
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
|
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
@ -97,10 +98,10 @@ const SettingsModalAdminContent = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
user() {
|
user() {
|
||||||
return this.$store.state.users.currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
isLoggedIn() {
|
isLoggedIn() {
|
||||||
return !!this.$store.state.users.currentUser
|
return !!useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
open() {
|
open() {
|
||||||
return useInterfaceStore().settingsModalState !== 'hidden'
|
return useInterfaceStore().settingsModalState !== 'hidden'
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import StyleTab from './tabs/style_tab/style_tab.vue'
|
||||||
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
@ -75,7 +76,7 @@ const SettingsModalContent = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isLoggedIn() {
|
isLoggedIn() {
|
||||||
return !!this.$store.state.users.currentUser
|
return !!useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
open() {
|
open() {
|
||||||
return useInterfaceStore().settingsModalState !== 'hidden'
|
return useInterfaceStore().settingsModalState !== 'hidden'
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import Preview from './old_theme_tab/theme_preview.vue'
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { normalizeThemeData, useInterfaceStore } from 'src/stores/interface.js'
|
import { normalizeThemeData, useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { updateProfileImages } from 'src/api/user.js'
|
import { updateProfileImages } from 'src/api/user.js'
|
||||||
import { newImporter } from 'src/services/export_import/export_import.js'
|
import { newImporter } from 'src/services/export_import/export_import.js'
|
||||||
|
|
@ -220,7 +221,7 @@ const AppearanceTab = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isDefaultBackground() {
|
isDefaultBackground() {
|
||||||
return !this.$store.state.users.currentUser.background_image
|
return !useUsersStore().currentUser.background_image
|
||||||
},
|
},
|
||||||
switchInProgress() {
|
switchInProgress() {
|
||||||
return useInterfaceStore().themeChangeInProgress
|
return useInterfaceStore().themeChangeInProgress
|
||||||
|
|
@ -282,7 +283,7 @@ const AppearanceTab = {
|
||||||
instanceWallpaperUsed() {
|
instanceWallpaperUsed() {
|
||||||
return (
|
return (
|
||||||
useInstanceStore().instanceIdentity.background &&
|
useInstanceStore().instanceIdentity.background &&
|
||||||
!this.$store.state.users.currentUser.background_image
|
!useUsersStore().currentUser.background_image
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
customThemeVersion() {
|
customThemeVersion() {
|
||||||
|
|
@ -490,9 +491,8 @@ const AppearanceTab = {
|
||||||
background,
|
background,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
.then(({ data }) => {
|
.then((result) => {
|
||||||
this.$store.commit('addNewUsers', [data])
|
useUsersStore().addNewUsers(result)
|
||||||
this.$store.commit('setCurrentUser', data)
|
|
||||||
this.backgroundPreview = null
|
this.backgroundPreview = null
|
||||||
this.backgroundError = null
|
this.backgroundError = null
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.j
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { updateProfile } from 'src/api/user.js'
|
import { updateProfile } from 'src/api/user.js'
|
||||||
import localeService from 'src/services/locale/locale.service.js'
|
import localeService from 'src/services/locale/locale.service.js'
|
||||||
|
|
@ -92,7 +93,7 @@ const ComposingTab = {
|
||||||
HTMLMediaElement.prototype,
|
HTMLMediaElement.prototype,
|
||||||
'audioTracks',
|
'audioTracks',
|
||||||
),
|
),
|
||||||
emailLanguage: this.$store.state.users.currentUser.language || [''],
|
emailLanguage: useUsersStore().currentUser.language || [''],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -169,9 +170,8 @@ const ComposingTab = {
|
||||||
updateProfile({
|
updateProfile({
|
||||||
params,
|
params,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then(({ data: user }) => {
|
}).then((result) => {
|
||||||
this.$store.commit('addNewUsers', [user])
|
useUsersStore().addNewUsers(result)
|
||||||
this.$store.commit('setCurrentUser', user)
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateFont(key, value) {
|
updateFont(key, value) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'pinia'
|
||||||
|
|
||||||
import Checkbox from 'src/components/checkbox/checkbox.vue'
|
import Checkbox from 'src/components/checkbox/checkbox.vue'
|
||||||
import Exporter from 'src/components/exporter/exporter.vue'
|
import Exporter from 'src/components/exporter/exporter.vue'
|
||||||
|
|
@ -6,6 +6,7 @@ import Importer from 'src/components/importer/importer.vue'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
import { useOAuthTokensStore } from 'src/stores/oauth_tokens.js'
|
import { useOAuthTokensStore } from 'src/stores/oauth_tokens.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
addBackup,
|
addBackup,
|
||||||
|
|
@ -39,9 +40,7 @@ const DataImportExportTab = {
|
||||||
Checkbox,
|
Checkbox,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState(useUsersStore, ['currentUser']),
|
||||||
user: (state) => state.users.currentUser,
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getFollowsContent() {
|
getFollowsContent() {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { updateProfile } from 'src/api/user.js'
|
import { updateProfile } from 'src/api/user.js'
|
||||||
import localeService from 'src/services/locale/locale.service.js'
|
import localeService from 'src/services/locale/locale.service.js'
|
||||||
|
|
@ -25,7 +26,7 @@ const GeneralTab = {
|
||||||
value: mode,
|
value: mode,
|
||||||
label: this.$t(`settings.absolute_time_format_12h_${mode}`),
|
label: this.$t(`settings.absolute_time_format_12h_${mode}`),
|
||||||
})),
|
})),
|
||||||
emailLanguage: this.$store.state.users.currentUser.language || [''],
|
emailLanguage: useUsersStore().currentUser.language || [''],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -62,9 +63,8 @@ const GeneralTab = {
|
||||||
updateProfile({
|
updateProfile({
|
||||||
params,
|
params,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then(({ data: user }) => {
|
}).then((result) => {
|
||||||
this.$store.commit('addNewUsers', [user])
|
useUsersStore().addNewUsers(result)
|
||||||
this.$store.commit('setCurrentUser', user)
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateFont(path, value) {
|
updateFont(path, value) {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import TabSwitcher from 'src/components/tab_switcher/tab_switcher.jsx'
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
import { useOAuthTokensStore } from 'src/stores/oauth_tokens.js'
|
import { useOAuthTokensStore } from 'src/stores/oauth_tokens.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { importBlocks, importFollows } from 'src/api/user.js'
|
import { importBlocks, importFollows } from 'src/api/user.js'
|
||||||
|
|
||||||
|
|
@ -40,16 +41,16 @@ const MutesAndBlocks = {
|
||||||
return useInstanceStore().knownDomains
|
return useInstanceStore().knownDomains
|
||||||
},
|
},
|
||||||
user() {
|
user() {
|
||||||
return this.$store.state.users.currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
blocks() {
|
blocks() {
|
||||||
return get(this.$store.state.users.currentUser, 'blockIds', [])
|
return get(useUsersStore().currentUser, 'blockIds', [])
|
||||||
},
|
},
|
||||||
mutes() {
|
mutes() {
|
||||||
return get(this.$store.state.users.currentUser, 'muteIds', [])
|
return get(useUsersStore().currentUser, 'muteIds', [])
|
||||||
},
|
},
|
||||||
domains() {
|
domains() {
|
||||||
return get(this.$store.state.users.currentUser, 'domainMutes', [])
|
return get(useUsersStore().currentUser, 'domainMutes', [])
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -94,13 +95,13 @@ const MutesAndBlocks = {
|
||||||
},
|
},
|
||||||
filterUnblockedUsers(userIds) {
|
filterUnblockedUsers(userIds) {
|
||||||
return reject(userIds, (userId) => {
|
return reject(userIds, (userId) => {
|
||||||
const relationship = this.$store.getters.relationship(this.userId)
|
const relationship = useUsersStore().relationship(this.userId)
|
||||||
return relationship.blocking || userId === this.user.id
|
return relationship.blocking || userId === this.user.id
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
filterUnMutedUsers(userIds) {
|
filterUnMutedUsers(userIds) {
|
||||||
return reject(userIds, (userId) => {
|
return reject(userIds, (userId) => {
|
||||||
const relationship = this.$store.getters.relationship(this.userId)
|
const relationship = useUsersStore().relationship(this.userId)
|
||||||
return relationship.muting || userId === this.user.id
|
return relationship.muting || userId === this.user.id
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import BooleanSetting from '../helpers/boolean_setting.vue'
|
||||||
import SharedComputedObject from '../helpers/shared_computed_object.js'
|
import SharedComputedObject from '../helpers/shared_computed_object.js'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { updateNotificationSettings } from 'src/api/user.js'
|
import { updateNotificationSettings } from 'src/api/user.js'
|
||||||
|
|
||||||
|
|
@ -9,8 +10,7 @@ const NotificationsTab = {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
activeTab: 'profile',
|
activeTab: 'profile',
|
||||||
notificationSettings:
|
notificationSettings: useUsersStore().currentUser.notification_settings,
|
||||||
this.$store.state.users.currentUser.notification_settings,
|
|
||||||
newDomainToMute: '',
|
newDomainToMute: '',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -19,7 +19,7 @@ const NotificationsTab = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
user() {
|
user() {
|
||||||
return this.$store.state.users.currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
canReceiveReports() {
|
canReceiveReports() {
|
||||||
if (!this.user) {
|
if (!this.user) {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import BooleanSetting from '../helpers/boolean_setting.vue'
|
||||||
import SharedComputedObject from '../helpers/shared_computed_object.js'
|
import SharedComputedObject from '../helpers/shared_computed_object.js'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { updateProfile } from 'src/api/user.js'
|
import { updateProfile } from 'src/api/user.js'
|
||||||
|
|
||||||
|
|
@ -20,7 +21,7 @@ const ProfileTab = {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// Whether user is locked or not
|
// Whether user is locked or not
|
||||||
locked: this.$store.state.users.currentUser.locked,
|
locked: useUsersStore().currentUser.locked,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -30,7 +31,7 @@ const ProfileTab = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
user() {
|
user() {
|
||||||
return this.$store.state.users.currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
...SharedComputedObject(),
|
...SharedComputedObject(),
|
||||||
},
|
},
|
||||||
|
|
@ -43,9 +44,8 @@ const ProfileTab = {
|
||||||
params,
|
params,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
.then(({ data: user }) => {
|
.then((result) => {
|
||||||
this.$store.commit('addNewUsers', [user])
|
useUsersStore().addNewUsers(result)
|
||||||
this.$store.commit('setCurrentUser', user)
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.displayUploadError(error)
|
this.displayUploadError(error)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import Mfa from './mfa.vue'
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
import { useOAuthTokensStore } from 'src/stores/oauth_tokens'
|
import { useOAuthTokensStore } from 'src/stores/oauth_tokens'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
addAlias,
|
addAlias,
|
||||||
|
|
@ -52,7 +53,7 @@ const SecurityTab = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
user() {
|
user() {
|
||||||
return this.$store.state.users.currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
pleromaExtensionsAvailable() {
|
pleromaExtensionsAvailable() {
|
||||||
return useInstanceCapabilitiesStore().pleromaExtensionsAvailable
|
return useInstanceCapabilitiesStore().pleromaExtensionsAvailable
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.j
|
||||||
import { useInterfaceStore } from 'src/stores/interface'
|
import { useInterfaceStore } from 'src/stores/interface'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useShoutStore } from 'src/stores/shout'
|
import { useShoutStore } from 'src/stores/shout'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
@ -70,7 +71,7 @@ const SideDrawer = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
currentUser() {
|
currentUser() {
|
||||||
return this.$store.state.users.currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
shout() {
|
shout() {
|
||||||
return useShoutStore().joined
|
return useShoutStore().joined
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.j
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
import { useUserHighlightStore } from 'src/stores/user_highlight.js'
|
import { useUserHighlightStore } from 'src/stores/user_highlight.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
||||||
|
|
||||||
|
|
@ -309,9 +310,9 @@ const Status = {
|
||||||
if (this.statusoid.user.id === this.currentUser.id) return false
|
if (this.statusoid.user.id === this.currentUser.id) return false
|
||||||
const { status } = this
|
const { status } = this
|
||||||
const { reblog } = status
|
const { reblog } = status
|
||||||
const relationship = this.$store.getters.relationship(status.user.id)
|
const relationship = useUsersStore().relationship(status.user.id)
|
||||||
const relationshipReblog =
|
const relationshipReblog =
|
||||||
reblog && this.$store.getters.relationship(reblog.user.id)
|
reblog && useUsersStore().relationship(reblog.user.id)
|
||||||
return (
|
return (
|
||||||
(status.muted && !status.thread_muted) ||
|
(status.muted && !status.thread_muted) ||
|
||||||
// Reprööt of a muted post according to BE
|
// Reprööt of a muted post according to BE
|
||||||
|
|
@ -411,7 +412,7 @@ const Status = {
|
||||||
return this.mergedConfig.hideBotIndication
|
return this.mergedConfig.hideBotIndication
|
||||||
},
|
},
|
||||||
currentUser() {
|
currentUser() {
|
||||||
return this.$store.state.users.currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
mergedConfig() {
|
mergedConfig() {
|
||||||
return useMergedConfigStore().mergedConfig
|
return useMergedConfigStore().mergedConfig
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import EmojiPicker from '../emoji_picker/emoji_picker.vue'
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
@ -98,7 +99,7 @@ export default {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
userIsMuted() {
|
userIsMuted() {
|
||||||
return this.$store.getters.relationship(this.status.user.id).muting
|
return useUsersStore().relationship(this.status.user.id).muting
|
||||||
},
|
},
|
||||||
threadIsMuted() {
|
threadIsMuted() {
|
||||||
return this.status.thread_muted
|
return this.status.thread_muted
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import Popover from 'src/components/popover/popover.vue'
|
||||||
import ActionButton from './action_button.vue'
|
import ActionButton from './action_button.vue'
|
||||||
|
|
||||||
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
|
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import genRandomSeed from 'src/services/random_seed/random_seed.service.js'
|
import genRandomSeed from 'src/services/random_seed/random_seed.service.js'
|
||||||
|
|
||||||
|
|
@ -71,7 +72,7 @@ export default {
|
||||||
return this.status.user
|
return this.status.user
|
||||||
},
|
},
|
||||||
userIsMuted() {
|
userIsMuted() {
|
||||||
return this.$store.getters.relationship(this.user.id).muting
|
return useUsersStore().relationship(this.user.id).muting
|
||||||
},
|
},
|
||||||
conversationIsMuted() {
|
conversationIsMuted() {
|
||||||
return this.status.thread_muted
|
return this.status.thread_muted
|
||||||
|
|
@ -80,9 +81,7 @@ export default {
|
||||||
return this.user.fqn.split('@')[1]
|
return this.user.fqn.split('@')[1]
|
||||||
},
|
},
|
||||||
domainIsMuted() {
|
domainIsMuted() {
|
||||||
return new Set(this.$store.state.users.currentUser.domainMutes).has(
|
return new Set(useUsersStore().currentUser.domainMutes).has(this.domain)
|
||||||
this.domain,
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
availableScopes() {
|
availableScopes() {
|
||||||
return ['private', 'unlisted', 'direct', 'public'].filter((scope) => {
|
return ['private', 'unlisted', 'direct', 'public'].filter((scope) => {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import ActionButtonContainer from './action_button_container.vue'
|
||||||
import { BUTTONS } from './buttons_definitions.js'
|
import { BUTTONS } from './buttons_definitions.js'
|
||||||
|
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import genRandomSeed from 'src/services/random_seed/random_seed.service.js'
|
import genRandomSeed from 'src/services/random_seed/random_seed.service.js'
|
||||||
|
|
||||||
|
|
@ -88,7 +89,7 @@ const StatusActionButtons = {
|
||||||
return this.buttons.filter((x) => !this.pinnedItems.has(x.name))
|
return this.buttons.filter((x) => !this.pinnedItems.has(x.name))
|
||||||
},
|
},
|
||||||
currentUser() {
|
currentUser() {
|
||||||
return this.$store.state.users.currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
funcArg() {
|
funcArg() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -168,7 +169,7 @@ const StatusActionButtons = {
|
||||||
useSyncConfigStore().pushSyncConfig()
|
useSyncConfigStore().pushSyncConfig()
|
||||||
},
|
},
|
||||||
getComponent(button) {
|
getComponent(button) {
|
||||||
if (!this.$store.state.users.currentUser && button.anonLink) {
|
if (!useUsersStore().currentUser && button.anonLink) {
|
||||||
return 'a'
|
return 'a'
|
||||||
} else if (button.action == null && button.link != null) {
|
} else if (button.action == null && button.link != null) {
|
||||||
return 'a'
|
return 'a'
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { mapState as mapPiniaState } from 'pinia'
|
import { mapState } from 'pinia'
|
||||||
import { mapState } from 'vuex'
|
|
||||||
|
|
||||||
import Attachment from 'src/components/attachment/attachment.vue'
|
import Attachment from 'src/components/attachment/attachment.vue'
|
||||||
import Gallery from 'src/components/gallery/gallery.vue'
|
import Gallery from 'src/components/gallery/gallery.vue'
|
||||||
|
|
@ -9,6 +8,7 @@ import StatusBody from 'src/components/status_body/status_body.vue'
|
||||||
|
|
||||||
import { useMediaViewerStore } from 'src/stores/media_viewer.js'
|
import { useMediaViewerStore } from 'src/stores/media_viewer.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
@ -84,10 +84,8 @@ const StatusContent = {
|
||||||
maxThumbnails() {
|
maxThumbnails() {
|
||||||
return this.mergedConfig.maxThumbnails
|
return this.mergedConfig.maxThumbnails
|
||||||
},
|
},
|
||||||
...mapPiniaState(useMergedConfigStore, ['mergedConfig']),
|
...mapState(useMergedConfigStore, ['mergedConfig']),
|
||||||
...mapState({
|
...mapState(useUsersStore, ['currentUser']),
|
||||||
currentUser: (state) => state.users.currentUser,
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
Attachment,
|
Attachment,
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { mapState } from 'pinia'
|
||||||
import { useAdminSettingsStore } from 'src/stores/admin_settings'
|
import { useAdminSettingsStore } from 'src/stores/admin_settings'
|
||||||
import { useEmojiStore } from 'src/stores/emoji'
|
import { useEmojiStore } from 'src/stores/emoji'
|
||||||
import { useInterfaceStore } from 'src/stores/interface'
|
import { useInterfaceStore } from 'src/stores/interface'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { Popover, SelectComponent },
|
components: { Popover, SelectComponent },
|
||||||
|
|
@ -25,7 +26,7 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isUserAdmin() {
|
isUserAdmin() {
|
||||||
return this.$store.state.users.currentUser?.rights.admin
|
return useUsersStore().currentUser?.rights.admin
|
||||||
},
|
},
|
||||||
...mapState(useEmojiStore, ['adminPacksLocal', 'adminPacksLocalLoading']),
|
...mapState(useEmojiStore, ['adminPacksLocal', 'adminPacksLocalLoading']),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import TimelineMenu from 'src/components/timeline_menu/timeline_menu.vue'
|
||||||
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import timelineFetcher from 'src/services/timeline_fetcher/timeline_fetcher.service.js'
|
import timelineFetcher from 'src/services/timeline_fetcher/timeline_fetcher.service.js'
|
||||||
|
|
||||||
|
|
@ -132,7 +133,7 @@ const Timeline = {
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
const store = this.$store
|
const store = this.$store
|
||||||
const credentials = store.state.users.currentUser.credentials
|
const credentials = useUsersStore().currentUser.credentials
|
||||||
const showImmediately = this.timeline.visibleStatuses.length === 0
|
const showImmediately = this.timeline.visibleStatuses.length === 0
|
||||||
|
|
||||||
window.addEventListener('scroll', this.handleScroll)
|
window.addEventListener('scroll', this.handleScroll)
|
||||||
|
|
@ -215,7 +216,7 @@ const Timeline = {
|
||||||
fetchOlderStatuses: throttle(
|
fetchOlderStatuses: throttle(
|
||||||
function () {
|
function () {
|
||||||
const store = this.$store
|
const store = this.$store
|
||||||
const credentials = store.state.users.currentUser.credentials
|
const credentials = useUsersStore().currentUser.credentials
|
||||||
store.commit('setLoading', { timeline: this.timelineName, value: true })
|
store.commit('setLoading', { timeline: this.timelineName, value: true })
|
||||||
timelineFetcher
|
timelineFetcher
|
||||||
.fetchAndUpdate({
|
.fetchAndUpdate({
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { mapState as mapPiniaState } from 'pinia'
|
import { mapState } from 'pinia'
|
||||||
import { mapState } from 'vuex'
|
|
||||||
|
|
||||||
import BookmarkFoldersMenuContent from 'src/components/bookmark_folders_menu/bookmark_folders_menu_content.vue'
|
import BookmarkFoldersMenuContent from 'src/components/bookmark_folders_menu/bookmark_folders_menu_content.vue'
|
||||||
import ListsMenuContent from 'src/components/lists_menu/lists_menu_content.vue'
|
import ListsMenuContent from 'src/components/lists_menu/lists_menu_content.vue'
|
||||||
|
|
@ -13,6 +12,7 @@ import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
import { useInterfaceStore } from 'src/stores/interface'
|
import { useInterfaceStore } from 'src/stores/interface'
|
||||||
import { useListsStore } from 'src/stores/lists'
|
import { useListsStore } from 'src/stores/lists'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faChevronDown } from '@fortawesome/free-solid-svg-icons'
|
import { faChevronDown } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
@ -62,16 +62,14 @@ const TimelineMenu = {
|
||||||
(route === 'bookmark-folder' || route === 'bookmarks')
|
(route === 'bookmark-folder' || route === 'bookmarks')
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
...mapPiniaState(useInstanceCapabilitiesStore, [
|
...mapState(useInstanceCapabilitiesStore, [
|
||||||
'pleromaChatMessagesAvailable',
|
'pleromaChatMessagesAvailable',
|
||||||
'pleromaBookmarkFoldersAvailable',
|
'pleromaBookmarkFoldersAvailable',
|
||||||
'bookmarkFolders',
|
'bookmarkFolders',
|
||||||
'localBubble',
|
'localBubble',
|
||||||
]),
|
]),
|
||||||
...mapPiniaState(useInstanceStore, ['privateMode', 'federating']),
|
...mapState(useInstanceStore, ['privateMode', 'federating']),
|
||||||
...mapState({
|
...mapState(useUsersStore, ['currentUser']),
|
||||||
currentUser: (state) => state.users.currentUser,
|
|
||||||
}),
|
|
||||||
timelinesList() {
|
timelinesList() {
|
||||||
return filterNavigation(
|
return filterNavigation(
|
||||||
Object.entries(TIMELINES).map(([k, v]) => ({ ...v, name: k })),
|
Object.entries(TIMELINES).map(([k, v]) => ({ ...v, name: k })),
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import Modal from 'src/components/modal/modal.vue'
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import pleromaTanFoxMask from 'src/assets/pleromatan_apology_fox_mask.png'
|
import pleromaTanFoxMask from 'src/assets/pleromatan_apology_fox_mask.png'
|
||||||
import pleromaTanMask from 'src/assets/pleromatan_apology_mask.png'
|
import pleromaTanMask from 'src/assets/pleromatan_apology_mask.png'
|
||||||
|
|
@ -41,7 +42,7 @@ const UpdateNotification = {
|
||||||
shouldShow() {
|
shouldShow() {
|
||||||
return (
|
return (
|
||||||
!useInstanceStore().disableUpdateNotification &&
|
!useInstanceStore().disableUpdateNotification &&
|
||||||
this.$store.state.users.currentUser &&
|
useUsersStore().currentUser &&
|
||||||
useSyncConfigStore().flagStorage.updateCounter <
|
useSyncConfigStore().flagStorage.updateCounter <
|
||||||
CURRENT_UPDATE_COUNTER &&
|
CURRENT_UPDATE_COUNTER &&
|
||||||
!useMergedConfigStore().mergedConfig.dontShowUpdateNotifs
|
!useMergedConfigStore().mergedConfig.dontShowUpdateNotifs
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import { useMediaViewerStore } from 'src/stores/media_viewer'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { usePostStatusStore } from 'src/stores/post_status'
|
import { usePostStatusStore } from 'src/stores/post_status'
|
||||||
import { useUserHighlightStore } from 'src/stores/user_highlight.js'
|
import { useUserHighlightStore } from 'src/stores/user_highlight.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { updateProfile } from 'src/api/user.js'
|
import { updateProfile } from 'src/api/user.js'
|
||||||
import { propsToNative } from 'src/services/attributes_helper/attributes_helper.service.js'
|
import { propsToNative } from 'src/services/attributes_helper/attributes_helper.service.js'
|
||||||
|
|
@ -158,7 +159,7 @@ export default {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const user = this.$store.getters.findUser(this.userId)
|
const user = useUsersStore().findUser(this.userId)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
followRequestInProgress: false,
|
followRequestInProgress: false,
|
||||||
|
|
@ -192,7 +193,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.$store.dispatch('fetchUserRelationship', this.user.id)
|
useUsersStore().fetchUserRelationship(this.user.id)
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
escapedNewBio() {
|
escapedNewBio() {
|
||||||
|
|
@ -228,23 +229,23 @@ export default {
|
||||||
: ['Person', 'Service']
|
: ['Person', 'Service']
|
||||||
},
|
},
|
||||||
user() {
|
user() {
|
||||||
return this.$store.getters.findUser(this.userId)
|
return useUsersStore().findUser(this.userId)
|
||||||
},
|
},
|
||||||
role() {
|
role() {
|
||||||
return this.user.role
|
return this.user.role
|
||||||
},
|
},
|
||||||
relationship() {
|
relationship() {
|
||||||
return this.$store.getters.relationship(this.userId)
|
return useUsersStore().relationship(this.userId)
|
||||||
},
|
},
|
||||||
isOtherUser() {
|
isOtherUser() {
|
||||||
return this.user.id !== this.$store.state.users.currentUser.id
|
return this.user.id !== useUsersStore().currentUser.id
|
||||||
},
|
},
|
||||||
subscribeUrl() {
|
subscribeUrl() {
|
||||||
const serverUrl = new URL(this.user.statusnet_profile_url)
|
const serverUrl = new URL(this.user.statusnet_profile_url)
|
||||||
return `${serverUrl.protocol}//${serverUrl.host}/main/ostatus`
|
return `${serverUrl.protocol}//${serverUrl.host}/main/ostatus`
|
||||||
},
|
},
|
||||||
loggedIn() {
|
loggedIn() {
|
||||||
return this.$store.state.users.currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
dailyAvg() {
|
dailyAvg() {
|
||||||
const days = Math.ceil(
|
const days = Math.ceil(
|
||||||
|
|
@ -394,17 +395,15 @@ export default {
|
||||||
isDefaultAvatar() {
|
isDefaultAvatar() {
|
||||||
const baseAvatar = useInstanceStore().instanceIdenitity.defaultAvatar
|
const baseAvatar = useInstanceStore().instanceIdenitity.defaultAvatar
|
||||||
return (
|
return (
|
||||||
!this.$store.state.users.currentUser.profile_image_url ||
|
!useUsersStore().currentUser.profile_image_url ||
|
||||||
this.$store.state.users.currentUser.profile_image_url.includes(
|
useUsersStore().currentUser.profile_image_url.includes(baseAvatar)
|
||||||
baseAvatar,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
isDefaultBanner() {
|
isDefaultBanner() {
|
||||||
const baseBanner = useInstanceStore().instanceIdentity.defaultBanner
|
const baseBanner = useInstanceStore().instanceIdentity.defaultBanner
|
||||||
return (
|
return (
|
||||||
!this.$store.state.users.currentUser.cover_photo ||
|
!useUsersStore().currentUser.cover_photo ||
|
||||||
this.$store.state.users.currentUser.cover_photo.includes(baseBanner)
|
useUsersStore().currentUser.cover_photo.includes(baseBanner)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
fieldsLimits() {
|
fieldsLimits() {
|
||||||
|
|
@ -557,7 +556,7 @@ export default {
|
||||||
return
|
return
|
||||||
},
|
},
|
||||||
resetState() {
|
resetState() {
|
||||||
const user = this.$store.state.users.currentUser
|
const user = useUsersStore().currentUser
|
||||||
|
|
||||||
this.newName = user.name_unescaped
|
this.newName = user.name_unescaped
|
||||||
this.newBio = ldUnescape(user.description)
|
this.newBio = ldUnescape(user.description)
|
||||||
|
|
@ -603,11 +602,10 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateProfile({ params })
|
updateProfile({ params })
|
||||||
.then(({ data: user }) => {
|
.then(({ data: user, ...rest }) => {
|
||||||
this.newFields.splice(this.newFields.length)
|
this.newFields.splice(this.newFields.length)
|
||||||
merge(this.newFields, user.fields)
|
merge(this.newFields, user.fields)
|
||||||
this.$store.commit('addNewUsers', [user])
|
useUsersStore().addNewUsers({ data: user, ...rest })
|
||||||
this.$store.commit('setCurrentUser', user)
|
|
||||||
this.resetState()
|
this.resetState()
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,14 @@
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'pinia'
|
||||||
|
|
||||||
import AuthForm from 'src/components/auth_form/auth_form.js'
|
import AuthForm from 'src/components/auth_form/auth_form.js'
|
||||||
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
|
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
|
||||||
import UserCard from 'src/components/user_card/user_card.vue'
|
import UserCard from 'src/components/user_card/user_card.vue'
|
||||||
|
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const UserPanel = {
|
const UserPanel = {
|
||||||
computed: {
|
computed: {
|
||||||
signedIn() {
|
...mapState(useUsersStore, ['currentUser', 'loggedIn']),
|
||||||
return this.user
|
|
||||||
},
|
|
||||||
...mapState({ user: (state) => state.users.currentUser }),
|
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
PostStatusForm,
|
PostStatusForm,
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<aside class="user-panel">
|
<aside class="user-panel">
|
||||||
<div
|
<div
|
||||||
v-if="signedIn"
|
v-if="loggedIn"
|
||||||
key="user-panel-signed"
|
key="user-panel-signed"
|
||||||
class="panel panel-default signed-in"
|
class="panel panel-default signed-in"
|
||||||
>
|
>
|
||||||
<UserCard
|
<UserCard
|
||||||
:user-id="user.id"
|
:user-id="currentUser.id"
|
||||||
:hide-bio="true"
|
:hide-bio="true"
|
||||||
/>
|
/>
|
||||||
<PostStatusForm />
|
<PostStatusForm />
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import UserCard from 'src/components/user_card/user_card.vue'
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faCircleNotch } from '@fortawesome/free-solid-svg-icons'
|
import { faCircleNotch } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
@ -54,12 +55,12 @@ const UserProfile = {
|
||||||
isUs() {
|
isUs() {
|
||||||
return (
|
return (
|
||||||
this.userId &&
|
this.userId &&
|
||||||
this.$store.state.users.currentUser.id &&
|
useUsersStore().currentUser.id &&
|
||||||
this.userId === this.$store.state.users.currentUser.id
|
this.userId === useUsersStore().currentUser.id
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
user() {
|
user() {
|
||||||
return this.$store.getters.findUser(this.userId)
|
return useUsersStore().findUser(this.userId)
|
||||||
},
|
},
|
||||||
isExternal() {
|
isExternal() {
|
||||||
return this.$route.name === 'external-user-profile'
|
return this.$route.name === 'external-user-profile'
|
||||||
|
|
@ -81,18 +82,14 @@ const UserProfile = {
|
||||||
return useMergedConfigStore().mergedConfig.compactProfiles
|
return useMergedConfigStore().mergedConfig.compactProfiles
|
||||||
},
|
},
|
||||||
friends() {
|
friends() {
|
||||||
return get(
|
return get(useUsersStore().findUser(this.userId), 'friendIds', []).map(
|
||||||
this.$store.getters.findUser(this.userId),
|
(id) => useUsersStore().findUser(id),
|
||||||
'friendIds',
|
)
|
||||||
[],
|
|
||||||
).map((id) => this.$store.getters.findUser(id))
|
|
||||||
},
|
},
|
||||||
followers() {
|
followers() {
|
||||||
return get(
|
return get(useUsersStore().findUser(this.userId), 'followerIds', []).map(
|
||||||
this.$store.getters.findUser(this.userId),
|
(id) => useUsersStore().findUser(id),
|
||||||
'followerIds',
|
)
|
||||||
[],
|
|
||||||
).map((id) => this.$store.getters.findUser(id))
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -136,8 +133,8 @@ const UserProfile = {
|
||||||
|
|
||||||
// Check if user data is already loaded in store
|
// Check if user data is already loaded in store
|
||||||
const user = maybeId
|
const user = maybeId
|
||||||
? this.$store.getters.findUser(maybeId)
|
? useUsersStore().findUser(maybeId)
|
||||||
: this.$store.getters.findUserByName(maybeName)
|
: useUsersStore().findUserByName(maybeName)
|
||||||
if (user) {
|
if (user) {
|
||||||
loadById(user.id)
|
loadById(user.id)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import UserCard from 'src/components/user_card/user_card.vue'
|
||||||
|
|
||||||
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
|
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faCircleNotch } from '@fortawesome/free-solid-svg-icons'
|
import { faCircleNotch } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
@ -38,7 +39,7 @@ const UserProfileAdminView = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
user() {
|
user() {
|
||||||
return this.$store.getters.findUser(this.userId)
|
return useUsersStore().findUser(this.userId)
|
||||||
},
|
},
|
||||||
userId() {
|
userId() {
|
||||||
return this.$route.params.id
|
return this.$route.params.id
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import UserLink from 'src/components/user_link/user_link.vue'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
import { useReportsStore } from 'src/stores/reports.js'
|
import { useReportsStore } from 'src/stores/reports.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { reportUser } from 'src/api/user.js'
|
import { reportUser } from 'src/api/user.js'
|
||||||
|
|
||||||
|
|
@ -28,7 +29,7 @@ const UserReportingModal = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isLoggedIn() {
|
isLoggedIn() {
|
||||||
return !!this.$store.state.users.currentUser
|
return !!useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
isOpen() {
|
isOpen() {
|
||||||
return this.isLoggedIn && this.reportModal.activated
|
return this.isLoggedIn && this.reportModal.activated
|
||||||
|
|
@ -37,7 +38,7 @@ const UserReportingModal = {
|
||||||
return this.reportModal.userId
|
return this.reportModal.userId
|
||||||
},
|
},
|
||||||
user() {
|
user() {
|
||||||
return this.$store.getters.findUser(this.userId)
|
return useUsersStore().findUser(this.userId)
|
||||||
},
|
},
|
||||||
remoteInstance() {
|
remoteInstance() {
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { shuffle } from 'lodash'
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { fetchUser, suggestions } from 'src/api/public.js'
|
import { fetchUser, suggestions } from 'src/api/public.js'
|
||||||
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
||||||
|
|
@ -31,7 +32,7 @@ function showWhoToFollow(panel, reply) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWhoToFollow(panel) {
|
function getWhoToFollow(panel) {
|
||||||
const credentials = panel.$store.state.users.currentUser.credentials
|
const credentials = panel.$useUsersStore().currentUser.credentials
|
||||||
if (credentials) {
|
if (credentials) {
|
||||||
panel.usersToFollow.forEach((toFollow) => {
|
panel.usersToFollow.forEach((toFollow) => {
|
||||||
toFollow.name = 'Loading...'
|
toFollow.name = 'Loading...'
|
||||||
|
|
@ -48,7 +49,7 @@ const WhoToFollowPanel = {
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
user: function () {
|
user: function () {
|
||||||
return this.$store.state.users.currentUser.screen_name
|
return useUsersStore().currentUser.screen_name
|
||||||
},
|
},
|
||||||
suggestionsEnabled() {
|
suggestionsEnabled() {
|
||||||
return useInstanceCapabilitiesStore().suggestionsEnabled
|
return useInstanceCapabilitiesStore().suggestionsEnabled
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,6 @@ const defaultReducer = (state, paths) =>
|
||||||
|
|
||||||
const saveImmedeatelyActions = [
|
const saveImmedeatelyActions = [
|
||||||
'markNotificationsAsSeen',
|
'markNotificationsAsSeen',
|
||||||
'clearCurrentUser',
|
|
||||||
'setCurrentUser',
|
|
||||||
'setHighlight',
|
'setHighlight',
|
||||||
'setOption',
|
'setOption',
|
||||||
'setClientData',
|
'setClientData',
|
||||||
|
|
@ -75,19 +73,13 @@ export default function createPersistedState({
|
||||||
setState(key, reducer(cloneDeep(state), paths), storage).then(
|
setState(key, reducer(cloneDeep(state), paths), storage).then(
|
||||||
(success) => {
|
(success) => {
|
||||||
if (success !== undefined) {
|
if (success !== undefined) {
|
||||||
if (
|
if (mutation.type === 'setOption') {
|
||||||
mutation.type === 'setOption' ||
|
|
||||||
mutation.type === 'setCurrentUser'
|
|
||||||
) {
|
|
||||||
useInterfaceStore().settingsSaved({ success })
|
useInterfaceStore().settingsSaved({ success })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
if (
|
if (mutation.type === 'setOption') {
|
||||||
mutation.type === 'setOption' ||
|
|
||||||
mutation.type === 'setCurrentUser'
|
|
||||||
) {
|
|
||||||
useInterfaceStore().settingsSaved({ error })
|
useInterfaceStore().settingsSaved({ error })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
export const piniaPushNotificationsPlugin = ({ store }) => {
|
export const piniaPushNotificationsPlugin = ({ store }) => {
|
||||||
if (
|
if (
|
||||||
|
|
@ -25,7 +26,7 @@ export const piniaPushNotificationsPlugin = ({ store }) => {
|
||||||
useInterfaceStore().notificationPermission === 'granted'
|
useInterfaceStore().notificationPermission === 'granted'
|
||||||
let permissionPresent =
|
let permissionPresent =
|
||||||
useInterfaceStore().notificationPermission !== undefined
|
useInterfaceStore().notificationPermission !== undefined
|
||||||
let user = !!window.vuex.state.users.currentUser
|
let user = !!useUsersStore().currentUser
|
||||||
|
|
||||||
if (store.$id === 'instance') {
|
if (store.$id === 'instance') {
|
||||||
if (actionName === 'set' && args[0].path === 'vapidPublicKey') {
|
if (actionName === 'set' && args[0].path === 'vapidPublicKey') {
|
||||||
|
|
@ -66,6 +67,7 @@ export const piniaPushNotificationsPlugin = ({ store }) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO make it work with pinia
|
||||||
export const vuexPushNotificationsPlugin = (store) => {
|
export const vuexPushNotificationsPlugin = (store) => {
|
||||||
store.subscribe((mutation, state) => {
|
store.subscribe((mutation, state) => {
|
||||||
// Initial state
|
// Initial state
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,10 @@ import drafts from './drafts.js'
|
||||||
import notifications from './notifications.js'
|
import notifications from './notifications.js'
|
||||||
import profileConfig from './profileConfig.js'
|
import profileConfig from './profileConfig.js'
|
||||||
import statuses from './statuses.js'
|
import statuses from './statuses.js'
|
||||||
import users from './users.js'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
statuses,
|
statuses,
|
||||||
notifications,
|
notifications,
|
||||||
users,
|
|
||||||
api,
|
api,
|
||||||
profileConfig,
|
profileConfig,
|
||||||
drafts,
|
drafts,
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
import { useReportsStore } from 'src/stores/reports.js'
|
import { useReportsStore } from 'src/stores/reports.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { dismissNotification, markNotificationsAsSeen } from 'src/api/user.js'
|
import { dismissNotification, markNotificationsAsSeen } from 'src/api/user.js'
|
||||||
|
|
||||||
|
|
@ -158,7 +159,7 @@ export const notifications = {
|
||||||
commit('markNotificationsAsSeen')
|
commit('markNotificationsAsSeen')
|
||||||
markNotificationsAsSeen({
|
markNotificationsAsSeen({
|
||||||
id: state.maxId,
|
id: state.maxId,
|
||||||
credentials: rootState.users.currentUser.credentials,
|
credentials: useUsersStore().currentUser.credentials,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
closeAllDesktopNotifications(rootState)
|
closeAllDesktopNotifications(rootState)
|
||||||
})
|
})
|
||||||
|
|
@ -168,7 +169,7 @@ export const notifications = {
|
||||||
markNotificationsAsSeen({
|
markNotificationsAsSeen({
|
||||||
single: true,
|
single: true,
|
||||||
id,
|
id,
|
||||||
credentials: rootState.users.currentUser.credentials,
|
credentials: useUsersStore().currentUser.credentials,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
closeDesktopNotification(rootState, { id })
|
closeDesktopNotification(rootState, { id })
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { get, set } from 'lodash'
|
import { get, set } from 'lodash'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { updateNotificationSettings, updateProfile } from 'src/api/user.js'
|
import { updateNotificationSettings, updateProfile } from 'src/api/user.js'
|
||||||
|
|
||||||
|
|
@ -10,9 +11,8 @@ const defaultApi = ({ rootState, commit }, { path, value }) => {
|
||||||
return updateProfile({
|
return updateProfile({
|
||||||
params,
|
params,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then(({ data: result }) => {
|
}).then((result) => {
|
||||||
commit('addNewUsers', [result])
|
useUsersStore().addNewUsers(result)
|
||||||
commit('setCurrentUser', result)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import {
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
fetchEmojiReactions,
|
fetchEmojiReactions,
|
||||||
|
|
@ -619,7 +620,7 @@ const statuses = {
|
||||||
showImmediately,
|
showImmediately,
|
||||||
timeline,
|
timeline,
|
||||||
noIdUpdate,
|
noIdUpdate,
|
||||||
user: rootState.users.currentUser,
|
user: useUsersStore().currentUser,
|
||||||
userId,
|
userId,
|
||||||
pagination,
|
pagination,
|
||||||
})
|
})
|
||||||
|
|
@ -671,7 +672,7 @@ const statuses = {
|
||||||
}).then(({ data: status }) =>
|
}).then(({ data: status }) =>
|
||||||
commit('setFavoritedConfirm', {
|
commit('setFavoritedConfirm', {
|
||||||
status,
|
status,
|
||||||
user: rootState.users.currentUser,
|
user: useUsersStore().currentUser,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
@ -684,7 +685,7 @@ const statuses = {
|
||||||
}).then(({ data: status }) =>
|
}).then(({ data: status }) =>
|
||||||
commit('setFavoritedConfirm', {
|
commit('setFavoritedConfirm', {
|
||||||
status,
|
status,
|
||||||
user: rootState.users.currentUser,
|
user: useUsersStore().currentUser,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
@ -739,7 +740,7 @@ const statuses = {
|
||||||
}).then(({ data: status }) =>
|
}).then(({ data: status }) =>
|
||||||
commit('setRetweetedConfirm', {
|
commit('setRetweetedConfirm', {
|
||||||
status: status.retweeted_status,
|
status: status.retweeted_status,
|
||||||
user: rootState.users.currentUser,
|
user: useUsersStore().currentUser,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
@ -752,7 +753,7 @@ const statuses = {
|
||||||
}).then(({ data: status }) =>
|
}).then(({ data: status }) =>
|
||||||
commit('setRetweetedConfirm', {
|
commit('setRetweetedConfirm', {
|
||||||
status,
|
status,
|
||||||
user: rootState.users.currentUser,
|
user: useUsersStore().currentUser,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
@ -795,17 +796,17 @@ const statuses = {
|
||||||
commit('addFavs', {
|
commit('addFavs', {
|
||||||
id,
|
id,
|
||||||
favoritedByUsers,
|
favoritedByUsers,
|
||||||
currentUser: rootState.users.currentUser,
|
currentUser: useUsersStore().currentUser,
|
||||||
})
|
})
|
||||||
commit('addRepeats', {
|
commit('addRepeats', {
|
||||||
id,
|
id,
|
||||||
rebloggedByUsers,
|
rebloggedByUsers,
|
||||||
currentUser: rootState.users.currentUser,
|
currentUser: useUsersStore().currentUser,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
reactWithEmoji({ rootState, dispatch, commit }, { id, emoji }) {
|
reactWithEmoji({ rootState, dispatch, commit }, { id, emoji }) {
|
||||||
const currentUser = rootState.users.currentUser
|
const currentUser = useUsersStore().currentUser
|
||||||
if (!currentUser) return
|
if (!currentUser) return
|
||||||
|
|
||||||
commit('addOwnReaction', { id, emoji, currentUser })
|
commit('addOwnReaction', { id, emoji, currentUser })
|
||||||
|
|
@ -818,14 +819,14 @@ const statuses = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
unreactWithEmoji({ rootState, dispatch, commit }, { id, emoji }) {
|
unreactWithEmoji({ rootState, dispatch, commit }, { id, emoji }) {
|
||||||
const currentUser = rootState.users.currentUser
|
const currentUser = useUsersStore().currentUser
|
||||||
if (!currentUser) return
|
if (!currentUser) return
|
||||||
|
|
||||||
commit('removeOwnReaction', { id, emoji, currentUser })
|
commit('removeOwnReaction', { id, emoji, currentUser })
|
||||||
unreactWithEmoji({
|
unreactWithEmoji({
|
||||||
id,
|
id,
|
||||||
emoji,
|
emoji,
|
||||||
currentUser: rootState.users.currentUser,
|
currentUser: useUsersStore().currentUser,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
dispatch('fetchEmojiReactionsBy', id)
|
dispatch('fetchEmojiReactionsBy', id)
|
||||||
})
|
})
|
||||||
|
|
@ -838,7 +839,7 @@ const statuses = {
|
||||||
commit('addEmojiReactionsBy', {
|
commit('addEmojiReactionsBy', {
|
||||||
id,
|
id,
|
||||||
emojiReactions,
|
emojiReactions,
|
||||||
currentUser: rootState.users.currentUser,
|
currentUser: useUsersStore().currentUser,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
@ -850,7 +851,7 @@ const statuses = {
|
||||||
commit('addFavs', {
|
commit('addFavs', {
|
||||||
id,
|
id,
|
||||||
favoritedByUsers,
|
favoritedByUsers,
|
||||||
currentUser: rootState.users.currentUser,
|
currentUser: useUsersStore().currentUser,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
@ -862,7 +863,7 @@ const statuses = {
|
||||||
commit('addRepeats', {
|
commit('addRepeats', {
|
||||||
id,
|
id,
|
||||||
rebloggedByUsers,
|
rebloggedByUsers,
|
||||||
currentUser: rootState.users.currentUser,
|
currentUser: useUsersStore().currentUser,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,870 +0,0 @@
|
||||||
import Cookies from 'js-cookie'
|
|
||||||
import { compact, each, last, map, mergeWith } from 'lodash'
|
|
||||||
|
|
||||||
import {
|
|
||||||
registerPushNotifications,
|
|
||||||
unregisterPushNotifications,
|
|
||||||
} from '../services/sw/sw.js'
|
|
||||||
import {
|
|
||||||
windowHeight,
|
|
||||||
windowWidth,
|
|
||||||
} from '../services/window_utils/window_utils'
|
|
||||||
|
|
||||||
import { useAnnouncementsStore } from 'src/stores/announcements.js'
|
|
||||||
import { useBookmarkFoldersStore } from 'src/stores/bookmark_folders.js'
|
|
||||||
import { useChatsStore } from 'src/stores/chats.js'
|
|
||||||
import { useEmojiStore } from 'src/stores/emoji.js'
|
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
|
||||||
import { useListsStore } from 'src/stores/lists.js'
|
|
||||||
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 { revokeToken } from 'src/api/oauth.js'
|
|
||||||
import {
|
|
||||||
fetchFollowers,
|
|
||||||
fetchFriends,
|
|
||||||
fetchUser,
|
|
||||||
fetchUserByName,
|
|
||||||
getCaptcha,
|
|
||||||
register,
|
|
||||||
searchUsers,
|
|
||||||
verifyCredentials,
|
|
||||||
} from 'src/api/public.js'
|
|
||||||
import {
|
|
||||||
blockUser as apiBlockUser,
|
|
||||||
editUserNote as apiEditUserNote,
|
|
||||||
muteUser as apiMuteUser,
|
|
||||||
unblockUser as apiUnblockUser,
|
|
||||||
unmuteUser as apiUnmuteUser,
|
|
||||||
fetchBlocks,
|
|
||||||
fetchDomainMutes,
|
|
||||||
fetchMutes,
|
|
||||||
fetchUserInLists,
|
|
||||||
fetchUserRelationship,
|
|
||||||
followUser,
|
|
||||||
} from 'src/api/user.js'
|
|
||||||
|
|
||||||
// TODO: Unify with mergeOrAdd in statuses.js
|
|
||||||
export const mergeOrAdd = (arr, obj, item) => {
|
|
||||||
if (!item) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
const oldItem = obj[item.id]
|
|
||||||
if (oldItem) {
|
|
||||||
// We already have this, so only merge the new info.
|
|
||||||
mergeWith(oldItem, item, mergeArrayLength)
|
|
||||||
return { item: oldItem, new: false }
|
|
||||||
} else {
|
|
||||||
// This is a new item, prepare it
|
|
||||||
arr.push(item)
|
|
||||||
obj[item.id] = item
|
|
||||||
return { item, new: true }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const mergeArrayLength = (oldValue, newValue) => {
|
|
||||||
if (Array.isArray(oldValue) && Array.isArray(newValue)) {
|
|
||||||
oldValue.length = newValue.length
|
|
||||||
return mergeWith(oldValue, newValue, mergeArrayLength)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const getNotificationPermission = async () => {
|
|
||||||
const Notification = window.Notification
|
|
||||||
|
|
||||||
if (!Notification) return null
|
|
||||||
if (Notification.permission === 'default')
|
|
||||||
return Notification.requestPermission()
|
|
||||||
return Notification.permission
|
|
||||||
}
|
|
||||||
|
|
||||||
const blockUser = (store, args) => {
|
|
||||||
const id = args.id
|
|
||||||
const expiresIn = typeof args === 'object' ? args.expiresIn : 0
|
|
||||||
|
|
||||||
const predictedRelationship = store.state.relationships[id] || { id }
|
|
||||||
store.commit('updateUserRelationship', [predictedRelationship])
|
|
||||||
store.commit('addBlockId', id)
|
|
||||||
|
|
||||||
return apiBlockUser({ id, expiresIn }).then(({ data: relationship }) => {
|
|
||||||
store.commit('updateUserRelationship', [relationship])
|
|
||||||
store.commit('addBlockId', id)
|
|
||||||
|
|
||||||
store.commit('removeStatus', { timeline: 'friends', userId: id })
|
|
||||||
store.commit('removeStatus', { timeline: 'public', userId: id })
|
|
||||||
store.commit('removeStatus', {
|
|
||||||
timeline: 'publicAndExternal',
|
|
||||||
userId: id,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const unblockUser = (store, id) => {
|
|
||||||
return apiUnblockUser({ id }).then(({ data: relationship }) =>
|
|
||||||
store.commit('updateUserRelationship', [relationship]),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const removeUserFromFollowers = (store, id) => {
|
|
||||||
return removeUserFromFollowers({ id }).then((relationship) =>
|
|
||||||
store.commit('updateUserRelationship', [relationship]),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const editUserNote = (store, { id, comment }) => {
|
|
||||||
return apiEditUserNote({ id, comment }).then((relationship) =>
|
|
||||||
store.commit('updateUserRelationship', [relationship]),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const muteUser = (store, args) => {
|
|
||||||
const id = typeof args === 'object' ? args.id : args
|
|
||||||
const expiresIn = typeof args === 'object' ? args.expiresIn : 0
|
|
||||||
|
|
||||||
const predictedRelationship = store.state.relationships[id] || { id }
|
|
||||||
store.commit('updateUserRelationship', [predictedRelationship])
|
|
||||||
store.commit('addMuteId', id)
|
|
||||||
|
|
||||||
return apiMuteUser({
|
|
||||||
id,
|
|
||||||
expiresIn,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(({ data: relationship }) => {
|
|
||||||
store.commit('updateUserRelationship', [relationship])
|
|
||||||
store.commit('addMuteId', id)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const unmuteUser = (store, id) => {
|
|
||||||
const predictedRelationship = store.state.relationships[id] || { id }
|
|
||||||
predictedRelationship.muting = false
|
|
||||||
store.commit('updateUserRelationship', [predictedRelationship])
|
|
||||||
|
|
||||||
return apiUnmuteUser({ id }).then(({ data: relationship }) =>
|
|
||||||
store.commit('updateUserRelationship', [relationship]),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const hideReblogs = (store, userId) => {
|
|
||||||
return followUser({
|
|
||||||
id: userId,
|
|
||||||
reblogs: false,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(({ data: relationship }) =>
|
|
||||||
store.commit('updateUserRelationship', [relationship]),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const showReblogs = (store, userId) => {
|
|
||||||
return followUser({
|
|
||||||
id: userId,
|
|
||||||
reblogs: true,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(({ data: relationship }) =>
|
|
||||||
store.commit('updateUserRelationship', [relationship]),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const muteDomain = (store, domain) => {
|
|
||||||
return muteDomain({
|
|
||||||
domain,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(() => store.commit('addDomainMute', domain))
|
|
||||||
}
|
|
||||||
|
|
||||||
const unmuteDomain = (store, domain) => {
|
|
||||||
return unmuteDomain({
|
|
||||||
domain,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(() => store.commit('removeDomainMute', domain))
|
|
||||||
}
|
|
||||||
|
|
||||||
export const mutations = {
|
|
||||||
tagUser(state, { user: { id }, tag }) {
|
|
||||||
const user = state.usersObject[id]
|
|
||||||
user.tags.add(tag)
|
|
||||||
},
|
|
||||||
untagUser(state, { user: { id }, tag }) {
|
|
||||||
const user = state.usersObject[id]
|
|
||||||
user.tags.delete(tag)
|
|
||||||
},
|
|
||||||
updateRight(state, { user: { id }, right, value }) {
|
|
||||||
const user = state.usersObject[id]
|
|
||||||
const newRights = user.rights
|
|
||||||
newRights[right] = value
|
|
||||||
user.rights = newRights
|
|
||||||
},
|
|
||||||
updateUserAdminData(state, { user }) {
|
|
||||||
const { id } = user
|
|
||||||
const localUser = state.usersObject[id]
|
|
||||||
localUser.adminData = user
|
|
||||||
localUser.deactivated = !user.is_active
|
|
||||||
localUser.tags = new Set(user.tags)
|
|
||||||
},
|
|
||||||
setCurrentUser(state, user) {
|
|
||||||
state.lastLoginName = user.screen_name
|
|
||||||
state.currentUser = mergeWith(
|
|
||||||
state.currentUser || {},
|
|
||||||
user,
|
|
||||||
mergeArrayLength,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
clearCurrentUser(state) {
|
|
||||||
state.currentUser = false
|
|
||||||
state.lastLoginName = false
|
|
||||||
},
|
|
||||||
beginLogin(state) {
|
|
||||||
state.loggingIn = true
|
|
||||||
},
|
|
||||||
endLogin(state) {
|
|
||||||
state.loggingIn = false
|
|
||||||
},
|
|
||||||
saveFriendIds(state, { id, friendIds }) {
|
|
||||||
const user = state.usersObject[id]
|
|
||||||
user.friendIds = [...new Set([...(user.friendIds || []), ...friendIds])]
|
|
||||||
},
|
|
||||||
saveFollowerIds(state, { id, followerIds }) {
|
|
||||||
const user = state.usersObject[id]
|
|
||||||
user.followerIds = [...new Set([user.followerIds || [], ...followerIds])]
|
|
||||||
},
|
|
||||||
// Because frontend doesn't have a reason to keep these stuff in memory
|
|
||||||
// outside of viewing someones user profile.
|
|
||||||
clearFriends(state, userId) {
|
|
||||||
const user = state.usersObject[userId]
|
|
||||||
if (user) {
|
|
||||||
user.friendIds = []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
clearFollowers(state, userId) {
|
|
||||||
const user = state.usersObject[userId]
|
|
||||||
if (user) {
|
|
||||||
user.followerIds = []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
addNewUsers(state, users) {
|
|
||||||
each(users, (user) => {
|
|
||||||
if (user.relationship) {
|
|
||||||
state.relationships[user.relationship.id] = user.relationship
|
|
||||||
}
|
|
||||||
const res = mergeOrAdd(state.users, state.usersObject, user)
|
|
||||||
const item = res.item
|
|
||||||
if (res.new && item.screen_name && !item.screen_name.includes('@')) {
|
|
||||||
state.usersByNameObject[item.screen_name.toLowerCase()] = item
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
updateUserRelationship(state, relationships) {
|
|
||||||
relationships.forEach((relationship) => {
|
|
||||||
state.relationships[relationship.id] = relationship
|
|
||||||
})
|
|
||||||
},
|
|
||||||
updateUserInLists(state, { id, inLists }) {
|
|
||||||
state.usersObject[id].inLists = inLists
|
|
||||||
},
|
|
||||||
saveBlockIds(state, blockIds) {
|
|
||||||
state.currentUser.blockIds = blockIds
|
|
||||||
},
|
|
||||||
addBlockId(state, blockId) {
|
|
||||||
if (state.currentUser.blockIds.includes(blockId)) {
|
|
||||||
state.currentUser.blockIds.push(blockId)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
setBlockIdsMaxId(state, blockIdsMaxId) {
|
|
||||||
state.currentUser.blockIdsMaxId = blockIdsMaxId
|
|
||||||
},
|
|
||||||
saveMuteIds(state, muteIds) {
|
|
||||||
state.currentUser.muteIds = muteIds
|
|
||||||
},
|
|
||||||
setMuteIdsMaxId(state, muteIdsMaxId) {
|
|
||||||
state.currentUser.muteIdsMaxId = muteIdsMaxId
|
|
||||||
},
|
|
||||||
addMuteId(state, muteId) {
|
|
||||||
if (state.currentUser.muteIds.includes(muteId)) {
|
|
||||||
state.currentUser.muteIds.push(muteId)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
saveDomainMutes(state, domainMutes) {
|
|
||||||
state.currentUser.domainMutes = domainMutes
|
|
||||||
},
|
|
||||||
addDomainMute(state, domain) {
|
|
||||||
if (state.currentUser.domainMutes.includes(domain)) {
|
|
||||||
state.currentUser.domainMutes.push(domain)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
removeDomainMute(state, domain) {
|
|
||||||
const index = state.currentUser.domainMutes.indexOf(domain)
|
|
||||||
if (index !== -1) {
|
|
||||||
state.currentUser.domainMutes.splice(index, 1)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
setPinnedToUser(state, status) {
|
|
||||||
const user = state.usersObject[status.user.id]
|
|
||||||
user.pinnedStatusIds = user.pinnedStatusIds || []
|
|
||||||
const index = user.pinnedStatusIds.indexOf(status.id)
|
|
||||||
|
|
||||||
if (status.pinned && index === -1) {
|
|
||||||
user.pinnedStatusIds.push(status.id)
|
|
||||||
} else if (!status.pinned && index !== -1) {
|
|
||||||
user.pinnedStatusIds.splice(index, 1)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
setUserForStatus(state, status) {
|
|
||||||
status.user = state.usersObject[status.user.id]
|
|
||||||
},
|
|
||||||
setUserForNotification(state, notification) {
|
|
||||||
if (notification.type !== 'follow') {
|
|
||||||
notification.action.user = state.usersObject[notification.action.user.id]
|
|
||||||
}
|
|
||||||
notification.from_profile = state.usersObject[notification.from_profile.id]
|
|
||||||
},
|
|
||||||
setColor(state, { user: { id }, highlighted }) {
|
|
||||||
const user = state.usersObject[id]
|
|
||||||
user.highlight = highlighted
|
|
||||||
},
|
|
||||||
signUpPending(state) {
|
|
||||||
state.signUpPending = true
|
|
||||||
state.signUpErrors = []
|
|
||||||
state.signUpNotice = {}
|
|
||||||
},
|
|
||||||
signUpSuccess(state) {
|
|
||||||
state.signUpPending = false
|
|
||||||
},
|
|
||||||
signUpFailure(state, errors) {
|
|
||||||
state.signUpPending = false
|
|
||||||
state.signUpErrors = errors
|
|
||||||
state.signUpNotice = {}
|
|
||||||
},
|
|
||||||
signUpNotice(state, notice) {
|
|
||||||
state.signUpPending = false
|
|
||||||
state.signUpErrors = []
|
|
||||||
state.signUpNotice = notice
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getters = {
|
|
||||||
findUser: (state) => (query) => {
|
|
||||||
return state.usersObject[query]
|
|
||||||
},
|
|
||||||
findUserByName: (state) => (query) => {
|
|
||||||
return state.usersByNameObject[query.toLowerCase()]
|
|
||||||
},
|
|
||||||
findUserByUrl: (state) => (query) => {
|
|
||||||
return state.users.find(
|
|
||||||
(u) =>
|
|
||||||
u.statusnet_profile_url &&
|
|
||||||
u.statusnet_profile_url.toLowerCase() === query.toLowerCase(),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
relationship: (state) => (id) => {
|
|
||||||
const rel = id && state.relationships[id]
|
|
||||||
return rel || { id, loading: true }
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
export const defaultState = {
|
|
||||||
loggingIn: false,
|
|
||||||
lastLoginName: false,
|
|
||||||
currentUser: false,
|
|
||||||
users: [],
|
|
||||||
usersObject: {},
|
|
||||||
usersByNameObject: {},
|
|
||||||
signUpPending: false,
|
|
||||||
signUpErrors: [],
|
|
||||||
signUpNotice: {},
|
|
||||||
relationships: {},
|
|
||||||
}
|
|
||||||
|
|
||||||
const users = {
|
|
||||||
state: defaultState,
|
|
||||||
mutations,
|
|
||||||
getters,
|
|
||||||
actions: {
|
|
||||||
async fetchUserIfMissing(store, id) {
|
|
||||||
const user = store.getters.findUser(id)
|
|
||||||
if (!user) {
|
|
||||||
return store.dispatch('fetchUser', id)
|
|
||||||
} else {
|
|
||||||
return user
|
|
||||||
}
|
|
||||||
},
|
|
||||||
updateUserAdminData(store, { userAdminData }) {
|
|
||||||
return store
|
|
||||||
.dispatch('fetchUserIfMissing', userAdminData.id)
|
|
||||||
.then((user) => {
|
|
||||||
user.adminData = userAdminData
|
|
||||||
store.commit('addNewUsers', [user])
|
|
||||||
return user
|
|
||||||
})
|
|
||||||
},
|
|
||||||
fetchUser(store, id) {
|
|
||||||
return fetchUser({
|
|
||||||
id,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
})
|
|
||||||
.then(({ data: user }) => {
|
|
||||||
store.commit('addNewUsers', [user])
|
|
||||||
return user
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
if (error.statusCode === 404) {
|
|
||||||
console.warn(`User ${id} not found`)
|
|
||||||
} else {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
fetchUserByName(store, name) {
|
|
||||||
return fetchUserByName({
|
|
||||||
name,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(({ data: user }) => {
|
|
||||||
store.commit('addNewUsers', [user])
|
|
||||||
return user
|
|
||||||
})
|
|
||||||
},
|
|
||||||
fetchUserRelationship(store, id) {
|
|
||||||
if (store.state.currentUser) {
|
|
||||||
fetchUserRelationship({
|
|
||||||
id,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(({ data: relationships }) =>
|
|
||||||
store.commit('updateUserRelationship', relationships),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fetchUserInLists(store, id) {
|
|
||||||
if (store.state.currentUser) {
|
|
||||||
fetchUserInLists({
|
|
||||||
id,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(({ data: inLists }) =>
|
|
||||||
store.commit('updateUserInLists', { id, inLists }),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fetchBlocks(store, args) {
|
|
||||||
const { reset } = args || {}
|
|
||||||
|
|
||||||
const maxId = store.state.currentUser.blockIdsMaxId
|
|
||||||
return fetchBlocks({
|
|
||||||
maxId,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(({ data: blocks }) => {
|
|
||||||
if (reset) {
|
|
||||||
store.commit('saveBlockIds', map(blocks, 'id'))
|
|
||||||
} else {
|
|
||||||
map(blocks, 'id').map((id) => store.commit('addBlockId', id))
|
|
||||||
}
|
|
||||||
if (blocks.length) {
|
|
||||||
store.commit('setBlockIdsMaxId', last(blocks).id)
|
|
||||||
}
|
|
||||||
store.commit('addNewUsers', blocks)
|
|
||||||
return blocks
|
|
||||||
})
|
|
||||||
},
|
|
||||||
blockUser(store, data) {
|
|
||||||
return blockUser(store, data)
|
|
||||||
},
|
|
||||||
unblockUser(store, data) {
|
|
||||||
return unblockUser(store, data)
|
|
||||||
},
|
|
||||||
removeUserFromFollowers(store, id) {
|
|
||||||
return removeUserFromFollowers(store, id)
|
|
||||||
},
|
|
||||||
blockUsers(store, data = []) {
|
|
||||||
return Promise.all(data.map((d) => blockUser(store, d)))
|
|
||||||
},
|
|
||||||
unblockUsers(store, data = []) {
|
|
||||||
return Promise.all(data.map((d) => unblockUser(store, d)))
|
|
||||||
},
|
|
||||||
editUserNote(store, args) {
|
|
||||||
return editUserNote(store, args)
|
|
||||||
},
|
|
||||||
fetchMutes(store, args) {
|
|
||||||
const { reset } = args || {}
|
|
||||||
|
|
||||||
const maxId = store.state.currentUser.muteIdsMaxId
|
|
||||||
return fetchMutes({
|
|
||||||
maxId,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(({ data: mutes }) => {
|
|
||||||
if (reset) {
|
|
||||||
store.commit('saveMuteIds', map(mutes, 'id'))
|
|
||||||
} else {
|
|
||||||
map(mutes, 'id').map((id) => store.commit('addMuteId', id))
|
|
||||||
}
|
|
||||||
if (mutes.length) {
|
|
||||||
store.commit('setMuteIdsMaxId', last(mutes).id)
|
|
||||||
}
|
|
||||||
store.commit('addNewUsers', mutes)
|
|
||||||
return mutes
|
|
||||||
})
|
|
||||||
},
|
|
||||||
muteUser(store, data) {
|
|
||||||
return muteUser(store, data)
|
|
||||||
},
|
|
||||||
unmuteUser(store, id) {
|
|
||||||
return unmuteUser(store, id)
|
|
||||||
},
|
|
||||||
hideReblogs(store, id) {
|
|
||||||
return hideReblogs(store, id)
|
|
||||||
},
|
|
||||||
showReblogs(store, id) {
|
|
||||||
return showReblogs(store, id)
|
|
||||||
},
|
|
||||||
muteUsers(store, data = []) {
|
|
||||||
return Promise.all(data.map((d) => muteUser(store, d)))
|
|
||||||
},
|
|
||||||
unmuteUsers(store, ids = []) {
|
|
||||||
return Promise.all(ids.map((d) => unmuteUser(store, d)))
|
|
||||||
},
|
|
||||||
fetchDomainMutes(store) {
|
|
||||||
return fetchDomainMutes({
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(({ data: domainMutes }) => {
|
|
||||||
store.commit('saveDomainMutes', domainMutes)
|
|
||||||
return domainMutes
|
|
||||||
})
|
|
||||||
},
|
|
||||||
muteDomain(store, domain) {
|
|
||||||
return muteDomain(store, domain)
|
|
||||||
},
|
|
||||||
unmuteDomain(store, domain) {
|
|
||||||
return unmuteDomain(store, domain)
|
|
||||||
},
|
|
||||||
muteDomains(store, domains = []) {
|
|
||||||
return Promise.all(domains.map((domain) => muteDomain(store, domain)))
|
|
||||||
},
|
|
||||||
unmuteDomains(store, domain = []) {
|
|
||||||
return Promise.all(domain.map((domain) => unmuteDomain(store, domain)))
|
|
||||||
},
|
|
||||||
fetchFriends({ rootState, commit }, id) {
|
|
||||||
const user = rootState.users.usersObject[id]
|
|
||||||
const maxId = last(user.friendIds)
|
|
||||||
return fetchFriends({
|
|
||||||
id,
|
|
||||||
maxId,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(({ data: friends }) => {
|
|
||||||
commit('addNewUsers', friends)
|
|
||||||
commit('saveFriendIds', { id, friendIds: map(friends, 'id') })
|
|
||||||
return friends
|
|
||||||
})
|
|
||||||
},
|
|
||||||
fetchFollowers({ rootState, commit }, id) {
|
|
||||||
const user = rootState.users.usersObject[id]
|
|
||||||
const maxId = last(user.followerIds)
|
|
||||||
return fetchFollowers({
|
|
||||||
id,
|
|
||||||
maxId,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(({ data: followers }) => {
|
|
||||||
commit('addNewUsers', followers)
|
|
||||||
commit('saveFollowerIds', { id, followerIds: map(followers, 'id') })
|
|
||||||
return followers
|
|
||||||
})
|
|
||||||
},
|
|
||||||
clearFriends({ commit }, userId) {
|
|
||||||
commit('clearFriends', userId)
|
|
||||||
},
|
|
||||||
clearFollowers({ commit }, userId) {
|
|
||||||
commit('clearFollowers', userId)
|
|
||||||
},
|
|
||||||
subscribeUser({ rootState, commit }, id) {
|
|
||||||
return followUser({
|
|
||||||
id,
|
|
||||||
notify: true,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(({ data: relationship }) =>
|
|
||||||
commit('updateUserRelationship', [relationship]),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
unsubscribeUser({ rootState, commit }, id) {
|
|
||||||
return followUser({
|
|
||||||
id,
|
|
||||||
notify: false,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(({ data: relationship }) =>
|
|
||||||
commit('updateUserRelationship', [relationship]),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
registerPushNotifications(store) {
|
|
||||||
const token = store.state.currentUser.credentials
|
|
||||||
const vapidPublicKey = useInstanceStore().vapidPublicKey
|
|
||||||
const isEnabled = useMergedConfigStore().mergedConfig.webPushNotifications
|
|
||||||
const notificationVisibility =
|
|
||||||
useMergedConfigStore().mergedConfig.notificationVisibility
|
|
||||||
|
|
||||||
registerPushNotifications(
|
|
||||||
isEnabled,
|
|
||||||
vapidPublicKey,
|
|
||||||
token,
|
|
||||||
notificationVisibility,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
unregisterPushNotifications(store) {
|
|
||||||
const token = store.state.currentUser.credentials
|
|
||||||
|
|
||||||
unregisterPushNotifications(token)
|
|
||||||
},
|
|
||||||
addNewUsers({ commit }, users) {
|
|
||||||
commit('addNewUsers', users)
|
|
||||||
},
|
|
||||||
addNewStatuses(store, { statuses }) {
|
|
||||||
const users = map(statuses, 'user')
|
|
||||||
const retweetedUsers = compact(map(statuses, 'retweeted_status.user'))
|
|
||||||
store.commit('addNewUsers', users)
|
|
||||||
store.commit('addNewUsers', retweetedUsers)
|
|
||||||
|
|
||||||
each(statuses, (status) => {
|
|
||||||
// Reconnect users to statuses
|
|
||||||
store.commit('setUserForStatus', status)
|
|
||||||
// Set pinned statuses to user
|
|
||||||
store.commit('setPinnedToUser', status)
|
|
||||||
})
|
|
||||||
each(compact(map(statuses, 'retweeted_status')), (status) => {
|
|
||||||
// Reconnect users to retweets
|
|
||||||
store.commit('setUserForStatus', status)
|
|
||||||
// Set pinned retweets to user
|
|
||||||
store.commit('setPinnedToUser', status)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
addNewNotifications(store, { notifications }) {
|
|
||||||
const users = map(notifications, 'from_profile')
|
|
||||||
const targetUsers = map(notifications, 'target').filter(Boolean)
|
|
||||||
const notificationIds = notifications.map((_) => _.id)
|
|
||||||
store.commit('addNewUsers', users)
|
|
||||||
store.commit('addNewUsers', targetUsers)
|
|
||||||
|
|
||||||
const notificationsObject = store.rootState.notifications.idStore
|
|
||||||
const relevantNotifications = Object.entries(notificationsObject)
|
|
||||||
.filter(([k]) => notificationIds.includes(k))
|
|
||||||
.map(([, val]) => val)
|
|
||||||
|
|
||||||
// Reconnect users to notifications
|
|
||||||
each(relevantNotifications, (notification) => {
|
|
||||||
store.commit('setUserForNotification', notification)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
searchUsers({ rootState, commit }, { query }) {
|
|
||||||
return searchUsers({
|
|
||||||
query,
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(({ data: users }) => {
|
|
||||||
commit('addNewUsers', users)
|
|
||||||
return users
|
|
||||||
})
|
|
||||||
},
|
|
||||||
async signUp(store, userInfo) {
|
|
||||||
const oauthStore = useOAuthStore()
|
|
||||||
store.commit('signUpPending')
|
|
||||||
|
|
||||||
try {
|
|
||||||
const token = await oauthStore.ensureAppToken()
|
|
||||||
const { data } = await register({
|
|
||||||
credentials: token,
|
|
||||||
params: { ...userInfo },
|
|
||||||
})
|
|
||||||
|
|
||||||
if (data.access_token) {
|
|
||||||
store.commit('signUpSuccess')
|
|
||||||
oauthStore.setToken(data.access_token)
|
|
||||||
await store.dispatch('loginUser', data.access_token)
|
|
||||||
return 'ok'
|
|
||||||
} else {
|
|
||||||
// Request succeeded, but user cannot login yet.
|
|
||||||
store.commit('signUpNotice', data)
|
|
||||||
return 'request_sent'
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
const errors = e.message
|
|
||||||
store.commit('signUpFailure', errors)
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getCaptcha(store) {
|
|
||||||
return getCaptcha({
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
}).then(({ data }) => data)
|
|
||||||
},
|
|
||||||
|
|
||||||
logout(store) {
|
|
||||||
const oauth = useOAuthStore()
|
|
||||||
|
|
||||||
// NOTE: No need to verify the app still exists, because if it doesn't,
|
|
||||||
// the token will be invalid too
|
|
||||||
return oauth
|
|
||||||
.ensureApp()
|
|
||||||
.then((app) => {
|
|
||||||
const params = {
|
|
||||||
app,
|
|
||||||
instance: useInstanceStore().server,
|
|
||||||
token: oauth.userToken,
|
|
||||||
}
|
|
||||||
|
|
||||||
return revokeToken(params)
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
store.commit('clearCurrentUser')
|
|
||||||
store.dispatch('disconnectFromSocket')
|
|
||||||
store.dispatch('stopFetchingTimeline', 'friends')
|
|
||||||
store.dispatch('stopFetchingNotifications')
|
|
||||||
useListsStore().stopFetching()
|
|
||||||
useBookmarkFoldersStore().stopFetching()
|
|
||||||
store.dispatch('stopFetchingFollowRequests')
|
|
||||||
store.commit('clearNotifications')
|
|
||||||
store.commit('resetStatuses')
|
|
||||||
useChatsStore().resetChats()
|
|
||||||
oauth.clearToken()
|
|
||||||
Cookies.remove('__Host-pleroma_key', { path: '/' })
|
|
||||||
useInterfaceStore().setLastTimeline('public-timeline')
|
|
||||||
useInterfaceStore().setLayoutWidth(windowWidth())
|
|
||||||
useInterfaceStore().setLayoutHeight(windowHeight())
|
|
||||||
})
|
|
||||||
},
|
|
||||||
loginUser(store, accessToken) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const commit = store.commit
|
|
||||||
const dispatch = store.dispatch
|
|
||||||
|
|
||||||
commit('beginLogin')
|
|
||||||
|
|
||||||
verifyCredentials({
|
|
||||||
credentials: useOAuthStore().token,
|
|
||||||
})
|
|
||||||
.then(({ data: user }) => {
|
|
||||||
// user.credentials = userCredentials
|
|
||||||
user.credentials = accessToken
|
|
||||||
user.blockIds = []
|
|
||||||
user.muteIds = []
|
|
||||||
user.domainMutes = []
|
|
||||||
commit('setCurrentUser', user)
|
|
||||||
|
|
||||||
useSyncConfigStore()
|
|
||||||
.initSyncConfig(user)
|
|
||||||
.then(() => {
|
|
||||||
useInterfaceStore()
|
|
||||||
.applyTheme()
|
|
||||||
.catch((e) => {
|
|
||||||
console.error('Error setting theme', e)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
useUserHighlightStore().initUserHighlight(user)
|
|
||||||
commit('addNewUsers', [user])
|
|
||||||
|
|
||||||
useEmojiStore().fetchEmoji()
|
|
||||||
|
|
||||||
getNotificationPermission().then((permission) =>
|
|
||||||
useInterfaceStore().setNotificationPermission(permission),
|
|
||||||
)
|
|
||||||
|
|
||||||
// Do server-side storage migrations
|
|
||||||
|
|
||||||
// Debug snippet to clean up storage and reset migrations
|
|
||||||
/*
|
|
||||||
// Reset wordfilter
|
|
||||||
Object.keys(
|
|
||||||
useSyncConfigStore().prefsStorage.simple.muteFilters
|
|
||||||
).forEach(key => {
|
|
||||||
useSyncConfigStore().unsetSimplePrefAndSave({ path: 'muteFilters.' + key, value: null })
|
|
||||||
})
|
|
||||||
|
|
||||||
// Reset flag to 0 to re-run migrations
|
|
||||||
useSyncConfigStore().setFlag({ flag: 'configMigration', value: 0 })
|
|
||||||
/**/
|
|
||||||
|
|
||||||
if (user.token) {
|
|
||||||
dispatch('setWsToken', user.token)
|
|
||||||
|
|
||||||
// Initialize the shout socket.
|
|
||||||
dispatch('initializeSocket')
|
|
||||||
}
|
|
||||||
|
|
||||||
const startPolling = () => {
|
|
||||||
// Start getting fresh posts.
|
|
||||||
dispatch('startFetchingTimeline', { timeline: 'friends' })
|
|
||||||
|
|
||||||
// Start fetching notifications
|
|
||||||
dispatch('startFetchingNotifications')
|
|
||||||
|
|
||||||
if (useInstanceCapabilitiesStore().pleromaChatMessagesAvailable) {
|
|
||||||
// Start fetching chats
|
|
||||||
dispatch('startFetchingChats')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
useListsStore().startFetching()
|
|
||||||
useBookmarkFoldersStore().startFetching()
|
|
||||||
|
|
||||||
if (user.locked) {
|
|
||||||
dispatch('startFetchingFollowRequests')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (useMergedConfigStore().mergedConfig.useStreamingApi) {
|
|
||||||
dispatch('fetchTimeline', {
|
|
||||||
timeline: 'friends',
|
|
||||||
sinceId: null,
|
|
||||||
})
|
|
||||||
dispatch('fetchNotifications', { sinceId: null })
|
|
||||||
dispatch('enableMastoSockets', true)
|
|
||||||
.catch((error) => {
|
|
||||||
console.error(
|
|
||||||
'Failed initializing MastoAPI Streaming socket',
|
|
||||||
error,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
dispatch('fetchChats', { latest: true })
|
|
||||||
setTimeout(
|
|
||||||
() => dispatch('setNotificationsSilence', false),
|
|
||||||
10000,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
startPolling()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start fetching things that don't need to block the UI
|
|
||||||
useAnnouncementsStore().startFetchingAnnouncements()
|
|
||||||
|
|
||||||
dispatch('fetchMutes')
|
|
||||||
dispatch('loadDrafts')
|
|
||||||
|
|
||||||
useInterfaceStore().setLayoutWidth(windowWidth())
|
|
||||||
useInterfaceStore().setLayoutHeight(windowHeight())
|
|
||||||
|
|
||||||
// Fetch our friends
|
|
||||||
fetchFriends({ id: user.id }).then(({ data: friends }) =>
|
|
||||||
commit('addNewUsers', friends),
|
|
||||||
)
|
|
||||||
commit('endLogin')
|
|
||||||
resolve()
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error(error)
|
|
||||||
|
|
||||||
// Authentication failed
|
|
||||||
commit('endLogin')
|
|
||||||
|
|
||||||
// remove authentication token on client/authentication errors
|
|
||||||
if ([400, 401, 403, 422].includes(error.statusCode)) {
|
|
||||||
useOAuthStore().clearToken()
|
|
||||||
}
|
|
||||||
|
|
||||||
commit('endLogin')
|
|
||||||
if (error.tatusCode === 401) {
|
|
||||||
throw new Error('Wrong username or password', error)
|
|
||||||
} else {
|
|
||||||
throw new Error('An error occurred, please try again', error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
export default users
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
import { showDesktopNotification } from '../desktop_notification_utils/desktop_notification_utils.js'
|
import { showDesktopNotification } from '../desktop_notification_utils/desktop_notification_utils.js'
|
||||||
|
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
export const maybeShowChatNotification = (chat) => {
|
export const maybeShowChatNotification = (chat) => {
|
||||||
if (!chat.lastMessage) return
|
if (!chat.lastMessage) return
|
||||||
if (window.vuex.state.users.currentUser.id === chat.lastMessage.account_id)
|
if (useUsersStore().currentUser.id === chat.lastMessage.account_id) return
|
||||||
return
|
|
||||||
|
|
||||||
const opts = {
|
const opts = {
|
||||||
tag: chat.lastMessage.id,
|
tag: chat.lastMessage.id,
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ export const parseUser = (data) => {
|
||||||
|
|
||||||
output.screen_name = data.acct
|
output.screen_name = data.acct
|
||||||
output.fqn = data.fqn
|
output.fqn = data.fqn
|
||||||
|
output.url = data.url
|
||||||
output.statusnet_profile_url = data.url
|
output.statusnet_profile_url = data.url
|
||||||
|
|
||||||
if (Object.hasOwn(data, 'mute_expires_at')) {
|
if (Object.hasOwn(data, 'mute_expires_at')) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import { map } from 'lodash'
|
import { map } from 'lodash'
|
||||||
|
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
editStatus as apiEditStatus,
|
editStatus as apiEditStatus,
|
||||||
postStatus as apiPostStatus,
|
postStatus as apiPostStatus,
|
||||||
|
|
@ -24,7 +26,7 @@ const postStatus = ({
|
||||||
const mediaIds = map(media, 'id')
|
const mediaIds = map(media, 'id')
|
||||||
|
|
||||||
return apiPostStatus({
|
return apiPostStatus({
|
||||||
credentials: store.state.users.currentUser.credentials,
|
credentials: useUsersStore().currentUser.credentials,
|
||||||
status,
|
status,
|
||||||
spoilerText,
|
spoilerText,
|
||||||
visibility,
|
visibility,
|
||||||
|
|
@ -63,7 +65,7 @@ const editStatus = ({
|
||||||
|
|
||||||
return apiEditStatus({
|
return apiEditStatus({
|
||||||
id: statusId,
|
id: statusId,
|
||||||
credentials: store.state.users.currentUser.credentials,
|
credentials: useUsersStore().currentUser.credentials,
|
||||||
status,
|
status,
|
||||||
spoilerText,
|
spoilerText,
|
||||||
sensitive,
|
sensitive,
|
||||||
|
|
@ -90,12 +92,12 @@ const editStatus = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
const uploadMedia = ({ store, formData }) => {
|
const uploadMedia = ({ store, formData }) => {
|
||||||
const credentials = store.state.users.currentUser.credentials
|
const credentials = useUsersStore().currentUser.credentials
|
||||||
return apiUploadMedia({ credentials, formData }).then(({ data }) => data)
|
return apiUploadMedia({ credentials, formData }).then(({ data }) => data)
|
||||||
}
|
}
|
||||||
|
|
||||||
const setMediaDescription = ({ store, id, description }) => {
|
const setMediaDescription = ({ store, id, description }) => {
|
||||||
const credentials = store.state.users.currentUser.credentials
|
const credentials = useUsersStore().currentUser.credentials
|
||||||
return apiSetMediaDescription({ credentials, id, description }).then(
|
return apiSetMediaDescription({ credentials, id, description }).then(
|
||||||
({ data }) => data,
|
({ data }) => data,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { promiseInterval } from '../promise_interval/promise_interval.js'
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { fetchTimeline } from 'src/api/timelines.js'
|
import { fetchTimeline } from 'src/api/timelines.js'
|
||||||
|
|
||||||
|
|
@ -48,7 +49,7 @@ const fetchAndUpdate = ({
|
||||||
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
|
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
|
||||||
const { hideMutedPosts, replyVisibility } =
|
const { hideMutedPosts, replyVisibility } =
|
||||||
useMergedConfigStore().mergedConfig
|
useMergedConfigStore().mergedConfig
|
||||||
const loggedIn = !!rootState.users.currentUser
|
const loggedIn = !!useUsersStore().currentUser
|
||||||
|
|
||||||
if (older) {
|
if (older) {
|
||||||
// When minId = 0 we need to fetch without maxId param
|
// When minId = 0 we need to fetch without maxId param
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { dismissAnnouncement, getAnnouncements } from 'src/api/user.js'
|
import { dismissAnnouncement, getAnnouncements } from 'src/api/user.js'
|
||||||
|
|
||||||
|
|
@ -16,7 +17,7 @@ export const useAnnouncementsStore = defineStore('announcements', {
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
unreadAnnouncementCount() {
|
unreadAnnouncementCount() {
|
||||||
if (!window.vuex.state.users.currentUser) {
|
if (!useUsersStore().currentUser) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,7 +31,7 @@ export const useAnnouncementsStore = defineStore('announcements', {
|
||||||
async fetchAnnouncements() {
|
async fetchAnnouncements() {
|
||||||
if (!this.supportsAnnouncements) return
|
if (!this.supportsAnnouncements) return
|
||||||
|
|
||||||
const currentUser = window.vuex.state.users.currentUser
|
const currentUser = useUsersStore().currentUser
|
||||||
const isAdmin =
|
const isAdmin =
|
||||||
currentUser &&
|
currentUser &&
|
||||||
currentUser.privileges.has('announcements_manage_announcements')
|
currentUser.privileges.has('announcements_manage_announcements')
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const PASSWORD_STRATEGY = 'password'
|
const PASSWORD_STRATEGY = 'password'
|
||||||
const TOKEN_STRATEGY = 'token'
|
const TOKEN_STRATEGY = 'token'
|
||||||
|
|
@ -63,7 +64,7 @@ export const useAuthFlowStore = defineStore('authFlow', {
|
||||||
},
|
},
|
||||||
async login({ access_token: accessToken }) {
|
async login({ access_token: accessToken }) {
|
||||||
useOAuthStore().setToken(accessToken)
|
useOAuthStore().setToken(accessToken)
|
||||||
await window.vuex.dispatch('loginUser', accessToken, { root: true })
|
useUsersStore().loginUser(accessToken, { root: true })
|
||||||
this.resetState()
|
this.resetState()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { defineStore } from 'pinia'
|
||||||
|
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { listEmojiPacks } from 'src/api/public.js'
|
import { listEmojiPacks } from 'src/api/public.js'
|
||||||
import { ensureFinalFallback } from 'src/i18n/languages.js'
|
import { ensureFinalFallback } from 'src/i18n/languages.js'
|
||||||
|
|
@ -194,7 +195,7 @@ export const useEmojiStore = defineStore('emoji', {
|
||||||
},
|
},
|
||||||
|
|
||||||
async getAdminPacks(instance, listFunction) {
|
async getAdminPacks(instance, listFunction) {
|
||||||
const currentUser = window.vuex.state.users.currentUser
|
const currentUser = useUsersStore().currentUser
|
||||||
|
|
||||||
if (!currentUser.rights.admin) return
|
if (!currentUser.rights.admin) return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import {
|
||||||
} from '../modules/default_config_state.js'
|
} from '../modules/default_config_state.js'
|
||||||
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { fetchKnownDomains } from 'src/api/public.js'
|
import { fetchKnownDomains } from 'src/api/public.js'
|
||||||
|
|
||||||
|
|
@ -212,7 +213,7 @@ export const useInstanceStore = defineStore('instance', {
|
||||||
async getKnownDomains() {
|
async getKnownDomains() {
|
||||||
try {
|
try {
|
||||||
const { data } = await fetchKnownDomains({
|
const { data } = await fetchKnownDomains({
|
||||||
credentials: window.vuex.state.users.currentUser.credentials,
|
credentials: useUsersStore().currentUser.credentials,
|
||||||
})
|
})
|
||||||
this.knownDomains = data
|
this.knownDomains = data
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import { deserialize } from '../services/theme_data/iss_deserializer.js'
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CURRENT_VERSION,
|
CURRENT_VERSION,
|
||||||
|
|
@ -245,7 +246,7 @@ export const useInterfaceStore = defineStore('interface', {
|
||||||
const mobileLayout = width <= 800
|
const mobileLayout = width <= 800
|
||||||
const normalOrMobile = mobileLayout ? 'mobile' : 'normal'
|
const normalOrMobile = mobileLayout ? 'mobile' : 'normal'
|
||||||
const { thirdColumnMode } = useMergedConfigStore().mergedConfig
|
const { thirdColumnMode } = useMergedConfigStore().mergedConfig
|
||||||
if (thirdColumnMode === 'none' || !window.vuex.state.users.currentUser) {
|
if (thirdColumnMode === 'none' || !useUsersStore().currentUser) {
|
||||||
this.layoutType = normalOrMobile
|
this.layoutType = normalOrMobile
|
||||||
} else {
|
} else {
|
||||||
const wideLayout = width >= 1300
|
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 { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { updateProfileJSON } from 'src/api/user.js'
|
import { updateProfileJSON } from 'src/api/user.js'
|
||||||
import { storage } from 'src/lib/storage.js'
|
import { storage } from 'src/lib/storage.js'
|
||||||
|
|
@ -807,7 +808,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
||||||
pushSyncConfig({ force = false } = {}) {
|
pushSyncConfig({ force = false } = {}) {
|
||||||
const needPush = this.dirty || force
|
const needPush = this.dirty || force
|
||||||
if (!needPush) return
|
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 } }
|
const params = { pleroma_settings_store: { 'pleroma-fe': this.cache } }
|
||||||
updateProfileJSON({
|
updateProfileJSON({
|
||||||
params,
|
params,
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import { defineStore } from 'pinia'
|
||||||
import { toRaw } from 'vue'
|
import { toRaw } from 'vue'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import { updateProfileJSON } from 'src/api/user.js'
|
import { updateProfileJSON } from 'src/api/user.js'
|
||||||
import { storage } from 'src/lib/storage.js'
|
import { storage } from 'src/lib/storage.js'
|
||||||
|
|
@ -328,7 +329,7 @@ export const useUserHighlightStore = defineStore('user_highlight', {
|
||||||
pushHighlight({ force = false } = {}) {
|
pushHighlight({ force = false } = {}) {
|
||||||
const needPush = this.dirty || force
|
const needPush = this.dirty || force
|
||||||
if (!needPush) return
|
if (!needPush) return
|
||||||
this.updateCache({ username: window.vuex.state.users.currentUser.fqn })
|
this.updateCache({ username: useUsersStore().currentUser.fqn })
|
||||||
const params = {
|
const params = {
|
||||||
pleroma_settings_store: { user_highlight: this.cache },
|
pleroma_settings_store: { user_highlight: this.cache },
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,18 +59,16 @@ const getNotificationPermission = async () => {
|
||||||
return Notification.permission
|
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', {
|
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: {
|
getters: {
|
||||||
loggedIn: (state) => !!state.currentUser,
|
loggedIn: (state) => !!state.currentUser,
|
||||||
findUser: (state) => (query) => {
|
findUser: (state) => (query) => {
|
||||||
|
|
@ -141,7 +139,7 @@ export const useUsersStore = defineStore('users', {
|
||||||
},
|
},
|
||||||
addNewUsers(users, timestamp) {
|
addNewUsers(users, timestamp) {
|
||||||
users.forEach((user) => {
|
users.forEach((user) => {
|
||||||
const existing = users.get(user.id) ?? {}
|
const existing = this.users.get(user.id) ?? {}
|
||||||
|
|
||||||
const { relationship, ...old } = existing
|
const { relationship, ...old } = existing
|
||||||
const { relationshop, ...neu } = user
|
const { relationshop, ...neu } = user
|
||||||
|
|
@ -150,6 +148,10 @@ export const useUsersStore = defineStore('users', {
|
||||||
this.users.set(user.id, newUser)
|
this.users.set(user.id, newUser)
|
||||||
this.usersByName.set(user.screen_name.toLowerCase(), newUser)
|
this.usersByName.set(user.screen_name.toLowerCase(), newUser)
|
||||||
this.usersByURL.set(user.url.toLowerCase(), newUser)
|
this.usersByURL.set(user.url.toLowerCase(), newUser)
|
||||||
|
|
||||||
|
if (user.id === this.currentUser.id) {
|
||||||
|
this.currentUser = newUser
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateUserRelationship(relationships) {
|
updateUserRelationship(relationships) {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import { mountOpts } from '../../../fixtures/setup_test'
|
||||||
|
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
const currentUser = {
|
const currentUser = {
|
||||||
id: 'current-user',
|
id: 'current-user',
|
||||||
|
|
@ -35,7 +36,7 @@ const replyMountOpts = (props) =>
|
||||||
mountOpts({
|
mountOpts({
|
||||||
props,
|
props,
|
||||||
afterStore(store) {
|
afterStore(store) {
|
||||||
store.state.users.currentUser = currentUser
|
useUsersStore().currentUser = currentUser
|
||||||
store.state.statuses.allStatusesObject = {
|
store.state.statuses.allStatusesObject = {
|
||||||
[repliedStatus.id]: repliedStatus,
|
[repliedStatus.id]: repliedStatus,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue