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

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