Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
f6cf509a04
229 changed files with 9798 additions and 5400 deletions
|
@ -1,4 +1,4 @@
|
|||
import Vue from 'vue'
|
||||
import { reactive } from 'vue'
|
||||
import { find, omitBy, orderBy, sumBy } from 'lodash'
|
||||
import chatService from '../services/chat_service/chat_service.js'
|
||||
import { parseChat, parseChatMessage } from '../services/entity_normalizer/entity_normalizer.service.js'
|
||||
|
@ -13,8 +13,8 @@ const emptyChatList = () => ({
|
|||
const defaultState = {
|
||||
chatList: emptyChatList(),
|
||||
chatListFetcher: null,
|
||||
openedChats: {},
|
||||
openedChatMessageServices: {},
|
||||
openedChats: reactive({}),
|
||||
openedChatMessageServices: reactive({}),
|
||||
fetcher: undefined,
|
||||
currentChatId: null,
|
||||
lastReadMessageId: null
|
||||
|
@ -137,10 +137,10 @@ const chats = {
|
|||
},
|
||||
addOpenedChat (state, { _dispatch, chat }) {
|
||||
state.currentChatId = chat.id
|
||||
Vue.set(state.openedChats, chat.id, chat)
|
||||
state.openedChats[chat.id] = chat
|
||||
|
||||
if (!state.openedChatMessageServices[chat.id]) {
|
||||
Vue.set(state.openedChatMessageServices, chat.id, chatService.empty(chat.id))
|
||||
state.openedChatMessageServices[chat.id] = chatService.empty(chat.id)
|
||||
}
|
||||
},
|
||||
setCurrentChatId (state, { chatId }) {
|
||||
|
@ -160,7 +160,7 @@ const chats = {
|
|||
}
|
||||
} else {
|
||||
state.chatList.data.push(updatedChat)
|
||||
Vue.set(state.chatList.idStore, updatedChat.id, updatedChat)
|
||||
state.chatList.idStore[updatedChat.id] = updatedChat
|
||||
}
|
||||
})
|
||||
},
|
||||
|
@ -172,7 +172,7 @@ const chats = {
|
|||
chat.updated_at = updatedChat.updated_at
|
||||
}
|
||||
if (!chat) { state.chatList.data.unshift(updatedChat) }
|
||||
Vue.set(state.chatList.idStore, updatedChat.id, updatedChat)
|
||||
state.chatList.idStore[updatedChat.id] = updatedChat
|
||||
},
|
||||
deleteChat (state, { _dispatch, id, _rootGetters }) {
|
||||
state.chats.data = state.chats.data.filter(conversation =>
|
||||
|
@ -186,8 +186,8 @@ const chats = {
|
|||
commit('setChatListFetcher', { fetcher: undefined })
|
||||
for (const chatId in state.openedChats) {
|
||||
chatService.clear(state.openedChatMessageServices[chatId])
|
||||
Vue.delete(state.openedChats, chatId)
|
||||
Vue.delete(state.openedChatMessageServices, chatId)
|
||||
delete state.openedChats[chatId]
|
||||
delete state.openedChatMessageServices[chatId]
|
||||
}
|
||||
},
|
||||
setChatsLoading (state, { value }) {
|
||||
|
@ -215,8 +215,8 @@ const chats = {
|
|||
for (const chatId in state.openedChats) {
|
||||
if (currentChatId !== chatId) {
|
||||
chatService.clear(state.openedChatMessageServices[chatId])
|
||||
Vue.delete(state.openedChats, chatId)
|
||||
Vue.delete(state.openedChatMessageServices, chatId)
|
||||
delete state.openedChats[chatId]
|
||||
delete state.openedChatMessageServices[chatId]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import { set, delete as del } from 'vue'
|
||||
import Cookies from 'js-cookie'
|
||||
import { setPreset, applyTheme } from '../services/style_setter/style_setter.js'
|
||||
import messages from '../i18n/messages'
|
||||
import localeService from '../services/locale/locale.service.js'
|
||||
|
||||
const BACKEND_LANGUAGE_COOKIE_NAME = 'userLanguage'
|
||||
|
||||
const browserLocale = (window.navigator.language || 'en').split('-')[0]
|
||||
|
||||
|
@ -11,10 +14,14 @@ const browserLocale = (window.navigator.language || 'en').split('-')[0]
|
|||
*/
|
||||
export const multiChoiceProperties = [
|
||||
'postContentType',
|
||||
'subjectLineBehavior'
|
||||
'subjectLineBehavior',
|
||||
'conversationDisplay', // tree | linear
|
||||
'conversationOtherRepliesButton', // below | inside
|
||||
'mentionLinkDisplay' // short | full_for_remote | full
|
||||
]
|
||||
|
||||
export const defaultState = {
|
||||
expertLevel: 0, // used to track which settings to show and hide
|
||||
colors: {},
|
||||
theme: undefined,
|
||||
customTheme: undefined,
|
||||
|
@ -24,6 +31,9 @@ export const defaultState = {
|
|||
hideShoutbox: false,
|
||||
// bad name: actually hides posts of muted USERS
|
||||
hideMutedPosts: undefined, // instance default
|
||||
hideMutedThreads: undefined, // instance default
|
||||
hideWordFilteredPosts: undefined, // instance default
|
||||
muteBotStatuses: undefined, // instance default
|
||||
collapseMessageWithSubject: undefined, // instance default
|
||||
padEmoji: true,
|
||||
hideAttachments: false,
|
||||
|
@ -38,8 +48,9 @@ export const defaultState = {
|
|||
alwaysShowNewPostButton: false,
|
||||
autohideFloatingPostButton: false,
|
||||
pauseOnUnfocused: true,
|
||||
stopGifs: false,
|
||||
stopGifs: true,
|
||||
replyVisibility: 'all',
|
||||
thirdColumnMode: 'notifications',
|
||||
notificationVisibility: {
|
||||
follows: true,
|
||||
mentions: true,
|
||||
|
@ -48,7 +59,8 @@ export const defaultState = {
|
|||
moves: true,
|
||||
emojiReactions: true,
|
||||
followRequest: true,
|
||||
chatMention: true
|
||||
chatMention: true,
|
||||
polls: true
|
||||
},
|
||||
webPushNotifications: false,
|
||||
muteWords: [],
|
||||
|
@ -66,13 +78,28 @@ export const defaultState = {
|
|||
hideFilteredStatuses: undefined, // instance default
|
||||
playVideosInModal: false,
|
||||
useOneClickNsfw: false,
|
||||
useContainFit: false,
|
||||
useContainFit: true,
|
||||
disableStickyHeaders: false,
|
||||
showScrollbars: false,
|
||||
greentext: undefined, // instance default
|
||||
useAtIcon: undefined, // instance default
|
||||
mentionLinkDisplay: undefined, // instance default
|
||||
mentionLinkShowTooltip: undefined, // instance default
|
||||
mentionLinkShowAvatar: undefined, // instance default
|
||||
mentionLinkFadeDomain: undefined, // instance default
|
||||
mentionLinkShowYous: undefined, // instance default
|
||||
mentionLinkBoldenYou: undefined, // instance default
|
||||
hidePostStats: undefined, // instance default
|
||||
hideBotIndication: undefined, // instance default
|
||||
hideUserStats: undefined, // instance default
|
||||
virtualScrolling: undefined, // instance default
|
||||
sensitiveByDefault: undefined, // instance default
|
||||
sensitiveIfSubject: undefined
|
||||
sensitiveIfSubject: undefined,
|
||||
conversationDisplay: undefined, // instance default
|
||||
conversationTreeAdvanced: undefined, // instance default
|
||||
conversationOtherRepliesButton: undefined, // instance default
|
||||
conversationTreeFadeAncestors: undefined, // instance default
|
||||
maxDepthInThread: undefined // instance default
|
||||
}
|
||||
|
||||
// caching the instance default properties
|
||||
|
@ -103,14 +130,14 @@ const config = {
|
|||
},
|
||||
mutations: {
|
||||
setOption (state, { name, value }) {
|
||||
set(state, name, value)
|
||||
state[name] = value
|
||||
},
|
||||
setHighlight (state, { user, color, type }) {
|
||||
const data = this.state.config.highlight[user]
|
||||
if (color || type) {
|
||||
set(state.highlight, user, { color: color || data.color, type: type || data.type })
|
||||
state.highlight[user] = { color: color || data.color, type: type || data.type }
|
||||
} else {
|
||||
del(state.highlight, user)
|
||||
delete state.highlight[user]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -144,6 +171,10 @@ const config = {
|
|||
break
|
||||
case 'interfaceLanguage':
|
||||
messages.setLanguage(this.getters.i18n, value)
|
||||
Cookies.set(BACKEND_LANGUAGE_COOKIE_NAME, localeService.internalToBackendLocale(value))
|
||||
break
|
||||
case 'thirdColumnMode':
|
||||
dispatch('setLayoutWidth', undefined)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { set } from 'vue'
|
||||
import { getPreset, applyTheme } from '../services/style_setter/style_setter.js'
|
||||
import { CURRENT_VERSION } from '../services/theme_data/theme_data.service.js'
|
||||
import apiService from '../services/api/api.service.js'
|
||||
|
@ -20,11 +19,23 @@ const defaultState = {
|
|||
background: '/static/aurora_borealis.jpg',
|
||||
collapseMessageWithSubject: false,
|
||||
greentext: false,
|
||||
useAtIcon: false,
|
||||
mentionLinkDisplay: 'short',
|
||||
mentionLinkShowTooltip: true,
|
||||
mentionLinkShowAvatar: false,
|
||||
mentionLinkFadeDomain: true,
|
||||
mentionLinkShowYous: false,
|
||||
mentionLinkBoldenYou: true,
|
||||
hideFilteredStatuses: false,
|
||||
// bad name: actually hides posts of muted USERS
|
||||
hideMutedPosts: false,
|
||||
hideMutedThreads: true,
|
||||
hideWordFilteredPosts: false,
|
||||
hidePostStats: false,
|
||||
hideBotIndication: false,
|
||||
hideSitename: false,
|
||||
hideUserStats: false,
|
||||
muteBotStatuses: false,
|
||||
loginMethod: 'password',
|
||||
logo: '/static/logo.svg',
|
||||
logoMargin: '.2em',
|
||||
|
@ -44,6 +55,11 @@ const defaultState = {
|
|||
virtualScrolling: true,
|
||||
sensitiveByDefault: false,
|
||||
sensitiveIfSubject: false,
|
||||
conversationDisplay: 'linear',
|
||||
conversationTreeAdvanced: false,
|
||||
conversationOtherRepliesButton: 'below',
|
||||
conversationTreeFadeAncestors: false,
|
||||
maxDepthInThread: 6,
|
||||
|
||||
// Nasty stuff
|
||||
customEmoji: [],
|
||||
|
@ -86,7 +102,7 @@ const instance = {
|
|||
mutations: {
|
||||
setInstanceOption (state, { name, value }) {
|
||||
if (typeof value !== 'undefined') {
|
||||
set(state, name, value)
|
||||
state[name] = value
|
||||
}
|
||||
},
|
||||
setKnownDomains (state, domains) {
|
||||
|
@ -98,6 +114,9 @@ const instance = {
|
|||
return instanceDefaultProperties
|
||||
.map(key => [key, state[key]])
|
||||
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {})
|
||||
},
|
||||
instanceDomain (state) {
|
||||
return new URL(state.server).hostname
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { set, delete as del } from 'vue'
|
||||
|
||||
const defaultState = {
|
||||
settingsModalState: 'hidden',
|
||||
settingsModalLoaded: false,
|
||||
|
@ -15,7 +13,7 @@ const defaultState = {
|
|||
window.CSS.supports('-webkit-filter', 'drop-shadow(0 0)')
|
||||
)
|
||||
},
|
||||
mobileLayout: false,
|
||||
layoutType: 'normal',
|
||||
globalNotices: [],
|
||||
layoutHeight: 0,
|
||||
lastTimeline: null
|
||||
|
@ -29,18 +27,17 @@ const interfaceMod = {
|
|||
if (state.noticeClearTimeout) {
|
||||
clearTimeout(state.noticeClearTimeout)
|
||||
}
|
||||
set(state.settings, 'currentSaveStateNotice', { error: false, data: success })
|
||||
set(state.settings, 'noticeClearTimeout',
|
||||
setTimeout(() => del(state.settings, 'currentSaveStateNotice'), 2000))
|
||||
state.settings.currentSaveStateNotice = { error: false, data: success }
|
||||
state.settings.noticeClearTimeout = setTimeout(() => delete state.settings.currentSaveStateNotice, 2000)
|
||||
} else {
|
||||
set(state.settings, 'currentSaveStateNotice', { error: true, errorData: error })
|
||||
state.settings.currentSaveStateNotice = { error: true, errorData: error }
|
||||
}
|
||||
},
|
||||
setNotificationPermission (state, permission) {
|
||||
state.notificationPermission = permission
|
||||
},
|
||||
setMobileLayout (state, value) {
|
||||
state.mobileLayout = value
|
||||
setLayoutType (state, value) {
|
||||
state.layoutType = value
|
||||
},
|
||||
closeSettingsModal (state) {
|
||||
state.settingsModalState = 'hidden'
|
||||
|
@ -75,6 +72,9 @@ const interfaceMod = {
|
|||
setLayoutHeight (state, value) {
|
||||
state.layoutHeight = value
|
||||
},
|
||||
setLayoutWidth (state, value) {
|
||||
state.layoutWidth = value
|
||||
},
|
||||
setLastTimeline (state, value) {
|
||||
state.lastTimeline = value
|
||||
}
|
||||
|
@ -89,9 +89,6 @@ const interfaceMod = {
|
|||
setNotificationPermission ({ commit }, permission) {
|
||||
commit('setNotificationPermission', permission)
|
||||
},
|
||||
setMobileLayout ({ commit }, value) {
|
||||
commit('setMobileLayout', value)
|
||||
},
|
||||
closeSettingsModal ({ commit }) {
|
||||
commit('closeSettingsModal')
|
||||
},
|
||||
|
@ -109,7 +106,7 @@ const interfaceMod = {
|
|||
commit('openSettingsModal')
|
||||
},
|
||||
pushGlobalNotice (
|
||||
{ commit, dispatch },
|
||||
{ commit, dispatch, state },
|
||||
{
|
||||
messageKey,
|
||||
messageArgs = {},
|
||||
|
@ -121,11 +118,14 @@ const interfaceMod = {
|
|||
messageArgs,
|
||||
level
|
||||
}
|
||||
if (timeout) {
|
||||
setTimeout(() => dispatch('removeGlobalNotice', notice), timeout)
|
||||
}
|
||||
commit('pushGlobalNotice', notice)
|
||||
return notice
|
||||
// Adding a new element to array wraps it in a Proxy, which breaks the comparison
|
||||
// TODO: Generate UUID or something instead or relying on !== operator?
|
||||
const newNotice = state.globalNotices[state.globalNotices.length - 1]
|
||||
if (timeout) {
|
||||
setTimeout(() => dispatch('removeGlobalNotice', newNotice), timeout)
|
||||
}
|
||||
return newNotice
|
||||
},
|
||||
removeGlobalNotice ({ commit }, notice) {
|
||||
commit('removeGlobalNotice', notice)
|
||||
|
@ -133,6 +133,24 @@ const interfaceMod = {
|
|||
setLayoutHeight ({ commit }, value) {
|
||||
commit('setLayoutHeight', value)
|
||||
},
|
||||
// value is optional, assuming it was cached prior
|
||||
setLayoutWidth ({ commit, state, rootGetters, rootState }, value) {
|
||||
let width = value
|
||||
if (value !== undefined) {
|
||||
commit('setLayoutWidth', value)
|
||||
} else {
|
||||
width = state.layoutWidth
|
||||
}
|
||||
const mobileLayout = width <= 800
|
||||
const normalOrMobile = mobileLayout ? 'mobile' : 'normal'
|
||||
const { thirdColumnMode } = rootGetters.mergedConfig
|
||||
if (thirdColumnMode === 'none' || !rootState.users.currentUser) {
|
||||
commit('setLayoutType', normalOrMobile)
|
||||
} else {
|
||||
const wideLayout = width >= 1300
|
||||
commit('setLayoutType', wideLayout ? 'wide' : normalOrMobile)
|
||||
}
|
||||
},
|
||||
setLastTimeline ({ commit }, value) {
|
||||
commit('setLastTimeline', value)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import fileTypeService from '../services/file_type/file_type.service.js'
|
||||
const supportedTypes = new Set(['image', 'video', 'audio', 'flash'])
|
||||
|
||||
const mediaViewer = {
|
||||
state: {
|
||||
|
@ -10,7 +11,7 @@ const mediaViewer = {
|
|||
setMedia (state, media) {
|
||||
state.media = media
|
||||
},
|
||||
setCurrent (state, index) {
|
||||
setCurrentMedia (state, index) {
|
||||
state.activated = true
|
||||
state.currentIndex = index
|
||||
},
|
||||
|
@ -22,13 +23,13 @@ const mediaViewer = {
|
|||
setMedia ({ commit }, attachments) {
|
||||
const media = attachments.filter(attachment => {
|
||||
const type = fileTypeService.fileType(attachment.mimetype)
|
||||
return type === 'image' || type === 'video' || type === 'audio'
|
||||
return supportedTypes.has(type)
|
||||
})
|
||||
commit('setMedia', media)
|
||||
},
|
||||
setCurrent ({ commit, state }, current) {
|
||||
setCurrentMedia ({ commit, state }, current) {
|
||||
const index = state.media.indexOf(current)
|
||||
commit('setCurrent', index || 0)
|
||||
commit('setCurrentMedia', index || 0)
|
||||
},
|
||||
closeMediaViewer ({ commit }) {
|
||||
commit('close')
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { delete as del } from 'vue'
|
||||
|
||||
const oauth = {
|
||||
state: {
|
||||
clientId: false,
|
||||
|
@ -29,7 +27,7 @@ const oauth = {
|
|||
state.userToken = false
|
||||
// state.token is userToken with older name, coming from persistent state
|
||||
// let's clear it as well, since it is being used as a fallback of state.userToken
|
||||
del(state, 'token')
|
||||
delete state.token
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { merge } from 'lodash'
|
||||
import { set } from 'vue'
|
||||
|
||||
const polls = {
|
||||
state: {
|
||||
|
@ -13,25 +12,25 @@ const polls = {
|
|||
// Make expired-state change trigger re-renders properly
|
||||
poll.expired = Date.now() > Date.parse(poll.expires_at)
|
||||
if (existingPoll) {
|
||||
set(state.pollsObject, poll.id, merge(existingPoll, poll))
|
||||
state.pollsObject[poll.id] = merge(existingPoll, poll)
|
||||
} else {
|
||||
set(state.pollsObject, poll.id, poll)
|
||||
state.pollsObject[poll.id] = poll
|
||||
}
|
||||
},
|
||||
trackPoll (state, pollId) {
|
||||
const currentValue = state.trackedPolls[pollId]
|
||||
if (currentValue) {
|
||||
set(state.trackedPolls, pollId, currentValue + 1)
|
||||
state.trackedPolls[pollId] = currentValue + 1
|
||||
} else {
|
||||
set(state.trackedPolls, pollId, 1)
|
||||
state.trackedPolls[pollId] = 1
|
||||
}
|
||||
},
|
||||
untrackPoll (state, pollId) {
|
||||
const currentValue = state.trackedPolls[pollId]
|
||||
if (currentValue) {
|
||||
set(state.trackedPolls, pollId, currentValue - 1)
|
||||
state.trackedPolls[pollId] = currentValue - 1
|
||||
} else {
|
||||
set(state.trackedPolls, pollId, 0)
|
||||
state.trackedPolls[pollId] = 0
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
140
src/modules/serverSideConfig.js
Normal file
140
src/modules/serverSideConfig.js
Normal file
|
@ -0,0 +1,140 @@
|
|||
import { get, set } from 'lodash'
|
||||
|
||||
const defaultApi = ({ rootState, commit }, { path, value }) => {
|
||||
const params = {}
|
||||
set(params, path, value)
|
||||
return rootState
|
||||
.api
|
||||
.backendInteractor
|
||||
.updateProfile({ params })
|
||||
.then(result => {
|
||||
commit('addNewUsers', [result])
|
||||
commit('setCurrentUser', result)
|
||||
})
|
||||
}
|
||||
|
||||
const notificationsApi = ({ rootState, commit }, { path, value, oldValue }) => {
|
||||
const settings = {}
|
||||
set(settings, path, value)
|
||||
return rootState
|
||||
.api
|
||||
.backendInteractor
|
||||
.updateNotificationSettings({ settings })
|
||||
.then(result => {
|
||||
if (result.status === 'success') {
|
||||
commit('confirmServerSideOption', { name, value })
|
||||
} else {
|
||||
commit('confirmServerSideOption', { name, value: oldValue })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Map that stores relation between path for reading (from user profile),
|
||||
* for writing (into API) an what API to use.
|
||||
*
|
||||
* Shorthand - instead of { get, set, api? } object it's possible to use string
|
||||
* in case default api is used and get = set
|
||||
*
|
||||
* If no api is specified, defaultApi is used (see above)
|
||||
*/
|
||||
export const settingsMap = {
|
||||
'defaultScope': 'source.privacy',
|
||||
'defaultNSFW': 'source.sensitive', // BROKEN: pleroma/pleroma#2837
|
||||
'stripRichContent': {
|
||||
get: 'source.pleroma.no_rich_text',
|
||||
set: 'no_rich_text'
|
||||
},
|
||||
// Privacy
|
||||
'locked': 'locked',
|
||||
'acceptChatMessages': {
|
||||
get: 'pleroma.accepts_chat_messages',
|
||||
set: 'accepts_chat_messages'
|
||||
},
|
||||
'allowFollowingMove': {
|
||||
get: 'pleroma.allow_following_move',
|
||||
set: 'allow_following_move'
|
||||
},
|
||||
'discoverable': {
|
||||
get: 'source.pleroma.discoverable',
|
||||
set: 'discoverable'
|
||||
},
|
||||
'hideFavorites': {
|
||||
get: 'pleroma.hide_favorites',
|
||||
set: 'hide_favorites'
|
||||
},
|
||||
'hideFollowers': {
|
||||
get: 'pleroma.hide_followers',
|
||||
set: 'hide_followers'
|
||||
},
|
||||
'hideFollows': {
|
||||
get: 'pleroma.hide_follows',
|
||||
set: 'hide_follows'
|
||||
},
|
||||
'hideFollowersCount': {
|
||||
get: 'pleroma.hide_followers_count',
|
||||
set: 'hide_followers_count'
|
||||
},
|
||||
'hideFollowsCount': {
|
||||
get: 'pleroma.hide_follows_count',
|
||||
set: 'hide_follows_count'
|
||||
},
|
||||
// NotificationSettingsAPIs
|
||||
'webPushHideContents': {
|
||||
get: 'pleroma.notification_settings.hide_notification_contents',
|
||||
set: 'hide_notification_contents',
|
||||
api: notificationsApi
|
||||
},
|
||||
'blockNotificationsFromStrangers': {
|
||||
get: 'pleroma.notification_settings.block_from_strangers',
|
||||
set: 'block_from_strangers',
|
||||
api: notificationsApi
|
||||
}
|
||||
}
|
||||
|
||||
export const defaultState = Object.fromEntries(Object.keys(settingsMap).map(key => [key, null]))
|
||||
|
||||
const serverSideConfig = {
|
||||
state: { ...defaultState },
|
||||
mutations: {
|
||||
confirmServerSideOption (state, { name, value }) {
|
||||
set(state, name, value)
|
||||
},
|
||||
wipeServerSideOption (state, { name }) {
|
||||
set(state, name, null)
|
||||
},
|
||||
wipeAllServerSideOptions (state) {
|
||||
Object.keys(settingsMap).forEach(key => {
|
||||
set(state, key, null)
|
||||
})
|
||||
},
|
||||
// Set the settings based on their path location
|
||||
setCurrentUser (state, user) {
|
||||
Object.entries(settingsMap).forEach((map) => {
|
||||
const [name, value] = map
|
||||
const { get: path = value } = value
|
||||
set(state, name, get(user._original, path))
|
||||
})
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
setServerSideOption ({ rootState, state, commit, dispatch }, { name, value }) {
|
||||
const oldValue = get(state, name)
|
||||
const map = settingsMap[name]
|
||||
if (!map) throw new Error('Invalid server-side setting')
|
||||
const { set: path = map, api = defaultApi } = map
|
||||
commit('wipeServerSideOption', { name })
|
||||
|
||||
api({ rootState, commit }, { path, value, oldValue })
|
||||
.catch((e) => {
|
||||
console.warn('Error setting server-side option:', e)
|
||||
commit('confirmServerSideOption', { name, value: oldValue })
|
||||
})
|
||||
},
|
||||
logout ({ commit }) {
|
||||
commit('wipeAllServerSideOptions')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default serverSideConfig
|
|
@ -1,7 +1,8 @@
|
|||
const shout = {
|
||||
state: {
|
||||
messages: [],
|
||||
channel: { state: '' }
|
||||
channel: { state: '' },
|
||||
joined: false
|
||||
},
|
||||
mutations: {
|
||||
setChannel (state, channel) {
|
||||
|
@ -13,11 +14,23 @@ const shout = {
|
|||
},
|
||||
setMessages (state, messages) {
|
||||
state.messages = messages.slice(-19, 20)
|
||||
},
|
||||
setJoined (state, joined) {
|
||||
state.joined = joined
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
initializeShout (store, socket) {
|
||||
const channel = socket.channel('chat:public')
|
||||
channel.joinPush.receive('ok', () => {
|
||||
store.commit('setJoined', true)
|
||||
})
|
||||
channel.onClose(() => {
|
||||
store.commit('setJoined', false)
|
||||
})
|
||||
channel.onError(() => {
|
||||
store.commit('setJoined', false)
|
||||
})
|
||||
channel.on('new_msg', (msg) => {
|
||||
store.commit('addMessage', msg)
|
||||
})
|
||||
|
|
|
@ -12,7 +12,6 @@ import {
|
|||
isArray,
|
||||
omitBy
|
||||
} from 'lodash'
|
||||
import { set } from 'vue'
|
||||
import {
|
||||
isStatusNotification,
|
||||
isValidNotification,
|
||||
|
@ -92,7 +91,7 @@ const mergeOrAdd = (arr, obj, item) => {
|
|||
// This is a new item, prepare it
|
||||
prepareStatus(item)
|
||||
arr.push(item)
|
||||
set(obj, item.id, item)
|
||||
obj[item.id] = item
|
||||
return { item, new: true }
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +130,7 @@ const addStatusToGlobalStorage = (state, data) => {
|
|||
if (conversationsObject[conversationId]) {
|
||||
conversationsObject[conversationId].push(status)
|
||||
} else {
|
||||
set(conversationsObject, conversationId, [status])
|
||||
conversationsObject[conversationId] = [status]
|
||||
}
|
||||
}
|
||||
return result
|
||||
|
@ -523,7 +522,7 @@ export const mutations = {
|
|||
},
|
||||
addEmojiReactionsBy (state, { id, emojiReactions, currentUser }) {
|
||||
const status = state.allStatusesObject[id]
|
||||
set(status, 'emoji_reactions', emojiReactions)
|
||||
status['emoji_reactions'] = emojiReactions
|
||||
},
|
||||
addOwnReaction (state, { id, emoji, currentUser }) {
|
||||
const status = state.allStatusesObject[id]
|
||||
|
@ -542,9 +541,9 @@ export const mutations = {
|
|||
|
||||
// Update count of existing reaction if it exists, otherwise append at the end
|
||||
if (reactionIndex >= 0) {
|
||||
set(status.emoji_reactions, reactionIndex, newReaction)
|
||||
status.emoji_reactions[reactionIndex] = newReaction
|
||||
} else {
|
||||
set(status, 'emoji_reactions', [...status.emoji_reactions, newReaction])
|
||||
status['emoji_reactions'] = [...status.emoji_reactions, newReaction]
|
||||
}
|
||||
},
|
||||
removeOwnReaction (state, { id, emoji, currentUser }) {
|
||||
|
@ -563,9 +562,9 @@ export const mutations = {
|
|||
}
|
||||
|
||||
if (newReaction.count > 0) {
|
||||
set(status.emoji_reactions, reactionIndex, newReaction)
|
||||
status.emoji_reactions[reactionIndex] = newReaction
|
||||
} else {
|
||||
set(status, 'emoji_reactions', status.emoji_reactions.filter(r => r.name !== emoji))
|
||||
status['emoji_reactions'] = status.emoji_reactions.filter(r => r.name !== emoji)
|
||||
}
|
||||
},
|
||||
updateStatusWithPoll (state, { id, poll }) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
|
||||
import { windowWidth, windowHeight } from '../services/window_utils/window_utils'
|
||||
import oauthApi from '../services/new_api/oauth.js'
|
||||
import { compact, map, each, mergeWith, last, concat, uniq, isArray } from 'lodash'
|
||||
import { set } from 'vue'
|
||||
import { registerPushNotifications, unregisterPushNotifications } from '../services/push/push.js'
|
||||
|
||||
// TODO: Unify with mergeOrAdd in statuses.js
|
||||
|
@ -15,9 +15,9 @@ export const mergeOrAdd = (arr, obj, item) => {
|
|||
} else {
|
||||
// This is a new item, prepare it
|
||||
arr.push(item)
|
||||
set(obj, item.id, item)
|
||||
obj[item.id] = item
|
||||
if (item.screen_name && !item.screen_name.includes('@')) {
|
||||
set(obj, item.screen_name.toLowerCase(), item)
|
||||
obj[item.screen_name.toLowerCase()] = item
|
||||
}
|
||||
return { item, new: true }
|
||||
}
|
||||
|
@ -107,23 +107,23 @@ export const mutations = {
|
|||
const user = state.usersObject[id]
|
||||
const tags = user.tags || []
|
||||
const newTags = tags.concat([tag])
|
||||
set(user, 'tags', newTags)
|
||||
user['tags'] = newTags
|
||||
},
|
||||
untagUser (state, { user: { id }, tag }) {
|
||||
const user = state.usersObject[id]
|
||||
const tags = user.tags || []
|
||||
const newTags = tags.filter(t => t !== tag)
|
||||
set(user, 'tags', newTags)
|
||||
user['tags'] = newTags
|
||||
},
|
||||
updateRight (state, { user: { id }, right, value }) {
|
||||
const user = state.usersObject[id]
|
||||
let newRights = user.rights
|
||||
newRights[right] = value
|
||||
set(user, 'rights', newRights)
|
||||
user['rights'] = newRights
|
||||
},
|
||||
updateActivationStatus (state, { user: { id }, deactivated }) {
|
||||
const user = state.usersObject[id]
|
||||
set(user, 'deactivated', deactivated)
|
||||
user['deactivated'] = deactivated
|
||||
},
|
||||
setCurrentUser (state, user) {
|
||||
state.lastLoginName = user.screen_name
|
||||
|
@ -152,26 +152,26 @@ export const mutations = {
|
|||
clearFriends (state, userId) {
|
||||
const user = state.usersObject[userId]
|
||||
if (user) {
|
||||
set(user, 'friendIds', [])
|
||||
user['friendIds'] = []
|
||||
}
|
||||
},
|
||||
clearFollowers (state, userId) {
|
||||
const user = state.usersObject[userId]
|
||||
if (user) {
|
||||
set(user, 'followerIds', [])
|
||||
user['followerIds'] = []
|
||||
}
|
||||
},
|
||||
addNewUsers (state, users) {
|
||||
each(users, (user) => {
|
||||
if (user.relationship) {
|
||||
set(state.relationships, user.relationship.id, user.relationship)
|
||||
state.relationships[user.relationship.id] = user.relationship
|
||||
}
|
||||
mergeOrAdd(state.users, state.usersObject, user)
|
||||
})
|
||||
},
|
||||
updateUserRelationship (state, relationships) {
|
||||
relationships.forEach((relationship) => {
|
||||
set(state.relationships, relationship.id, relationship)
|
||||
state.relationships[relationship.id] = relationship
|
||||
})
|
||||
},
|
||||
saveBlockIds (state, blockIds) {
|
||||
|
@ -229,7 +229,7 @@ export const mutations = {
|
|||
},
|
||||
setColor (state, { user: { id }, highlighted }) {
|
||||
const user = state.usersObject[id]
|
||||
set(user, 'highlight', highlighted)
|
||||
user['highlight'] = highlighted
|
||||
},
|
||||
signUpPending (state) {
|
||||
state.signUpPending = true
|
||||
|
@ -403,7 +403,7 @@ const users = {
|
|||
toggleActivationStatus ({ rootState, commit }, { user }) {
|
||||
const api = user.deactivated ? rootState.api.backendInteractor.activateUser : rootState.api.backendInteractor.deactivateUser
|
||||
api({ user })
|
||||
.then(({ deactivated }) => commit('updateActivationStatus', { user, deactivated }))
|
||||
.then((user) => { let deactivated = !user.is_active; commit('updateActivationStatus', { user, deactivated }) })
|
||||
},
|
||||
registerPushNotifications (store) {
|
||||
const token = store.state.currentUser.credentials
|
||||
|
@ -517,6 +517,8 @@ const users = {
|
|||
store.commit('resetStatuses')
|
||||
store.dispatch('resetChats')
|
||||
store.dispatch('setLastTimeline', 'public-timeline')
|
||||
store.dispatch('setLayoutWidth', windowWidth())
|
||||
store.dispatch('setLayoutHeight', windowHeight())
|
||||
})
|
||||
},
|
||||
loginUser (store, accessToken) {
|
||||
|
@ -577,6 +579,9 @@ const users = {
|
|||
// Get user mutes
|
||||
store.dispatch('fetchMutes')
|
||||
|
||||
store.dispatch('setLayoutWidth', windowWidth())
|
||||
store.dispatch('setLayoutHeight', windowHeight())
|
||||
|
||||
// Fetch our friends
|
||||
store.rootState.api.backendInteractor.fetchFriends({ id: user.id })
|
||||
.then((friends) => commit('addNewUsers', friends))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue