channel is nullable fixes
This commit is contained in:
parent
a4c50ae922
commit
af70a7f21b
@ -5171,7 +5171,10 @@
|
|||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"parent_id": {
|
"parent_id": {
|
||||||
"type": "string"
|
"type": [
|
||||||
|
"null",
|
||||||
|
"string"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -59954,7 +59954,10 @@
|
|||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"parent_id": {
|
"parent_id": {
|
||||||
"type": "string"
|
"type": [
|
||||||
|
"null",
|
||||||
|
"string"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -120,8 +120,9 @@ router.patch(
|
|||||||
(x) => !body.find((c) => c.id == x),
|
(x) => !body.find((c) => c.id == x),
|
||||||
);
|
);
|
||||||
|
|
||||||
const withParents = body.filter((x) => x.parent_id != undefined);
|
const withParents = body.filter((x) => x.parent_id !== undefined);
|
||||||
const withPositions = body.filter((x) => x.position != undefined);
|
console.log(body);
|
||||||
|
const withPositions = body.filter((x) => x.position !== undefined);
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
withPositions.map(async (opt) => {
|
withPositions.map(async (opt) => {
|
||||||
@ -148,22 +149,30 @@ router.patch(
|
|||||||
Channel.findOneOrFail({
|
Channel.findOneOrFail({
|
||||||
where: { id: opt.id },
|
where: { id: opt.id },
|
||||||
}),
|
}),
|
||||||
Channel.findOneOrFail({
|
opt.parent_id
|
||||||
where: { id: opt.parent_id as string },
|
? Channel.findOneOrFail({
|
||||||
select: { permission_overwrites: true, id: true },
|
where: { id: opt.parent_id },
|
||||||
}),
|
select: {
|
||||||
|
permission_overwrites: true,
|
||||||
|
id: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
: null,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (opt.lock_permissions)
|
if (opt.lock_permissions && parent)
|
||||||
await Channel.update(
|
await Channel.update(
|
||||||
{ id: channel.id },
|
{ id: channel.id },
|
||||||
{ permission_overwrites: parent.permission_overwrites },
|
{ permission_overwrites: parent.permission_overwrites },
|
||||||
);
|
);
|
||||||
|
if (parent) {
|
||||||
const parentPos = notMentioned.indexOf(parent.id);
|
const parentPos = notMentioned.indexOf(parent.id);
|
||||||
notMentioned.splice(parentPos + 1, 0, channel.id);
|
notMentioned.splice(parentPos + 1, 0, channel.id);
|
||||||
channel.position = (parentPos + 1) as number;
|
channel.position = (parentPos + 1) as number;
|
||||||
channel.parent = parent;
|
}
|
||||||
|
channel.parent = parent || undefined;
|
||||||
|
channel.parent_id = null;
|
||||||
|
console.log(channel.parent);
|
||||||
await channel.save();
|
await channel.save();
|
||||||
|
|
||||||
await emitEvent({
|
await emitEvent({
|
||||||
|
@ -20,5 +20,5 @@ export type ChannelReorderSchema = {
|
|||||||
id: string;
|
id: string;
|
||||||
position?: number;
|
position?: number;
|
||||||
lock_permissions?: boolean;
|
lock_permissions?: boolean;
|
||||||
parent_id?: string;
|
parent_id?: null | string;
|
||||||
}[];
|
}[];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user