forked from AkkomaGang/akkoma-fe
added some more explicit to string conversion since BE seem to be sending
numbers and it could cause an issue.
This commit is contained in:
parent
ef2585e32b
commit
48e811e6ed
2 changed files with 13 additions and 2 deletions
|
@ -105,6 +105,9 @@ export const findMaxId = (...args) => {
|
|||
}
|
||||
|
||||
const mergeOrAdd = (arr, obj, item) => {
|
||||
// For sequential IDs BE passes numbers as numbers, we want them as strings.
|
||||
item.id = String(item.id)
|
||||
|
||||
const oldItem = obj[item.id]
|
||||
|
||||
if (oldItem) {
|
||||
|
@ -292,8 +295,13 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot
|
|||
each(notifications, (notification) => {
|
||||
const result = mergeOrAdd(allStatuses, allStatusesObject, notification.notice)
|
||||
const action = result.item
|
||||
// For sequential IDs BE passes numbers as numbers, we want them as strings.
|
||||
action.id = String(action.id)
|
||||
|
||||
// Only add a new notification if we don't have one for the same action
|
||||
// TODO: this technically works but should be checking for notification.id, not action.id i think
|
||||
if (!find(state.notifications.data, (oldNotification) => oldNotification.action.id === action.id)) {
|
||||
// TODO: adapt to "what if notification ids are not actually numbers"
|
||||
state.notifications.maxId = Math.max(notification.id, state.notifications.maxId)
|
||||
state.notifications.minId = Math.min(notification.id, state.notifications.minId)
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ import { humanizeErrors } from './errors'
|
|||
|
||||
// TODO: Unify with mergeOrAdd in statuses.js
|
||||
export const mergeOrAdd = (arr, obj, item) => {
|
||||
// For sequential IDs BE passes numbers as numbers, we want them as strings.
|
||||
item.id = String(item.id)
|
||||
|
||||
if (!item) { return false }
|
||||
const oldItem = obj[item.id]
|
||||
if (oldItem) {
|
||||
|
@ -64,10 +67,10 @@ export const mutations = {
|
|||
each(users, (user) => mergeOrAdd(state.users, state.usersObject, user))
|
||||
},
|
||||
setUserForStatus (state, status) {
|
||||
status.user = state.usersObject[status.user.id]
|
||||
status.user = state.usersObject[String(status.user.id)]
|
||||
},
|
||||
setUserForNotification (state, notification) {
|
||||
notification.action.user = state.usersObject[notification.action.user.id]
|
||||
notification.action.user = state.usersObject[String(notification.action.user.id)]
|
||||
},
|
||||
setColor (state, { user: { id }, highlighted }) {
|
||||
const user = state.usersObject[id]
|
||||
|
|
Loading…
Reference in a new issue