mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 22:49:45 +01:00
fix: sort everything by dateCreated descending
This commit is contained in:
@@ -11,6 +11,7 @@ import getId from "../utils/id";
|
||||
import { EV, EVENTS } from "../common";
|
||||
import { getContentFromData } from "../content-types";
|
||||
import qclone from "qclone/src/qclone";
|
||||
import sort from "fast-sort";
|
||||
|
||||
export default class Notes extends Collection {
|
||||
async add(noteArg) {
|
||||
@@ -158,11 +159,12 @@ export default class Notes extends Collection {
|
||||
_getTagItems(tagId, collection) {
|
||||
const tag = this._db[collection].tag(tagId);
|
||||
if (!tag || tag.noteIds.length <= 0) return [];
|
||||
return tag.noteIds.reduce((arr, id) => {
|
||||
const array = tag.noteIds.reduce((arr, id) => {
|
||||
const item = this._collection.getItem(id);
|
||||
if (item) arr.push(item);
|
||||
return arr;
|
||||
}, []);
|
||||
return sort(array).desc((note) => note.dateCreated);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Topic from "../models/topic";
|
||||
import { qclone } from "qclone";
|
||||
import id from "../utils/id";
|
||||
import sort from "fast-sort";
|
||||
|
||||
export default class Topics {
|
||||
/**
|
||||
@@ -74,7 +75,9 @@ export default class Topics {
|
||||
* @returns {Array} an array containing all the topics
|
||||
*/
|
||||
get all() {
|
||||
return this._db.notebooks.notebook(this._notebookId).data.topics;
|
||||
return sort(this._db.notebooks.notebook(this._notebookId).data.topics).desc(
|
||||
(topic) => topic.dateCreated
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import Collection from "./collection";
|
||||
import getId from "../utils/id";
|
||||
import sort from "fast-sort";
|
||||
import { get7DayTimestamp } from "../utils/date";
|
||||
|
||||
export default class Trash {
|
||||
@@ -14,10 +13,6 @@ export default class Trash {
|
||||
notebooks: db.notebooks,
|
||||
};
|
||||
}
|
||||
// async init() {
|
||||
// await super.init();
|
||||
// await this.cleanup();
|
||||
// }
|
||||
|
||||
async init() {
|
||||
await this.cleanup();
|
||||
@@ -38,7 +33,7 @@ export default class Trash {
|
||||
const collection = this.collections[key];
|
||||
trashItems.push(...collection.deleted);
|
||||
}
|
||||
return trashItems;
|
||||
return sort(trashItems).desc((item) => item.dateDeleted);
|
||||
}
|
||||
|
||||
_getItem(id) {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import Indexer from "./indexer";
|
||||
import sort from "fast-sort";
|
||||
import { EV, EVENTS } from "../common";
|
||||
import IndexedCollection from "./indexed-collection";
|
||||
|
||||
export default class CachedCollection extends IndexedCollection {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { qclone } from "qclone";
|
||||
import sort from "fast-sort";
|
||||
|
||||
export default class Topic {
|
||||
/**
|
||||
* @param {Object} topic
|
||||
@@ -83,11 +85,11 @@ export default class Topic {
|
||||
}
|
||||
|
||||
get all() {
|
||||
return this._topic.notes
|
||||
.map((note) => {
|
||||
let fullNote = this._db.notes.note(note);
|
||||
if (fullNote) return fullNote.data;
|
||||
})
|
||||
.filter((v) => v);
|
||||
const notes = this._topic.notes.reduce((arr, noteId) => {
|
||||
let note = this._db.notes.note(noteId);
|
||||
if (note) arr.push(note.data);
|
||||
return arr;
|
||||
}, []);
|
||||
return sort(notes).desc((note) => note.dateCreated);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user