Merge remote-tracking branch 'origin/develop' into improve_settings_reusability

This commit is contained in:
Henry Jameson 2023-04-12 23:31:11 +03:00
commit 3e1aeb6d2c
11 changed files with 466 additions and 334 deletions

View File

@ -30,14 +30,14 @@
"body-scroll-lock": "3.1.5", "body-scroll-lock": "3.1.5",
"chromatism": "3.0.0", "chromatism": "3.0.0",
"click-outside-vue3": "4.0.1", "click-outside-vue3": "4.0.1",
"cropperjs": "1.5.12", "cropperjs": "1.5.13",
"escape-html": "1.0.3", "escape-html": "1.0.3",
"js-cookie": "3.0.1", "js-cookie": "3.0.1",
"localforage": "1.10.0", "localforage": "1.10.0",
"parse-link-header": "2.0.0", "parse-link-header": "2.0.0",
"phoenix": "1.6.2", "phoenix": "1.6.2",
"punycode.js": "2.3.0", "punycode.js": "2.3.0",
"qrcode": "1.5.0", "qrcode": "1.5.1",
"querystring-es3": "0.2.1", "querystring-es3": "0.2.1",
"url": "0.11.0", "url": "0.11.0",
"utf8": "3.0.0", "utf8": "3.0.0",
@ -49,18 +49,18 @@
"vuex": "4.1.0" "vuex": "4.1.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "7.21.0", "@babel/core": "7.21.4",
"@babel/eslint-parser": "7.19.1", "@babel/eslint-parser": "7.21.3",
"@babel/plugin-transform-runtime": "7.21.0", "@babel/plugin-transform-runtime": "7.21.4",
"@babel/preset-env": "7.20.2", "@babel/preset-env": "7.21.4",
"@babel/register": "7.21.0", "@babel/register": "7.21.0",
"@intlify/vue-i18n-loader": "5.0.0", "@intlify/vue-i18n-loader": "5.0.1",
"@ungap/event-target": "0.2.3", "@ungap/event-target": "0.2.3",
"@vue/babel-helper-vue-jsx-merge-props": "1.4.0", "@vue/babel-helper-vue-jsx-merge-props": "1.4.0",
"@vue/babel-plugin-jsx": "1.1.1", "@vue/babel-plugin-jsx": "1.1.1",
"@vue/compiler-sfc": "3.2.45", "@vue/compiler-sfc": "3.2.45",
"@vue/test-utils": "2.2.8", "@vue/test-utils": "2.2.8",
"autoprefixer": "10.4.13", "autoprefixer": "10.4.14",
"babel-loader": "9.1.2", "babel-loader": "9.1.2",
"babel-plugin-lodash": "3.3.4", "babel-plugin-lodash": "3.3.4",
"chai": "4.3.7", "chai": "4.3.7",
@ -99,14 +99,14 @@
"lodash": "4.17.21", "lodash": "4.17.21",
"mini-css-extract-plugin": "2.7.2", "mini-css-extract-plugin": "2.7.2",
"mocha": "10.2.0", "mocha": "10.2.0",
"nightwatch": "2.6.11", "nightwatch": "2.6.19",
"opn": "5.5.0", "opn": "5.5.0",
"ora": "0.4.1", "ora": "0.4.1",
"postcss": "8.4.20", "postcss": "8.4.20",
"postcss-html": "^1.5.0", "postcss-html": "^1.5.0",
"postcss-loader": "7.0.2", "postcss-loader": "7.0.2",
"postcss-scss": "^4.0.6", "postcss-scss": "^4.0.6",
"sass": "1.57.1", "sass": "1.60.0",
"sass-loader": "13.2.0", "sass-loader": "13.2.0",
"selenium-server": "2.53.1", "selenium-server": "2.53.1",
"semver": "7.3.8", "semver": "7.3.8",

View File

@ -1,9 +1,13 @@
<template> <template>
<div class="list"> <div
class="list"
role="list"
>
<div <div
v-for="item in items" v-for="item in items"
:key="getKey(item)" :key="getKey(item)"
class="list-item" class="list-item"
role="listitem"
> >
<slot <slot
name="item" name="item"

View File

@ -45,6 +45,7 @@ const NavPanel = {
privateMode: state => state.instance.private, privateMode: state => state.instance.private,
federating: state => state.instance.federating, federating: state => state.instance.federating,
pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable, pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable,
supportsAnnouncements: state => state.announcements.supportsAnnouncements,
pinnedItems: state => new Set(state.serverSideStorage.prefsStorage.collections.pinnedNavItems) pinnedItems: state => new Set(state.serverSideStorage.prefsStorage.collections.pinnedNavItems)
}), }),
pinnedList () { pinnedList () {
@ -56,6 +57,7 @@ const NavPanel = {
], ],
{ {
hasChats: this.pleromaChatMessagesAvailable, hasChats: this.pleromaChatMessagesAvailable,
hasAnnouncements: this.supportsAnnouncements,
isFederating: this.federating, isFederating: this.federating,
isPrivate: this.privateMode, isPrivate: this.privateMode,
currentUser: this.currentUser currentUser: this.currentUser
@ -75,6 +77,7 @@ const NavPanel = {
], ],
{ {
hasChats: this.pleromaChatMessagesAvailable, hasChats: this.pleromaChatMessagesAvailable,
hasAnnouncements: this.supportsAnnouncements,
isFederating: this.federating, isFederating: this.federating,
isPrivate: this.privateMode, isPrivate: this.privateMode,
currentUser: this.currentUser currentUser: this.currentUser

View File

@ -9,17 +9,20 @@ import DomainMuteCard from 'src/components/domain_mute_card/domain_mute_card.vue
import SelectableList from 'src/components/selectable_list/selectable_list.vue' import SelectableList from 'src/components/selectable_list/selectable_list.vue'
import ProgressButton from 'src/components/progress_button/progress_button.vue' import ProgressButton from 'src/components/progress_button/progress_button.vue'
import withSubscription from 'src/components/../hocs/with_subscription/with_subscription' import withSubscription from 'src/components/../hocs/with_subscription/with_subscription'
import withLoadMore from 'src/components/../hocs/with_load_more/with_load_more'
import Checkbox from 'src/components/checkbox/checkbox.vue' import Checkbox from 'src/components/checkbox/checkbox.vue'
const BlockList = withSubscription({ const BlockList = withLoadMore({
fetch: (props, $store) => $store.dispatch('fetchBlocks'), fetch: (props, $store) => $store.dispatch('fetchBlocks'),
select: (props, $store) => get($store.state.users.currentUser, 'blockIds', []), select: (props, $store) => get($store.state.users.currentUser, 'blockIds', []),
destroy: () => {},
childPropName: 'items' childPropName: 'items'
})(SelectableList) })(SelectableList)
const MuteList = withSubscription({ const MuteList = withLoadMore({
fetch: (props, $store) => $store.dispatch('fetchMutes'), fetch: (props, $store) => $store.dispatch('fetchMutes'),
select: (props, $store) => get($store.state.users.currentUser, 'muteIds', []), select: (props, $store) => get($store.state.users.currentUser, 'muteIds', []),
destroy: () => {},
childPropName: 'items' childPropName: 'items'
})(SelectableList) })(SelectableList)

View File

@ -98,7 +98,7 @@ const withLoadMore = ({
</button> </button>
} }
{!this.error && this.loading && <FAIcon spin icon="circle-notch"/>} {!this.error && this.loading && <FAIcon spin icon="circle-notch"/>}
{!this.error && !this.loading && !this.bottomedOut && <a onClick={this.fetchEntries}>{this.$t('general.more')}</a>} {!this.error && !this.loading && !this.bottomedOut && <a onClick={this.fetchEntries} role="button" tabindex="0">{this.$t('general.more')}</a>}
</div> </div>
</div> </div>
) )

View File

@ -939,6 +939,7 @@
"repeat_confirm_accept_button": "Repeat", "repeat_confirm_accept_button": "Repeat",
"repeat_confirm_cancel_button": "Do not repeat", "repeat_confirm_cancel_button": "Do not repeat",
"delete": "Delete status", "delete": "Delete status",
"delete_error": "Error deleting status: {0}",
"edit": "Edit status", "edit": "Edit status",
"edited_at": "(last edited {time})", "edited_at": "(last edited {time})",
"pin": "Pin on profile", "pin": "Pin on profile",

View File

@ -65,6 +65,7 @@ const chats = {
const newChatMessageSideEffects = (chat) => { const newChatMessageSideEffects = (chat) => {
maybeShowChatNotification(store, chat) maybeShowChatNotification(store, chat)
} }
commit('addNewUsers', chats.map(k => k.account).filter(k => k))
commit('addNewChats', { dispatch, chats, rootGetters, newChatMessageSideEffects }) commit('addNewChats', { dispatch, chats, rootGetters, newChatMessageSideEffects })
}, },
updateChat ({ commit }, { chat }) { updateChat ({ commit }, { chat }) {

View File

@ -615,9 +615,19 @@ const statuses = {
fetchStatusHistory ({ rootState, dispatch }, status) { fetchStatusHistory ({ rootState, dispatch }, status) {
return apiService.fetchStatusHistory({ status }) return apiService.fetchStatusHistory({ status })
}, },
deleteStatus ({ rootState, commit }, status) { deleteStatus ({ rootState, commit, dispatch }, status) {
commit('setDeleted', { status })
apiService.deleteStatus({ id: status.id, credentials: rootState.users.currentUser.credentials }) apiService.deleteStatus({ id: status.id, credentials: rootState.users.currentUser.credentials })
.then((_) => {
commit('setDeleted', { status })
})
.catch((e) => {
dispatch('pushGlobalNotice', {
level: 'error',
messageKey: 'status.delete_error',
messageArgs: [e.message],
timeout: 5000
})
})
}, },
deleteStatusById ({ rootState, commit }, id) { deleteStatusById ({ rootState, commit }, id) {
const status = rootState.statuses.allStatusesObject[id] const status = rootState.statuses.allStatusesObject[id]

View File

@ -195,9 +195,15 @@ export const mutations = {
state.currentUser.blockIds.push(blockId) state.currentUser.blockIds.push(blockId)
} }
}, },
setBlockIdsMaxId (state, blockIdsMaxId) {
state.currentUser.blockIdsMaxId = blockIdsMaxId
},
saveMuteIds (state, muteIds) { saveMuteIds (state, muteIds) {
state.currentUser.muteIds = muteIds state.currentUser.muteIds = muteIds
}, },
setMuteIdsMaxId (state, muteIdsMaxId) {
state.currentUser.muteIdsMaxId = muteIdsMaxId
},
addMuteId (state, muteId) { addMuteId (state, muteId) {
if (state.currentUser.muteIds.indexOf(muteId) === -1) { if (state.currentUser.muteIds.indexOf(muteId) === -1) {
state.currentUser.muteIds.push(muteId) state.currentUser.muteIds.push(muteId)
@ -320,10 +326,20 @@ const users = {
.then((inLists) => store.commit('updateUserInLists', { id, inLists })) .then((inLists) => store.commit('updateUserInLists', { id, inLists }))
} }
}, },
fetchBlocks (store) { fetchBlocks (store, args) {
return store.rootState.api.backendInteractor.fetchBlocks() const { reset } = args || {}
const maxId = store.state.currentUser.blockIdsMaxId
return store.rootState.api.backendInteractor.fetchBlocks({ maxId })
.then((blocks) => { .then((blocks) => {
store.commit('saveBlockIds', map(blocks, 'id')) if (reset) {
store.commit('saveBlockIds', map(blocks, 'id'))
} else {
map(blocks, 'id').map(id => store.commit('addBlockId', id))
}
if (blocks.length) {
store.commit('setBlockIdsMaxId', last(blocks).id)
}
store.commit('addNewUsers', blocks) store.commit('addNewUsers', blocks)
return blocks return blocks
}) })
@ -346,10 +362,20 @@ const users = {
editUserNote (store, args) { editUserNote (store, args) {
return editUserNote(store, args) return editUserNote(store, args)
}, },
fetchMutes (store) { fetchMutes (store, args) {
return store.rootState.api.backendInteractor.fetchMutes() const { reset } = args || {}
const maxId = store.state.currentUser.muteIdsMaxId
return store.rootState.api.backendInteractor.fetchMutes({ maxId })
.then((mutes) => { .then((mutes) => {
store.commit('saveMuteIds', map(mutes, 'id')) if (reset) {
store.commit('saveMuteIds', map(mutes, 'id'))
} else {
map(mutes, 'id').map(id => store.commit('addMuteId', id))
}
if (mutes.length) {
store.commit('setMuteIdsMaxId', last(mutes).id)
}
store.commit('addNewUsers', mutes) store.commit('addNewUsers', mutes)
return mutes return mutes
}) })

View File

@ -845,7 +845,7 @@ const postStatus = ({
}) })
if (pollOptions.some(option => option !== '')) { if (pollOptions.some(option => option !== '')) {
const normalizedPoll = { const normalizedPoll = {
expires_in: poll.expiresIn, expires_in: parseInt(poll.expiresIn, 10),
multiple: poll.multiple multiple: poll.multiple
} }
Object.keys(normalizedPoll).forEach(key => { Object.keys(normalizedPoll).forEach(key => {
@ -902,7 +902,7 @@ const editStatus = ({
if (pollOptions.some(option => option !== '')) { if (pollOptions.some(option => option !== '')) {
const normalizedPoll = { const normalizedPoll = {
expires_in: poll.expiresIn, expires_in: parseInt(poll.expiresIn, 10),
multiple: poll.multiple multiple: poll.multiple
} }
Object.keys(normalizedPoll).forEach(key => { Object.keys(normalizedPoll).forEach(key => {
@ -928,8 +928,9 @@ const editStatus = ({
} }
const deleteStatus = ({ id, credentials }) => { const deleteStatus = ({ id, credentials }) => {
return fetch(MASTODON_DELETE_URL(id), { return promisedRequest({
headers: authHeaders(credentials), url: MASTODON_DELETE_URL(id),
credentials,
method: 'DELETE' method: 'DELETE'
}) })
} }
@ -1118,8 +1119,12 @@ const generateMfaBackupCodes = ({ credentials }) => {
}).then((data) => data.json()) }).then((data) => data.json())
} }
const fetchMutes = ({ credentials }) => { const fetchMutes = ({ maxId, credentials }) => {
return promisedRequest({ url: MASTODON_USER_MUTES_URL, credentials }) const query = new URLSearchParams({ with_relationships: true })
if (maxId) {
query.append('max_id', maxId)
}
return promisedRequest({ url: `${MASTODON_USER_MUTES_URL}?${query.toString()}`, credentials })
.then((users) => users.map(parseUser)) .then((users) => users.map(parseUser))
} }
@ -1143,8 +1148,12 @@ const unsubscribeUser = ({ id, credentials }) => {
return promisedRequest({ url: MASTODON_UNSUBSCRIBE_USER(id), credentials, method: 'POST' }) return promisedRequest({ url: MASTODON_UNSUBSCRIBE_USER(id), credentials, method: 'POST' })
} }
const fetchBlocks = ({ credentials }) => { const fetchBlocks = ({ maxId, credentials }) => {
return promisedRequest({ url: MASTODON_USER_BLOCKS_URL, credentials }) const query = new URLSearchParams({ with_relationships: true })
if (maxId) {
query.append('max_id', maxId)
}
return promisedRequest({ url: `${MASTODON_USER_BLOCKS_URL}?${query.toString()}`, credentials })
.then((users) => users.map(parseUser)) .then((users) => users.map(parseUser))
} }

683
yarn.lock

File diff suppressed because it is too large Load Diff