mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-06-02 22:26:57 -05:00
Fix users without weapon pool having one "null weapon"
This commit is contained in:
parent
af7c4db4f4
commit
68dac83f4f
|
|
@ -6,7 +6,7 @@ import type {
|
|||
UserWeapon,
|
||||
UserWithPlusTier,
|
||||
} from "../../types";
|
||||
import { parseDBArray } from "~/utils/sql";
|
||||
import { parseDBJsonArray } from "~/utils/sql";
|
||||
import { dateToDatabaseTimestamp } from "~/utils/dates";
|
||||
|
||||
import addPatronDataSql from "./addPatronData.sql";
|
||||
|
|
@ -144,7 +144,7 @@ export function findByIdentifier(identifier: string | number) {
|
|||
return {
|
||||
...row,
|
||||
css: css ? JSON.parse(css) : undefined,
|
||||
weapons: parseDBArray(weapons),
|
||||
weapons: parseDBJsonArray(weapons),
|
||||
team: teamName
|
||||
? {
|
||||
name: teamName,
|
||||
|
|
|
|||
|
|
@ -7,8 +7,10 @@ export function parseDBJsonArray(value: any) {
|
|||
|
||||
// If the returned array of JSON objects from DB is empty
|
||||
// it will be returned as object with all values being null
|
||||
// this is a workaround for that
|
||||
return parsed.filter((item: any) => Object.values(item).some(Boolean));
|
||||
// this is a (hacky) workaround for that
|
||||
return parsed.filter((item: any) =>
|
||||
Object.values(item).some((val) => val !== null)
|
||||
);
|
||||
}
|
||||
|
||||
export function parseDBArray(value: any) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user