fix reporting modal
This commit is contained in:
parent
cbd79a48af
commit
946682b3b4
5 changed files with 26 additions and 27 deletions
|
|
@ -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
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue