Autocomplete domain mutes from list of known instances

This commit is contained in:
Sergey Suprunenko 2020-05-10 12:54:55 +02:00
parent acbef1ebdc
commit 1007039478
No known key found for this signature in database
GPG key ID: 5DCA7D1BE3914F9C
8 changed files with 79 additions and 22 deletions

View file

@ -1,6 +1,7 @@
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'
import { instanceDefaultProperties } from './config.js'
const defaultState = {
@ -48,6 +49,7 @@ const defaultState = {
postFormats: [],
restrictedNicknames: [],
safeDM: true,
knownDomains: [],
// Feature-set, apparently, not everything here is reported...
chatAvailable: false,
@ -80,6 +82,9 @@ const instance = {
if (typeof value !== 'undefined') {
set(state, name, value)
}
},
setKnownDomains (state, domains) {
state.knownDomains = domains
}
},
getters: {
@ -182,6 +187,18 @@ const instance = {
state.emojiFetched = true
dispatch('getStaticEmoji')
}
},
async getKnownDomains ({ commit, rootState }) {
try {
const result = await apiService.fetchKnownDomains({
credentials: rootState.users.currentUser.credentials
})
commit('setKnownDomains', result)
} catch (e) {
console.warn("Can't load known domains")
console.warn(e)
}
}
}
}