fix: prevent incorrect card indexing
This commit is contained in:
@@ -214,9 +214,10 @@ export const cardRouter = createTRPCRouter({
|
|||||||
|
|
||||||
if (!newList) return;
|
if (!newList) return;
|
||||||
|
|
||||||
if (!newIndex) {
|
if (newIndex === undefined) {
|
||||||
const lastCardIndex = newList.cards[0]?.index;
|
const lastCardIndex = newList.cards.length ? newList.cards[0]?.index : undefined;
|
||||||
newIndex = lastCardIndex ? lastCardIndex + 1 : 0;
|
|
||||||
|
newIndex = lastCardIndex !== undefined ? lastCardIndex + 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentList?.id || !newList?.id) return;
|
if (!currentList?.id || !newList?.id) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user