fix: Cannot create collection if all collections deleted

This commit is contained in:
Tom Moor 2021-03-19 08:01:13 -07:00
parent 56c4acc18f
commit 7891a8ee8b
2 changed files with 5 additions and 2 deletions

View File

@ -74,7 +74,10 @@ router.post("collections.create", auth(), async (ctx) => {
);
}
} else {
index = fractionalIndex(null, collections[0].index);
index = fractionalIndex(
null,
collections.length ? collections[0].index : null
);
}
index = await removeIndexCollision(user.teamId, index);

View File

@ -1002,7 +1002,7 @@ describe("#collections.create", () => {
});
it("should create collection", async () => {
const { user } = await seed();
const user = await buildUser();
const res = await server.post("/api/collections.create", {
body: { token: user.getJwtToken(), name: "Test" },
});