manual lint --fix

This commit is contained in:
Henry Jameson 2025-02-04 15:23:21 +02:00
commit d1ea589531
76 changed files with 187 additions and 184 deletions

View file

@ -60,7 +60,7 @@ const adminSettingsStorage = {
}
},
actions: {
loadFrontendsStuff ({ state, rootState, dispatch, commit }) {
loadFrontendsStuff ({ rootState, commit }) {
rootState.api.backendInteractor.fetchAvailableFrontends()
.then(frontends => commit('setAvailableFrontends', { frontends }))
},
@ -84,7 +84,7 @@ const adminSettingsStorage = {
.then(backendDescriptions => dispatch('setInstanceAdminDescriptions', { backendDescriptions }))
}
},
setInstanceAdminSettings ({ state, commit, dispatch }, { backendDbConfig }) {
setInstanceAdminSettings ({ state, commit }, { backendDbConfig }) {
const config = state.config || {}
const modifiedPaths = new Set()
backendDbConfig.configs.forEach(c => {
@ -108,7 +108,7 @@ const adminSettingsStorage = {
commit('updateAdminSettings', { config, modifiedPaths })
commit('resetAdminDraft')
},
setInstanceAdminDescriptions ({ state, commit, dispatch }, { backendDescriptions }) {
setInstanceAdminDescriptions ({ commit }, { backendDescriptions }) {
const convert = ({ children, description, label, key = '<ROOT>', group, suggestions }, path, acc) => {
const newPath = group ? [group, key] : [key]
const obj = { description, label, suggestions }
@ -127,7 +127,7 @@ const adminSettingsStorage = {
// This action takes draft state, diffs it with live config state and then pushes
// only differences between the two. Difference detection only work up to subkey (third) level.
pushAdminDraft ({ rootState, state, commit, dispatch }) {
pushAdminDraft ({ rootState, state, dispatch }) {
// TODO cleanup paths in modifiedPaths
const convert = (value) => {
if (typeof value !== 'object') {
@ -177,7 +177,7 @@ const adminSettingsStorage = {
.then(() => rootState.api.backendInteractor.fetchInstanceDBConfig())
.then(backendDbConfig => dispatch('setInstanceAdminSettings', { backendDbConfig }))
},
pushAdminSetting ({ rootState, state, commit, dispatch }, { path, value }) {
pushAdminSetting ({ rootState, dispatch }, { path, value }) {
const [group, key, ...rest] = Array.isArray(path) ? path : path.split(/\./g)
const clone = {} // not actually cloning the entire thing to avoid excessive writes
set(clone, rest, value)
@ -205,7 +205,7 @@ const adminSettingsStorage = {
.then(() => rootState.api.backendInteractor.fetchInstanceDBConfig())
.then(backendDbConfig => dispatch('setInstanceAdminSettings', { backendDbConfig }))
},
resetAdminSetting ({ rootState, state, commit, dispatch }, { path }) {
resetAdminSetting ({ rootState, state, dispatch }, { path }) {
const [group, key, subkey] = path.split(/\./g)
state.modifiedPaths.delete(path)

View file

@ -27,7 +27,7 @@ const api = {
addFetcher (state, { fetcherName, fetcher }) {
state.fetchers[fetcherName] = fetcher
},
removeFetcher (state, { fetcherName, fetcher }) {
removeFetcher (state, { fetcherName }) {
state.fetchers[fetcherName].stop()
delete state.fetchers[fetcherName]
},
@ -294,7 +294,7 @@ const api = {
setWsToken (store, token) {
store.commit('setWsToken', token)
},
initializeSocket ({ dispatch, commit, state, rootState }) {
initializeSocket ({ commit, state, rootState }) {
// Set up websocket connection
const token = state.wsToken
if (rootState.instance.shoutAvailable && typeof token !== 'undefined' && state.socket === null) {

View file

@ -19,19 +19,19 @@ const resetState = (state) => {
// getters
const getters = {
settings: (state, getters) => {
settings: (state) => {
return state.settings
},
requiredPassword: (state, getters, rootState) => {
requiredPassword: (state) => {
return state.strategy === PASSWORD_STRATEGY
},
requiredToken: (state, getters, rootState) => {
requiredToken: (state) => {
return state.strategy === TOKEN_STRATEGY
},
requiredTOTP: (state, getters, rootState) => {
requiredTOTP: (state) => {
return state.strategy === TOTP_STRATEGY
},
requiredRecovery: (state, getters, rootState) => {
requiredRecovery: (state) => {
return state.strategy === RECOVERY_STRATEGY
}
}
@ -67,10 +67,10 @@ const mutations = {
// actions
const actions = {
async login ({ state, dispatch, commit }, { access_token }) {
commit('setToken', access_token, { root: true })
await dispatch('loginUser', access_token, { root: true })
async login ({ state, dispatch, commit }, { access_token: accessToken }) {
commit('setToken', accessToken, { root: true })
await dispatch('loginUser', accessToken, { root: true })
resetState(state)
}
}

View file

@ -53,7 +53,7 @@ const chats = {
stopFetchingChats ({ commit }) {
commit('setChatListFetcher', { fetcher: undefined })
},
fetchChats ({ dispatch, rootState, commit }, params = {}) {
fetchChats ({ dispatch, rootState }) {
return rootState.api.backendInteractor.chats()
.then(({ chats }) => {
dispatch('addNewChats', { chats })
@ -73,13 +73,13 @@ const chats = {
},
// Opened Chats
startFetchingCurrentChat ({ commit, dispatch }, { fetcher }) {
startFetchingCurrentChat ({ dispatch }, { fetcher }) {
dispatch('setCurrentChatFetcher', { fetcher })
},
setCurrentChatFetcher ({ rootState, commit }, { fetcher }) {
setCurrentChatFetcher ({ commit }, { fetcher }) {
commit('setCurrentChatFetcher', { fetcher })
},
addOpenedChat ({ rootState, commit, dispatch }, { chat }) {
addOpenedChat ({ commit, dispatch }, { chat }) {
commit('addOpenedChat', { dispatch, chat: parseChat(chat) })
dispatch('addNewUsers', [chat.account])
},
@ -89,7 +89,7 @@ const chats = {
resetChatNewMessageCount ({ commit }, value) {
commit('resetChatNewMessageCount', value)
},
clearCurrentChat ({ rootState, commit, dispatch }, value) {
clearCurrentChat ({ commit }) {
commit('setCurrentChatId', { chatId: undefined })
commit('setCurrentChatFetcher', { fetcher: undefined })
},
@ -111,7 +111,7 @@ const chats = {
dispatch('clearCurrentChat')
commit('resetChats', { commit })
},
clearOpenedChats ({ rootState, commit, dispatch, rootGetters }) {
clearOpenedChats ({ commit }) {
commit('clearOpenedChats', { commit })
},
handleMessageError ({ commit }, value) {
@ -122,7 +122,7 @@ const chats = {
}
},
mutations: {
setChatListFetcher (state, { commit, fetcher }) {
setChatListFetcher (state, { fetcher }) {
const prevFetcher = state.chatListFetcher
if (prevFetcher) {
prevFetcher.stop()
@ -136,7 +136,7 @@ const chats = {
}
state.fetcher = fetcher && fetcher()
},
addOpenedChat (state, { _dispatch, chat }) {
addOpenedChat (state, { chat }) {
state.currentChatId = chat.id
state.openedChats[chat.id] = chat
@ -165,7 +165,7 @@ const chats = {
}
})
},
updateChat (state, { _dispatch, chat: updatedChat, _rootGetters }) {
updateChat (state, { chat: updatedChat }) {
const chat = getChatById(state, updatedChat.id)
if (chat) {
chat.lastMessage = updatedChat.lastMessage
@ -175,7 +175,7 @@ const chats = {
if (!chat) { state.chatList.data.unshift(updatedChat) }
state.chatList.idStore[updatedChat.id] = updatedChat
},
deleteChat (state, { _dispatch, id, _rootGetters }) {
deleteChat (state, { id }) {
state.chats.data = state.chats.data.filter(conversation =>
conversation.last_status.id !== id
)
@ -206,7 +206,7 @@ const chats = {
chatService.deleteMessage(chatMessageService, messageId)
}
},
resetChatNewMessageCount (state, _value) {
resetChatNewMessageCount (state) {
const chatMessageService = state.openedChatMessageServices[state.currentChatId]
chatService.resetNewMessageCount(chatMessageService)
},

View file

@ -38,13 +38,13 @@ export const multiChoiceProperties = [
// caching the instance default properties
export const instanceDefaultProperties = Object.entries(defaultState)
.filter(([key, value]) => value === undefined)
.map(([key, value]) => key)
.filter(([, value]) => value === undefined)
.map(([key]) => key)
const config = {
state: { ...defaultState },
getters: {
defaultConfig (state, getters, rootState, rootGetters) {
defaultConfig (state, getters, rootState) {
const { instance } = rootState
return {
...defaultState,
@ -58,7 +58,7 @@ const config = {
return {
...defaultConfig,
// Do not override with undefined
...Object.fromEntries(Object.entries(state).filter(([k, v]) => v !== undefined))
...Object.fromEntries(Object.entries(state).filter(([, v]) => v !== undefined))
}
}
},
@ -94,10 +94,10 @@ const config = {
name => dispatch('setOption', { name, value: data[name] })
)
},
setHighlight ({ commit, dispatch }, { user, color, type }) {
setHighlight ({ commit }, { user, color, type }) {
commit('setHighlight', { user, color, type })
},
setOptionTemporarily ({ commit, dispatch, state, rootState }, { name, value }) {
setOptionTemporarily ({ commit, dispatch, state }, { name, value }) {
if (useInterfaceStore().temporaryChangesTimeoutId !== null) {
console.warn('Can\'t track more than one temporary change')
return

View file

@ -36,7 +36,10 @@ export const notifications = {
})
},
clearNotifications (state) {
state = emptyNotifications()
const blankState = defaultState()
Object.keys(state).forEach(k => {
state[k] = blankState[k]
})
},
updateNotificationsMinMaxId (state, id) {
state.maxId = id > state.maxId ? id : state.maxId
@ -67,7 +70,7 @@ export const notifications = {
}
},
actions: {
addNewNotifications (store, { notifications, older }) {
addNewNotifications (store, { notifications }) {
const { commit, dispatch, state, rootState } = store
const validNotifications = notifications.filter((notification) => {
// If invalid notification, update ids but don't add it to store
@ -130,10 +133,10 @@ export const notifications = {
}
}
},
setNotificationsLoading ({ rootState, commit }, { value }) {
setNotificationsLoading ({ commit }, { value }) {
commit('setNotificationsLoading', { value })
},
setNotificationsSilence ({ rootState, commit }, { value }) {
setNotificationsSilence ({ commit }, { value }) {
commit('setNotificationsSilence', { value })
},
markNotificationsAsSeen ({ rootState, state, commit }) {
@ -155,14 +158,14 @@ export const notifications = {
closeDesktopNotification(rootState, { id })
})
},
dismissNotificationLocal ({ rootState, commit }, { id }) {
dismissNotificationLocal ({ commit }, { id }) {
commit('dismissNotification', { id })
},
dismissNotification ({ rootState, commit }, { id }) {
commit('dismissNotification', { id })
rootState.api.backendInteractor.dismissNotification({ id })
},
updateNotification ({ rootState, commit }, { id, updater }) {
updateNotification ({ commit }, { id, updater }) {
commit('updateNotification', { id, updater })
}
}

View file

@ -118,7 +118,7 @@ const profileConfig = {
}
},
actions: {
setProfileOption ({ rootState, state, commit, dispatch }, { name, value }) {
setProfileOption ({ rootState, state, commit }, { name, value }) {
const oldValue = get(state, name)
const map = settingsMap[name]
if (!map) throw new Error('Invalid server-side setting')

View file

@ -200,7 +200,7 @@ const _mergeJournal = (...journals) => {
.sort((a, b) => a.timestamp > b.timestamp ? 1 : -1)
}
export const _mergePrefs = (recent, stale, allFlagKeys) => {
export const _mergePrefs = (recent, stale) => {
if (!stale) return recent
if (!recent) return stale
const { _journal: recentJournal, ...recentData } = recent
@ -217,7 +217,7 @@ export const _mergePrefs = (recent, stale, allFlagKeys) => {
*/
const resultOutput = { ...recentData }
const totalJournal = _mergeJournal(staleJournal, recentJournal)
totalJournal.forEach(({ path, timestamp, operation, command, args }) => {
totalJournal.forEach(({ path, operation, args }) => {
if (path.startsWith('_')) {
console.error(`journal contains entry to edit internal (starts with _) field '${path}', something is incorrect here, ignoring.`)
return
@ -303,10 +303,13 @@ export const _doMigrations = (cache) => {
}
export const mutations = {
clearServerSideStorage (state, userData) {
state = { ...cloneDeep(defaultState) }
clearServerSideStorage (state) {
const blankState = { ...cloneDeep(defaultState) }
Object.keys(state).forEach(k => {
state[k] = blankState[k]
})
},
setServerSideStorage (state, userData, test) {
setServerSideStorage (state, userData) {
const live = userData.storage
state.raw = live
let cache = state.cache
@ -334,8 +337,10 @@ export const mutations = {
if (!needUpload && recent && stale) {
console.debug('Checking if data needs merging...')
// discarding timestamps and versions
/* eslint-disable no-unused-vars */
const { _timestamp: _0, _version: _1, ...recentData } = recent
const { _timestamp: _2, _version: _3, ...staleData } = stale
/* eslint-enable no-unused-vars */
dirty = !isEqual(recentData, staleData)
console.debug(`Data ${dirty ? 'needs' : 'doesn\'t need'} merging`)
}

View file

@ -223,7 +223,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
return status
}
const favoriteStatus = (favorite, counter) => {
const favoriteStatus = (favorite) => {
const status = find(allStatuses, { id: favorite.in_reply_to_status_id })
if (status) {
// This is our favorite, so the relevant bit.
@ -273,7 +273,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
favoriteStatus(favorite)
}
},
follow: (follow) => {
follow: () => {
// NOOP, it is known status but we don't do anything about it for now
},
default: (unknown) => {
@ -433,7 +433,7 @@ export const mutations = {
newStatus.fave_num = newStatus.favoritedBy.length
newStatus.favorited = !!newStatus.favoritedBy.find(({ id }) => currentUser.id === id)
},
addEmojiReactionsBy (state, { id, emojiReactions, currentUser }) {
addEmojiReactionsBy (state, { id, emojiReactions }) {
const status = state.allStatusesObject[id]
status.emoji_reactions = emojiReactions
},
@ -492,22 +492,22 @@ export const mutations = {
const statuses = {
state: defaultState(),
actions: {
addNewStatuses ({ rootState, commit, dispatch, state }, { statuses, showImmediately = false, timeline = false, noIdUpdate = false, userId, pagination }) {
addNewStatuses ({ rootState, commit }, { statuses, showImmediately = false, timeline = false, noIdUpdate = false, userId, pagination }) {
commit('addNewStatuses', { statuses, showImmediately, timeline, noIdUpdate, user: rootState.users.currentUser, userId, pagination })
},
fetchStatus ({ rootState, dispatch }, id) {
return rootState.api.backendInteractor.fetchStatus({ id })
.then((status) => dispatch('addNewStatuses', { statuses: [status] }))
},
fetchStatusSource ({ rootState, dispatch }, status) {
fetchStatusSource ({ rootState }, status) {
return apiService.fetchStatusSource({ id: status.id, credentials: rootState.users.currentUser.credentials })
},
fetchStatusHistory ({ rootState, dispatch }, status) {
fetchStatusHistory (_, status) {
return apiService.fetchStatusHistory({ status })
},
deleteStatus ({ rootState, commit, dispatch }, status) {
deleteStatus ({ rootState, commit }, status) {
apiService.deleteStatus({ id: status.id, credentials: rootState.users.currentUser.credentials })
.then((_) => {
.then(() => {
commit('setDeleted', { status })
})
.catch((e) => {
@ -584,10 +584,10 @@ const statuses = {
commit('setBookmarkedConfirm', { status })
})
},
queueFlush ({ rootState, commit }, { timeline, id }) {
queueFlush ({ commit }, { timeline, id }) {
commit('queueFlush', { timeline, id })
},
queueFlushAll ({ rootState, commit }) {
queueFlushAll ({ commit }) {
commit('queueFlushAll')
},
fetchFavsAndRepeats ({ rootState, commit }, id) {
@ -605,7 +605,7 @@ const statuses = {
commit('addOwnReaction', { id, emoji, currentUser })
rootState.api.backendInteractor.reactWithEmoji({ id, emoji }).then(
ok => {
() => {
dispatch('fetchEmojiReactionsBy', id)
}
)
@ -616,7 +616,7 @@ const statuses = {
commit('removeOwnReaction', { id, emoji, currentUser })
rootState.api.backendInteractor.unreactWithEmoji({ id, emoji }).then(
ok => {
() => {
dispatch('fetchEmojiReactionsBy', id)
}
)

View file

@ -509,8 +509,8 @@ const users = {
const notificationsObject = store.rootState.notifications.idStore
const relevantNotifications = Object.entries(notificationsObject)
.filter(([k, val]) => notificationIds.includes(k))
.map(([k, val]) => val)
.filter(([k]) => notificationIds.includes(k))
.map(([, val]) => val)
// Reconnect users to notifications
each(relevantNotifications, (notification) => {