feat: allow grouping by none

This commit is contained in:
thecodrr
2022-03-31 14:32:24 +05:00
parent 19ef7e1a2c
commit 1703420ca9
4 changed files with 8 additions and 4 deletions

View File

@@ -34,7 +34,7 @@ export class AutoSync {
* @private
*/
schedule(id, item) {
if (item && (item.remote || item.localOnly)) return;
if (item && (item.remote || item.localOnly || item.failed)) return;
clearTimeout(this.timeout);
this.timeout = setTimeout(() => {

View File

@@ -1,5 +1,4 @@
import { qclone } from "qclone";
import sort from "fast-sort";
import { deleteItem, findById } from "../utils/array";
export default class Topic {

View File

@@ -1,6 +1,6 @@
/**
* @typedef {{
* groupBy: "abc" | "year" | "month" | "week" | undefined,
* groupBy: "abc" | "year" | "month" | "week" | "none" | undefined,
* sortBy: "dateCreated" | "dateDeleted" | "dateEdited" | "title",
* sortDirection: "desc" | "asc"
* }} GroupOptions

View File

@@ -47,10 +47,15 @@ export function groupArray(
sortDirection: "desc",
}
) {
const keySelector = KEY_SELECTORS[options.groupBy || "default"];
if (options.sortBy && options.sortDirection)
fastsort(array).by(getSortSelectors(options));
if (options.groupBy === "none") {
array.splice(0, 0, { title: "All", type: "header" });
return array;
}
const keySelector = KEY_SELECTORS[options.groupBy || "default"];
let groups = new Map();
array.forEach((item) => {
let groupTitle = item.pinned