From eaeb7af2740431dea5b613802a7a5f73ab620e61 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Fri, 16 Sep 2022 14:37:52 -0700 Subject: [PATCH] Change folder tag to int --- lib/Controller/ApiController.php | 2 +- lib/Util.php | 3 +++ src/components/Timeline.vue | 15 ++++++++++----- src/mixins/GlobalMixin.ts | 5 +++++ src/types.ts | 1 + 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index 77730067..9ed47a17 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -203,7 +203,7 @@ class ApiController extends Controller { // Map sub to JSON array $subdirArray = [ - "dayid" => -0.1, + "dayid" => \OCA\Memories\Util::$TAG_DAYID_FOLDERS, "detail" => array_map(function ($node) { return [ "fileid" => $node->getId(), diff --git a/lib/Util.php b/lib/Util.php index 215775cd..35b9be51 100644 --- a/lib/Util.php +++ b/lib/Util.php @@ -7,6 +7,9 @@ use OCA\Memories\AppInfo\Application; use OCP\IConfig; class Util { + public static $TAG_DAYID_START = -(1 << 30); // the world surely didn't exist + public static $TAG_DAYID_FOLDERS = -(1 << 30) + 1; + /** * Get the path to the user's configured photos directory. * @param IConfig $config diff --git a/src/components/Timeline.vue b/src/components/Timeline.vue index 197d6b95..fa0577cf 100644 --- a/src/components/Timeline.vue +++ b/src/components/Timeline.vue @@ -308,7 +308,7 @@ export default class Timeline extends Mixins(GlobalMixin) { this.rowHeight = Math.floor(width / this.numCols); // Set heights of rows - this.list.filter(r => r.type === IRowType.PHOTOS).forEach(row => { + this.list.filter(r => r.type !== IRowType.HEAD).forEach(row => { row.size = this.rowHeight; }); this.reflowTimeline(true); @@ -432,8 +432,8 @@ export default class Timeline extends Mixins(GlobalMixin) { } // Special headers - if (head.dayId === -0.1) { - head.name = "Folders"; + if (head.dayId === this.TagDayID.FOLDERS) { + head.name = this.t("memories", "Folders"); return head.name; } @@ -803,10 +803,15 @@ export default class Timeline extends Mixins(GlobalMixin) { /** Get a new blank photos row */ getBlankRow(day: IDay): IRow { + let rowType = IRowType.PHOTOS; + if (day.dayid === this.TagDayID.FOLDERS) { + rowType = IRowType.FOLDERS; + } + return { id: ++this.numRows, photos: [], - type: IRowType.PHOTOS, + type: rowType, size: this.rowHeight, dayId: day.dayid, day: day, @@ -882,7 +887,7 @@ export default class Timeline extends Mixins(GlobalMixin) { /** Add a photo to selection list */ selectPhoto(photo: IPhoto, val?: boolean, noUpdate?: boolean) { - if (photo.flag & this.c.FLAG_PLACEHOLDER) { + if (photo.flag & this.c.FLAG_PLACEHOLDER || photo.flag & this.c.FLAG_IS_FOLDER) { return; // ignore placeholders } diff --git a/src/mixins/GlobalMixin.ts b/src/mixins/GlobalMixin.ts index d714c63d..44718c85 100644 --- a/src/mixins/GlobalMixin.ts +++ b/src/mixins/GlobalMixin.ts @@ -19,4 +19,9 @@ export default class GlobalMixin extends Vue { FLAG_ENTER_RIGHT: 1 << 9, FLAG_FORCE_RELOAD: 1 << 10, } + + public readonly TagDayID = { + START: -(1 << 30), + FOLDERS: -(1 << 30) + 1, + } } \ No newline at end of file diff --git a/src/types.ts b/src/types.ts index a56a3efb..bfa7ecfc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -74,6 +74,7 @@ export type IHeadRow = IRow & { export enum IRowType { HEAD = 0, PHOTOS = 1, + FOLDERS = 2, } export type ITick = {