mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
core: set synced to false on removing content by note id
This commit is contained in:
@@ -90,6 +90,25 @@ test("localOnly note should get included as a deleted item in collector", () =>
|
||||
expect(items[1].type).toBe("note");
|
||||
}));
|
||||
|
||||
test("unlinked relation should get included in collector", () =>
|
||||
databaseTest().then(async (db) => {
|
||||
await loginFakeUser(db);
|
||||
const collector = new Collector(db);
|
||||
await db.relations.add(
|
||||
{ id: "h", type: "note" },
|
||||
{ id: "h", type: "attachment" }
|
||||
);
|
||||
|
||||
await iteratorToArray(collector.collect(100, false));
|
||||
|
||||
await db.relations.from({ id: "h", type: "note" }, "attachment").unlink();
|
||||
|
||||
const items = await iteratorToArray(collector.collect(100, false));
|
||||
|
||||
expect(items).toHaveLength(1);
|
||||
expect(items[0].items[0].id).toBe("cd93df7a4c64fbd5f100361d629ac5b5");
|
||||
}));
|
||||
|
||||
async function iteratorToArray(iterator) {
|
||||
let items = [];
|
||||
for await (const item of iterator) {
|
||||
|
||||
@@ -197,7 +197,7 @@ export class Content implements ICollection {
|
||||
await this.db
|
||||
.sql()
|
||||
.replaceInto("content")
|
||||
.columns(["id", "dateModified", "deleted"])
|
||||
.columns(["id", "dateModified", "deleted", "synced"])
|
||||
.expression((eb) =>
|
||||
eb
|
||||
.selectFrom("content")
|
||||
@@ -205,7 +205,8 @@ export class Content implements ICollection {
|
||||
.select((eb) => [
|
||||
"content.id",
|
||||
eb.lit(Date.now()).as("dateModified"),
|
||||
eb.lit(1).as("deleted")
|
||||
eb.lit(1).as("deleted"),
|
||||
eb.lit(0).as("synced")
|
||||
])
|
||||
)
|
||||
.execute();
|
||||
|
||||
Reference in New Issue
Block a user