Merge branch 'develop' into feature/new-user-routes
This commit is contained in:
commit
2211c533dd
93 changed files with 5123 additions and 894 deletions
|
@ -1,5 +1,5 @@
|
|||
import { set, delete as del } from 'vue'
|
||||
import StyleSetter from '../services/style_setter/style_setter.js'
|
||||
import { setPreset, applyTheme } from '../services/style_setter/style_setter.js'
|
||||
|
||||
const browserLocale = (window.navigator.language || 'en').split('-')[0]
|
||||
|
||||
|
@ -9,6 +9,7 @@ const defaultState = {
|
|||
hideAttachments: false,
|
||||
hideAttachmentsInConv: false,
|
||||
hideNsfw: true,
|
||||
preloadImage: true,
|
||||
loopVideo: true,
|
||||
loopVideoSilentOnly: true,
|
||||
autoLoad: true,
|
||||
|
@ -23,6 +24,7 @@ const defaultState = {
|
|||
likes: true,
|
||||
repeats: true
|
||||
},
|
||||
webPushNotifications: true,
|
||||
muteWords: [],
|
||||
highlight: {},
|
||||
interfaceLanguage: browserLocale,
|
||||
|
@ -54,10 +56,10 @@ const config = {
|
|||
commit('setOption', {name, value})
|
||||
switch (name) {
|
||||
case 'theme':
|
||||
StyleSetter.setPreset(value, commit)
|
||||
setPreset(value, commit)
|
||||
break
|
||||
case 'customTheme':
|
||||
StyleSetter.setColors(value, commit)
|
||||
applyTheme(value, commit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { set } from 'vue'
|
||||
import StyleSetter from '../services/style_setter/style_setter.js'
|
||||
import { setPreset } from '../services/style_setter/style_setter.js'
|
||||
|
||||
const defaultState = {
|
||||
// Stuff from static/config.json and apiConfig
|
||||
|
@ -25,6 +25,8 @@ const defaultState = {
|
|||
scopeCopy: true,
|
||||
subjectLineBehavior: 'email',
|
||||
loginMethod: 'password',
|
||||
nsfwCensorImage: undefined,
|
||||
vapidPublicKey: undefined,
|
||||
|
||||
// Nasty stuff
|
||||
pleromaBackend: true,
|
||||
|
@ -60,7 +62,7 @@ const instance = {
|
|||
dispatch('setPageTitle')
|
||||
break
|
||||
case 'theme':
|
||||
StyleSetter.setPreset(value, commit)
|
||||
setPreset(value, commit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,14 @@ import { set, delete as del } from 'vue'
|
|||
const defaultState = {
|
||||
settings: {
|
||||
currentSaveStateNotice: null,
|
||||
noticeClearTimeout: null
|
||||
noticeClearTimeout: null,
|
||||
notificationPermission: null
|
||||
},
|
||||
browserSupport: {
|
||||
cssFilter: window.CSS && window.CSS.supports && (
|
||||
window.CSS.supports('filter', 'drop-shadow(0 0)') ||
|
||||
window.CSS.supports('-webkit-filter', 'drop-shadow(0 0)')
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,10 +24,13 @@ const interfaceMod = {
|
|||
}
|
||||
set(state.settings, 'currentSaveStateNotice', { error: false, data: success })
|
||||
set(state.settings, 'noticeClearTimeout',
|
||||
setTimeout(() => del(state.settings, 'currentSaveStateNotice'), 2000))
|
||||
setTimeout(() => del(state.settings, 'currentSaveStateNotice'), 2000))
|
||||
} else {
|
||||
set(state.settings, 'currentSaveStateNotice', { error: true, errorData: error })
|
||||
}
|
||||
},
|
||||
setNotificationPermission (state, permission) {
|
||||
state.notificationPermission = permission
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
|
@ -29,6 +39,9 @@ const interfaceMod = {
|
|||
},
|
||||
settingsSaved ({ commit, dispatch }, { success, error }) {
|
||||
commit('settingsSaved', { success, error })
|
||||
},
|
||||
setNotificationPermission ({ commit }, permission) {
|
||||
commit('setNotificationPermission', permission)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
|
||||
import { compact, map, each, merge } from 'lodash'
|
||||
import { set } from 'vue'
|
||||
import registerPushNotifications from '../services/push/push.js'
|
||||
import oauthApi from '../services/new_api/oauth'
|
||||
import {humanizeErrors} from './errors'
|
||||
import { humanizeErrors } from './errors'
|
||||
|
||||
// TODO: Unify with mergeOrAdd in statuses.js
|
||||
export const mergeOrAdd = (arr, obj, item) => {
|
||||
|
@ -11,17 +12,28 @@ export const mergeOrAdd = (arr, obj, item) => {
|
|||
if (oldItem) {
|
||||
// We already have this, so only merge the new info.
|
||||
merge(oldItem, item)
|
||||
return {item: oldItem, new: false}
|
||||
return { item: oldItem, new: false }
|
||||
} else {
|
||||
// This is a new item, prepare it
|
||||
arr.push(item)
|
||||
obj[item.id] = item
|
||||
return {item, new: true}
|
||||
if (item.screen_name && !item.screen_name.includes('@')) {
|
||||
obj[item.screen_name] = item
|
||||
}
|
||||
return { item, new: true }
|
||||
}
|
||||
}
|
||||
|
||||
const getNotificationPermission = () => {
|
||||
const Notification = window.Notification
|
||||
|
||||
if (!Notification) return Promise.resolve(null)
|
||||
if (Notification.permission === 'default') return Notification.requestPermission()
|
||||
return Promise.resolve(Notification.permission)
|
||||
}
|
||||
|
||||
export const mutations = {
|
||||
setMuted (state, { user: {id}, muted }) {
|
||||
setMuted (state, { user: { id }, muted }) {
|
||||
const user = state.usersObject[id]
|
||||
set(user, 'muted', muted)
|
||||
},
|
||||
|
@ -45,7 +57,7 @@ export const mutations = {
|
|||
setUserForStatus (state, status) {
|
||||
status.user = state.usersObject[status.user.id]
|
||||
},
|
||||
setColor (state, { user: {id}, highlighted }) {
|
||||
setColor (state, { user: { id }, highlighted }) {
|
||||
const user = state.usersObject[id]
|
||||
set(user, 'highlight', highlighted)
|
||||
},
|
||||
|
@ -77,8 +89,15 @@ const users = {
|
|||
mutations,
|
||||
actions: {
|
||||
fetchUser (store, id) {
|
||||
store.rootState.api.backendInteractor.fetchUser({id})
|
||||
.then((user) => store.commit('addNewUsers', user))
|
||||
store.rootState.api.backendInteractor.fetchUser({ id })
|
||||
.then((user) => store.commit('addNewUsers', [user]))
|
||||
},
|
||||
registerPushNotifications (store) {
|
||||
const token = store.state.currentUser.credentials
|
||||
const vapidPublicKey = store.rootState.instance.vapidPublicKey
|
||||
const isEnabled = store.rootState.config.webPushNotifications
|
||||
|
||||
registerPushNotifications(isEnabled, vapidPublicKey, token)
|
||||
},
|
||||
addNewStatuses (store, { statuses }) {
|
||||
const users = map(statuses, 'user')
|
||||
|
@ -143,6 +162,9 @@ const users = {
|
|||
commit('setCurrentUser', user)
|
||||
commit('addNewUsers', [user])
|
||||
|
||||
getNotificationPermission()
|
||||
.then(permission => commit('setNotificationPermission', permission))
|
||||
|
||||
// Set our new backend interactor
|
||||
commit('setBackendInteractor', backendInteractorService(accessToken))
|
||||
|
||||
|
@ -161,12 +183,8 @@ const users = {
|
|||
store.commit('addNewUsers', mutedUsers)
|
||||
})
|
||||
|
||||
if ('Notification' in window && window.Notification.permission === 'default') {
|
||||
window.Notification.requestPermission()
|
||||
}
|
||||
|
||||
// Fetch our friends
|
||||
store.rootState.api.backendInteractor.fetchFriends({id: user.id})
|
||||
store.rootState.api.backendInteractor.fetchFriends({ id: user.id })
|
||||
.then((friends) => commit('addNewUsers', friends))
|
||||
})
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue