fix reporting modal

This commit is contained in:
Henry Jameson 2026-08-26 13:57:45 +03:00
commit 946682b3b4
5 changed files with 26 additions and 27 deletions

View file

@ -21,8 +21,8 @@ const List = {
default: () => '', default: () => '',
}, },
preSelect: { preSelect: {
type: Array, type: Set,
default: [], default: new Set(),
}, },
nonInteractive: { nonInteractive: {
type: Boolean, type: Boolean,

View file

@ -56,7 +56,7 @@ const UserReportingModal = {
// Reset state // Reset state
this.comment = '' this.comment = ''
this.forward = false this.forward = false
this.statusIdsToReport = new Set(this.reportModal.preTickedIds) this.statusIdsToReport = new Set(this.reportModal.preTickedIds) // cloning
this.processing = false this.processing = false
this.error = false this.error = false
}, },

View file

@ -52,8 +52,9 @@
</div> </div>
<div class="user-reporting-panel-right"> <div class="user-reporting-panel-right">
<List <List
:external-items="reportModal.statuses" :external-items="reportModal.statusIds"
:pre-select="reportModal.preTickedIds" :pre-select="reportModal.preTickedIds"
:get-key="(item) => item"
selectable selectable
@select="onListSelect" @select="onListSelect"
> >
@ -61,7 +62,7 @@
<Status <Status
:in-conversation="false" :in-conversation="false"
:focused="false" :focused="false"
:statusoid="item" :status-id="item"
/> />
</template> </template>
</List> </List>

View file

@ -1,4 +1,3 @@
import { filter } from 'lodash'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { useInterfaceStore } from 'src/stores/interface.js' import { useInterfaceStore } from 'src/stores/interface.js'
@ -11,28 +10,23 @@ export const useReportsStore = defineStore('reports', {
state: () => ({ state: () => ({
reportModal: { reportModal: {
userId: null, userId: null,
statuses: [], statusIds: new Set(),
preTickedIds: [], preTickedIds: new Set(),
activated: false, activated: false,
}, },
reports: {}, reports: {},
}), }),
actions: { actions: {
openUserReportingModal({ userId, statusIds = [] }) { openUserReportingModal({ userId, statusIds = [] }) {
const preTickedStatuses = statusIds.map((id) => const preTickedIds = new Set(statusIds)
useStatusesStore().allStatuses.get(id), // There shouldn't be a case where this is undefined
) const userAllStatusesIds = useStatusesStore().statusesPerUser.get(userId)
const preTickedIds = statusIds // Set constructor should take care of duplicated IDs and order,
const statuses = preTickedStatuses.concat( // later duplicated IDs will be dropped in favor of earlier
filter( const sortedIds = new Set([...preTickedIds, ...userAllStatusesIds])
window.vuex.state.statuses.allStatuses,
(status) =>
status.user.id === userId && !preTickedIds.includes(status.id),
),
)
this.reportModal.userId = userId this.reportModal.userId = userId
this.reportModal.statuses = statuses this.reportModal.statusIds = sortedIds
this.reportModal.preTickedIds = preTickedIds this.reportModal.preTickedIds = preTickedIds
this.reportModal.activated = true this.reportModal.activated = true
}, },

View file

@ -30,6 +30,7 @@ import {
export const defaultState = () => ({ export const defaultState = () => ({
allStatuses: new Map(), allStatuses: new Map(),
statusesPerUser: new Map(),
timestamps: new WeakMap(), timestamps: new WeakMap(),
scrobblesNextFetch: {}, scrobblesNextFetch: {},
conversations: new Map(), conversations: new Map(),
@ -83,6 +84,12 @@ export const useStatusesStore = defineStore('statuses', {
// in case of likes (which are not statuses) it should return null // in case of likes (which are not statuses) it should return null
const addStatus = (data) => { const addStatus = (data) => {
const [status] = this.mergeOrAdd(this.allStatuses, data, timestamp) const [status] = this.mergeOrAdd(this.allStatuses, data, timestamp)
let userSet = this.statusesPerUser.get(status.user.id)
if (userSet === undefined) {
userSet = new Set()
this.statusesPerUser.set(status.user.id, userSet)
}
userSet.add(status.id)
// Add to conversation // Add to conversation
const conversations = this.conversations const conversations = this.conversations
@ -527,14 +534,11 @@ export const useStatusesStore = defineStore('statuses', {
// For when blocking a user // For when blocking a user
wipeUserStatuses(userId) { wipeUserStatuses(userId) {
const removed = new Set() const removed = this.statusesPerUser.get(userId)
this.allStatuses.forEach((status) => { removed.forEach((statusId) => {
if (status.user.id === userId) { this.allStatuses.delete(statusId)
this.allStatuses.delete(status.id)
removed.add(status.id)
}
}) })
this.statusesPerUser.delete(userId)
return removed return removed
}, },
}, },