forked from AkkomaGang/akkoma-fe
Fix tests, more replacing with mergedConfig
This commit is contained in:
parent
20fc259350
commit
0be86304d2
19 changed files with 56 additions and 49 deletions
|
@ -45,7 +45,7 @@ export default {
|
||||||
}),
|
}),
|
||||||
created () {
|
created () {
|
||||||
// Load the locale from the storage
|
// Load the locale from the storage
|
||||||
this.$i18n.locale = this.$store.state.config.interfaceLanguage
|
this.$i18n.locale = this.$store.getters.mergedConfig.interfaceLanguage
|
||||||
window.addEventListener('resize', this.updateMobileState)
|
window.addEventListener('resize', this.updateMobileState)
|
||||||
},
|
},
|
||||||
destroyed () {
|
destroyed () {
|
||||||
|
@ -93,7 +93,7 @@ export default {
|
||||||
suggestionsEnabled () { return this.$store.state.instance.suggestionsEnabled },
|
suggestionsEnabled () { return this.$store.state.instance.suggestionsEnabled },
|
||||||
showInstanceSpecificPanel () {
|
showInstanceSpecificPanel () {
|
||||||
return this.$store.state.instance.showInstanceSpecificPanel &&
|
return this.$store.state.instance.showInstanceSpecificPanel &&
|
||||||
!this.$store.state.config.hideISP &&
|
!this.$store.getters.mergedConfig.hideISP &&
|
||||||
this.$store.state.instance.instanceSpecificPanelContent
|
this.$store.state.instance.instanceSpecificPanelContent
|
||||||
},
|
},
|
||||||
showFeaturesPanel () { return this.$store.state.instance.showFeaturesPanel },
|
showFeaturesPanel () { return this.$store.state.instance.showFeaturesPanel },
|
||||||
|
|
|
@ -15,8 +15,8 @@ const Attachment = {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
nsfwImage: this.$store.state.instance.nsfwCensorImage || nsfwImage,
|
nsfwImage: this.$store.state.instance.nsfwCensorImage || nsfwImage,
|
||||||
hideNsfwLocal: this.$store.state.config.hideNsfw,
|
hideNsfwLocal: this.$store.getters.mergedConfig.hideNsfw,
|
||||||
preloadImage: this.$store.state.config.preloadImage,
|
preloadImage: this.$store.getters.mergedConfig.preloadImage,
|
||||||
loading: false,
|
loading: false,
|
||||||
img: fileTypeService.fileType(this.attachment.mimetype) === 'image' && document.createElement('img'),
|
img: fileTypeService.fileType(this.attachment.mimetype) === 'image' && document.createElement('img'),
|
||||||
modalOpen: false,
|
modalOpen: false,
|
||||||
|
@ -57,7 +57,7 @@ const Attachment = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openModal (event) {
|
openModal (event) {
|
||||||
const modalTypes = this.$store.state.config.playVideosInModal
|
const modalTypes = this.$store.getters.mergedConfig.playVideosInModal
|
||||||
? ['image', 'video']
|
? ['image', 'video']
|
||||||
: ['image']
|
: ['image']
|
||||||
if (fileTypeService.fileMatchesSomeType(modalTypes, this.attachment) ||
|
if (fileTypeService.fileMatchesSomeType(modalTypes, this.attachment) ||
|
||||||
|
@ -70,7 +70,7 @@ const Attachment = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggleHidden (event) {
|
toggleHidden (event) {
|
||||||
if (this.$store.state.config.useOneClickNsfw && !this.showHidden) {
|
if (this.$store.getters.mergedConfig.useOneClickNsfw && !this.showHidden) {
|
||||||
this.openModal(event)
|
this.openModal(event)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ const EmojiInput = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
padEmoji () {
|
padEmoji () {
|
||||||
return this.$store.state.config.padEmoji
|
return this.$store.getters.mergedConfig.padEmoji
|
||||||
},
|
},
|
||||||
suggestions () {
|
suggestions () {
|
||||||
const firstchar = this.textAtCaret.charAt(0)
|
const firstchar = this.textAtCaret.charAt(0)
|
||||||
|
|
|
@ -37,7 +37,7 @@ const Gallery = {
|
||||||
return itemsPerRow => ({ 'height': `${(this.width / (itemsPerRow + 0.6))}px` })
|
return itemsPerRow => ({ 'height': `${(this.width / (itemsPerRow + 0.6))}px` })
|
||||||
},
|
},
|
||||||
useContainFit () {
|
useContainFit () {
|
||||||
return this.$store.state.config.useContainFit
|
return this.$store.getters.mergedConfig.useContainFit
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -40,7 +40,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
language: {
|
language: {
|
||||||
get: function () { return this.$store.state.config.interfaceLanguage },
|
get: function () { return this.$store.getters.mergedConfig.interfaceLanguage },
|
||||||
set: function (val) {
|
set: function (val) {
|
||||||
this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val })
|
this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val })
|
||||||
this.$i18n.locale = val
|
this.$i18n.locale = val
|
||||||
|
|
|
@ -63,7 +63,7 @@ const MobileNav = {
|
||||||
this.$refs.notifications.markAsSeen()
|
this.$refs.notifications.markAsSeen()
|
||||||
},
|
},
|
||||||
onScroll ({ target: { scrollTop, clientHeight, scrollHeight } }) {
|
onScroll ({ target: { scrollTop, clientHeight, scrollHeight } }) {
|
||||||
if (this.$store.state.config.autoLoad && scrollTop + clientHeight >= scrollHeight) {
|
if (this.$store.getters.mergedConfig.autoLoad && scrollTop + clientHeight >= scrollHeight) {
|
||||||
this.$refs.notifications.fetchOlderNotifications()
|
this.$refs.notifications.fetchOlderNotifications()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ const MobilePostStatusButton = {
|
||||||
return this.autohideFloatingPostButton && (this.hidden || this.inputActive)
|
return this.autohideFloatingPostButton && (this.hidden || this.inputActive)
|
||||||
},
|
},
|
||||||
autohideFloatingPostButton () {
|
autohideFloatingPostButton () {
|
||||||
return !!this.$store.state.config.autohideFloatingPostButton
|
return !!this.$store.getters.mergedConfig.autohideFloatingPostButton
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
|
@ -39,7 +39,7 @@ const Notification = {
|
||||||
return highlightClass(this.notification.from_profile)
|
return highlightClass(this.notification.from_profile)
|
||||||
},
|
},
|
||||||
userStyle () {
|
userStyle () {
|
||||||
const highlight = this.$store.state.config.highlight
|
const highlight = this.$store.getters.mergedConfig.highlight
|
||||||
const user = this.notification.from_profile
|
const user = this.notification.from_profile
|
||||||
return highlightStyle(highlight[user.screen_name])
|
return highlightStyle(highlight[user.screen_name])
|
||||||
},
|
},
|
||||||
|
|
|
@ -152,7 +152,7 @@ const PostStatusForm = {
|
||||||
this.$store.state.instance.pollLimits.max_options >= 2
|
this.$store.state.instance.pollLimits.max_options >= 2
|
||||||
},
|
},
|
||||||
hideScopeNotice () {
|
hideScopeNotice () {
|
||||||
return this.$store.state.config.hideScopeNotice
|
return this.$store.getters.mergedConfig.hideScopeNotice
|
||||||
},
|
},
|
||||||
pollContentError () {
|
pollContentError () {
|
||||||
return this.pollFormVisible &&
|
return this.pollFormVisible &&
|
||||||
|
|
|
@ -99,7 +99,7 @@ const settings = {
|
||||||
handler (value) {
|
handler (value) {
|
||||||
this.$store.dispatch('setOption', {
|
this.$store.dispatch('setOption', {
|
||||||
name: 'notificationVisibility',
|
name: 'notificationVisibility',
|
||||||
value: this.$store.state.config.notificationVisibility
|
value: this.$store.getters.mergedConfig.notificationVisibility
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
|
|
|
@ -7,7 +7,7 @@ const StillImage = {
|
||||||
],
|
],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
stopGifs: this.$store.state.config.stopGifs
|
stopGifs: this.$store.getters.mergedConfig.stopGifs
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -27,7 +27,7 @@ export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
availableStyles: [],
|
availableStyles: [],
|
||||||
selected: this.$store.state.config.theme,
|
selected: this.$store.getters.mergedConfig.theme,
|
||||||
|
|
||||||
previewShadows: {},
|
previewShadows: {},
|
||||||
previewColors: {},
|
previewColors: {},
|
||||||
|
@ -111,7 +111,7 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.normalizeLocalState(this.$store.state.config.customTheme)
|
this.normalizeLocalState(this.$store.getters.mergedConfig.customTheme)
|
||||||
if (typeof this.shadowSelected === 'undefined') {
|
if (typeof this.shadowSelected === 'undefined') {
|
||||||
this.shadowSelected = this.shadowsAvailable[0]
|
this.shadowSelected = this.shadowsAvailable[0]
|
||||||
}
|
}
|
||||||
|
@ -365,9 +365,9 @@ export default {
|
||||||
return version >= 1 || version <= 2
|
return version >= 1 || version <= 2
|
||||||
},
|
},
|
||||||
clearAll () {
|
clearAll () {
|
||||||
const state = this.$store.state.config.customTheme
|
const state = this.$store.getters.mergedConfig.customTheme
|
||||||
const version = state.colors ? 2 : 'l1'
|
const version = state.colors ? 2 : 'l1'
|
||||||
this.normalizeLocalState(this.$store.state.config.customTheme, version)
|
this.normalizeLocalState(this.$store.getters.mergedConfig.customTheme, version)
|
||||||
},
|
},
|
||||||
|
|
||||||
// Clears all the extra stuff when loading V1 theme
|
// Clears all the extra stuff when loading V1 theme
|
||||||
|
|
|
@ -141,7 +141,7 @@ const Timeline = {
|
||||||
const bodyBRect = document.body.getBoundingClientRect()
|
const bodyBRect = document.body.getBoundingClientRect()
|
||||||
const height = Math.max(bodyBRect.height, -(bodyBRect.y))
|
const height = Math.max(bodyBRect.height, -(bodyBRect.y))
|
||||||
if (this.timeline.loading === false &&
|
if (this.timeline.loading === false &&
|
||||||
this.$store.state.config.autoLoad &&
|
this.$store.getters.mergedConfig.autoLoad &&
|
||||||
this.$el.offsetHeight > 0 &&
|
this.$el.offsetHeight > 0 &&
|
||||||
(window.innerHeight + window.pageYOffset) >= (height - 750)) {
|
(window.innerHeight + window.pageYOffset) >= (height - 750)) {
|
||||||
this.fetchOlderStatuses()
|
this.fetchOlderStatuses()
|
||||||
|
@ -153,7 +153,7 @@ const Timeline = {
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
newStatusCount (count) {
|
newStatusCount (count) {
|
||||||
if (!this.$store.state.config.streaming) {
|
if (!this.$store.getters.mergedConfig.streaming) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
|
@ -162,7 +162,7 @@ const Timeline = {
|
||||||
const top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0)
|
const top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0)
|
||||||
if (top < 15 &&
|
if (top < 15 &&
|
||||||
!this.paused &&
|
!this.paused &&
|
||||||
!(this.unfocused && this.$store.state.config.pauseOnUnfocused)
|
!(this.unfocused && this.$store.getters.mergedConfig.pauseOnUnfocused)
|
||||||
) {
|
) {
|
||||||
this.showNewStatuses()
|
this.showNewStatuses()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -27,9 +27,9 @@ export default {
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
style () {
|
style () {
|
||||||
const color = this.$store.state.config.customTheme.colors
|
const color = this.$store.getters.mergedConfig.customTheme.colors
|
||||||
? this.$store.state.config.customTheme.colors.bg // v2
|
? this.$store.getters.mergedConfig.customTheme.colors.bg // v2
|
||||||
: this.$store.state.config.colors.bg // v1
|
: this.$store.getters.mergedConfig.colors.bg // v1
|
||||||
|
|
||||||
if (color) {
|
if (color) {
|
||||||
const rgb = (typeof color === 'string') ? hex2rgb(color) : color
|
const rgb = (typeof color === 'string') ? hex2rgb(color) : color
|
||||||
|
@ -61,11 +61,11 @@ export default {
|
||||||
},
|
},
|
||||||
userHighlightType: {
|
userHighlightType: {
|
||||||
get () {
|
get () {
|
||||||
const data = this.$store.state.config.highlight[this.user.screen_name]
|
const data = this.$store.getters.mergedConfig.highlight[this.user.screen_name]
|
||||||
return (data && data.type) || 'disabled'
|
return (data && data.type) || 'disabled'
|
||||||
},
|
},
|
||||||
set (type) {
|
set (type) {
|
||||||
const data = this.$store.state.config.highlight[this.user.screen_name]
|
const data = this.$store.getters.mergedConfig.highlight[this.user.screen_name]
|
||||||
if (type !== 'disabled') {
|
if (type !== 'disabled') {
|
||||||
this.$store.dispatch('setHighlight', { user: this.user.screen_name, color: (data && data.color) || '#FFFFFF', type })
|
this.$store.dispatch('setHighlight', { user: this.user.screen_name, color: (data && data.color) || '#FFFFFF', type })
|
||||||
} else {
|
} else {
|
||||||
|
@ -76,7 +76,7 @@ export default {
|
||||||
},
|
},
|
||||||
userHighlightColor: {
|
userHighlightColor: {
|
||||||
get () {
|
get () {
|
||||||
const data = this.$store.state.config.highlight[this.user.screen_name]
|
const data = this.$store.getters.mergedConfig.highlight[this.user.screen_name]
|
||||||
return data && data.color
|
return data && data.color
|
||||||
},
|
},
|
||||||
set (color) {
|
set (color) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ const VideoAttachment = {
|
||||||
props: ['attachment', 'controls'],
|
props: ['attachment', 'controls'],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
loopVideo: this.$store.state.config.loopVideo
|
loopVideo: this.$store.getters.mergedConfig.loopVideo
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -12,16 +12,16 @@ const VideoAttachment = {
|
||||||
if (typeof target.webkitAudioDecodedByteCount !== 'undefined') {
|
if (typeof target.webkitAudioDecodedByteCount !== 'undefined') {
|
||||||
// non-zero if video has audio track
|
// non-zero if video has audio track
|
||||||
if (target.webkitAudioDecodedByteCount > 0) {
|
if (target.webkitAudioDecodedByteCount > 0) {
|
||||||
this.loopVideo = this.loopVideo && !this.$store.state.config.loopVideoSilentOnly
|
this.loopVideo = this.loopVideo && !this.$store.getters.mergedConfig.loopVideoSilentOnly
|
||||||
}
|
}
|
||||||
} else if (typeof target.mozHasAudio !== 'undefined') {
|
} else if (typeof target.mozHasAudio !== 'undefined') {
|
||||||
// true if video has audio track
|
// true if video has audio track
|
||||||
if (target.mozHasAudio) {
|
if (target.mozHasAudio) {
|
||||||
this.loopVideo = this.loopVideo && !this.$store.state.config.loopVideoSilentOnly
|
this.loopVideo = this.loopVideo && !this.$store.getters.mergedConfig.loopVideoSilentOnly
|
||||||
}
|
}
|
||||||
} else if (typeof target.audioTracks !== 'undefined') {
|
} else if (typeof target.audioTracks !== 'undefined') {
|
||||||
if (target.audioTracks.length > 0) {
|
if (target.audioTracks.length > 0) {
|
||||||
this.loopVideo = this.loopVideo && !this.$store.state.config.loopVideoSilentOnly
|
this.loopVideo = this.loopVideo && !this.$store.getters.mergedConfig.loopVideoSilentOnly
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,10 @@ const update = ({ store, notifications, older }) => {
|
||||||
|
|
||||||
const fetchAndUpdate = ({ store, credentials, older = false }) => {
|
const fetchAndUpdate = ({ store, credentials, older = false }) => {
|
||||||
const args = { credentials }
|
const args = { credentials }
|
||||||
|
const { getters } = store
|
||||||
const rootState = store.rootState || store.state
|
const rootState = store.rootState || store.state
|
||||||
const timelineData = rootState.statuses.notifications
|
const timelineData = rootState.statuses.notifications
|
||||||
const hideMutedPosts = typeof rootState.config.hideMutedPosts === 'undefined'
|
const hideMutedPosts = getters.mergedConfig.hideMutedPosts
|
||||||
? rootState.instance.hideMutedPosts
|
|
||||||
: rootState.config.hideMutedPosts
|
|
||||||
|
|
||||||
args['withMuted'] = !hideMutedPosts
|
args['withMuted'] = !hideMutedPosts
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,21 @@ const update = ({ store, statuses, timeline, showImmediately, userId }) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchAndUpdate = ({ store, credentials, timeline = 'friends', older = false, showImmediately = false, userId = false, tag = false, until }) => {
|
const fetchAndUpdate = ({
|
||||||
|
store,
|
||||||
|
credentials,
|
||||||
|
timeline = 'friends',
|
||||||
|
older = false,
|
||||||
|
showImmediately = false,
|
||||||
|
userId = false,
|
||||||
|
tag = false,
|
||||||
|
until
|
||||||
|
}) => {
|
||||||
const args = { timeline, credentials }
|
const args = { timeline, credentials }
|
||||||
const rootState = store.rootState || store.state
|
const rootState = store.rootState || store.state
|
||||||
|
const { getters } = store
|
||||||
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
|
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
|
||||||
const hideMutedPosts = typeof rootState.config.hideMutedPosts === 'undefined'
|
const hideMutedPosts = getters.mergedConfig.hideMutedPosts
|
||||||
? rootState.instance.hideMutedPosts
|
|
||||||
: rootState.config.hideMutedPosts
|
|
||||||
|
|
||||||
if (older) {
|
if (older) {
|
||||||
args['until'] = until || timelineData.minId
|
args['until'] = until || timelineData.minId
|
||||||
|
|
|
@ -12,8 +12,8 @@ const generateInput = (value, padEmoji = true) => {
|
||||||
},
|
},
|
||||||
mocks: {
|
mocks: {
|
||||||
$store: {
|
$store: {
|
||||||
state: {
|
getters: {
|
||||||
config: {
|
mergedConfig: {
|
||||||
padEmoji
|
padEmoji
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,14 @@ const actions = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const testGetters = {
|
const testGetters = {
|
||||||
findUser: state => getters.findUser(state.users)
|
findUser: state => getters.findUser(state.users),
|
||||||
|
mergedConfig: state => ({
|
||||||
|
colors: '',
|
||||||
|
highlight: {},
|
||||||
|
customTheme: {
|
||||||
|
colors: []
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const localUser = {
|
const localUser = {
|
||||||
|
@ -45,13 +52,6 @@ const externalProfileStore = new Vuex.Store({
|
||||||
interface: {
|
interface: {
|
||||||
browserSupport: ''
|
browserSupport: ''
|
||||||
},
|
},
|
||||||
config: {
|
|
||||||
colors: '',
|
|
||||||
highlight: {},
|
|
||||||
customTheme: {
|
|
||||||
colors: []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
instance: {
|
instance: {
|
||||||
hideUserStats: true
|
hideUserStats: true
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue