A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: add pinned group
thecodrr5d75e165bc5b
diff --git a/packages/core/api/database.js b/packages/core/api/database.jsindex ca6d5fdc3..820d82f8d 100644--- a/packages/core/api/database.js+++ b/packages/core/api/database.js@@ -68,8 +68,9 @@ class Database {* @param {boolean} special Should only be used in the React app.*/groupNotes(by, special = false) {- //TODO add tests- let notes = tfun.filter(".pinned == false")(this.getNotes());+ let notes = !special+ ? tfun.filter(".pinned == false")(this.getNotes())+ : this.getNotes();switch (by) {case "abc":return groupBy(diff --git a/packages/core/utils/index.js b/packages/core/utils/index.jsindex 411cb8b80..937578523 100644--- a/packages/core/utils/index.js+++ b/packages/core/utils/index.js@@ -1,5 +1,7 @@var tfun = require("transfun/transfun.js").tfun;-tfun = global.tfun;+if (!tfun) {+ tfun = global.tfun;+}export function extractValues(obj) {const t = [];@@ -35,20 +37,33 @@ function groupBySpecial(arr, key) {let groups = [];let groupCounts = [];var i = -1;+ let pinned = [];for (let val of arr) {+ if (val.pinned) {+ pinned[pinned.length] = val;+ continue;+ }i++;- let k = key(val);- let index = _groups[k] === undefined ? i : _groups[k].index;+ let groupTitle = key(val);+ let index =+ _groups[groupTitle] === undefined ? i : _groups[groupTitle].index;let groupIndex =- _groups[k] == undefined ? groupCounts.length : _groups[k].groupIndex;+ _groups[groupTitle] == undefined+ ? groupCounts.length+ : _groups[groupTitle].groupIndex;retVal.splice(index + 1, 0, val);groupCounts[groupIndex] =groupCounts.length == groupIndex ? 1 : groupCounts[groupIndex] + 1;- groups[groupIndex] = { title: k };- _groups[k] = {+ groups[groupIndex] = { title: groupTitle };+ _groups[groupTitle] = {index: i,groupIndex};}- return { items: retVal, groups, groupCounts };++ let g = { items: retVal, groups, groupCounts };+ g.items.splice(0, 0, ...pinned);+ g.groupCounts.splice(0, 0, pinned.length);+ g.groups.splice(0, 0, { title: " " });+ return g;}