mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
core: fix Object is not iterable error on some platforms
This happened due to [Symbol.asyncIterable] not getting transformed when it was a method of a class. Moving it inside another method fixes the issue.
This commit is contained in:
committed by
Ammar Ahmed
parent
d55a6a6fc0
commit
a25d21038a
@@ -72,7 +72,9 @@ export async function* exportNotes(
|
|||||||
const pathTree = new PathTree();
|
const pathTree = new PathTree();
|
||||||
const notePathMap: Map<string, string[]> = new Map();
|
const notePathMap: Map<string, string[]> = new Map();
|
||||||
|
|
||||||
for await (const note of notes.fields(["notes.id", "notes.title"])) {
|
for await (const note of notes
|
||||||
|
.fields(["notes.id", "notes.title"])
|
||||||
|
.iterate()) {
|
||||||
const filename = `${sanitizeFilename(note.title || "Untitled", {
|
const filename = `${sanitizeFilename(note.title || "Untitled", {
|
||||||
replacement: "-"
|
replacement: "-"
|
||||||
})}.${FORMAT_TO_EXT[format]}`;
|
})}.${FORMAT_TO_EXT[format]}`;
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ export default class Lookup {
|
|||||||
) {
|
) {
|
||||||
const results: Map<string, number> = new Map();
|
const results: Map<string, number> = new Map();
|
||||||
const columns = fields.map((f) => f.column);
|
const columns = fields.map((f) => f.column);
|
||||||
for await (const item of selector.fields(columns)) {
|
for await (const item of selector.fields(columns).iterate()) {
|
||||||
if (limit && results.size >= limit) break;
|
if (limit && results.size >= limit) break;
|
||||||
|
|
||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ export class Attachments implements ICollection {
|
|||||||
async cleanup() {
|
async cleanup() {
|
||||||
const now = dayjs().unix();
|
const now = dayjs().unix();
|
||||||
const ids: string[] = [];
|
const ids: string[] = [];
|
||||||
for await (const attachment of this.deleted) {
|
for await (const attachment of this.deleted.iterate()) {
|
||||||
if (dayjs(attachment.dateDeleted).add(7, "days").unix() < now) continue;
|
if (dayjs(attachment.dateDeleted).add(7, "days").unix() < now) continue;
|
||||||
|
|
||||||
const isDeleted = await this.db.fs().deleteFile(attachment.hash);
|
const isDeleted = await this.db.fs().deleteFile(attachment.hash);
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ export default class Backup {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let current = 0;
|
let current = 0;
|
||||||
for await (const attachment of this.db.attachments.all) {
|
for await (const attachment of this.db.attachments.all.iterate()) {
|
||||||
current++;
|
current++;
|
||||||
if (
|
if (
|
||||||
!(await this.db
|
!(await this.db
|
||||||
|
|||||||
@@ -476,7 +476,7 @@ export class FilteredSelector<T extends Item> {
|
|||||||
async *map<TReturnType>(
|
async *map<TReturnType>(
|
||||||
fn: (item: T) => TReturnType
|
fn: (item: T) => TReturnType
|
||||||
): AsyncIterableIterator<TReturnType> {
|
): AsyncIterableIterator<TReturnType> {
|
||||||
for await (const item of this) {
|
for await (const item of this.iterate()) {
|
||||||
yield fn(item);
|
yield fn(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -567,9 +567,13 @@ export class FilteredSelector<T extends Item> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iterate() {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||||
|
const thisArg = this;
|
||||||
|
return {
|
||||||
async *[Symbol.asyncIterator]() {
|
async *[Symbol.asyncIterator]() {
|
||||||
let lastRow: any | null = null;
|
let lastRow: any | null = null;
|
||||||
const fields = this._fields.slice();
|
const fields = thisArg._fields.slice();
|
||||||
if (fields.length > 0) {
|
if (fields.length > 0) {
|
||||||
if (!fields.find((f) => f.includes(".dateCreated")))
|
if (!fields.find((f) => f.includes(".dateCreated")))
|
||||||
fields.push("dateCreated");
|
fields.push("dateCreated");
|
||||||
@@ -577,7 +581,7 @@ export class FilteredSelector<T extends Item> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const rows = await this.filter
|
const rows = await thisArg.filter
|
||||||
.orderBy("dateCreated asc")
|
.orderBy("dateCreated asc")
|
||||||
.orderBy("id asc")
|
.orderBy("id asc")
|
||||||
.$if(lastRow !== null, (qb) =>
|
.$if(lastRow !== null, (qb) =>
|
||||||
@@ -587,7 +591,7 @@ export class FilteredSelector<T extends Item> {
|
|||||||
(eb) => eb.tuple(lastRow.dateCreated, lastRow.id)
|
(eb) => eb.tuple(lastRow.dateCreated, lastRow.id)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.limit(this.batchSize)
|
.limit(thisArg.batchSize)
|
||||||
.$if(fields.length === 0, (eb) => eb.selectAll())
|
.$if(fields.length === 0, (eb) => eb.selectAll())
|
||||||
.$if(fields.length > 0, (eb) => eb.select(fields))
|
.$if(fields.length > 0, (eb) => eb.select(fields))
|
||||||
.execute();
|
.execute();
|
||||||
@@ -599,6 +603,8 @@ export class FilteredSelector<T extends Item> {
|
|||||||
lastRow = rows[rows.length - 1];
|
lastRow = rows[rows.length - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private buildSortExpression(options: GroupOptions, hasDueDate?: boolean) {
|
private buildSortExpression(options: GroupOptions, hasDueDate?: boolean) {
|
||||||
sanitizeSortOptions(this.type, options);
|
sanitizeSortOptions(this.type, options);
|
||||||
|
|||||||
Reference in New Issue
Block a user