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