From d9632cea61bf8a423ee0bda63dfca2b68573f27d Mon Sep 17 00:00:00 2001 From: Scott Chacon Date: Fri, 7 Jul 2023 12:49:43 +0200 Subject: [PATCH] add modifiedAt to virtual branch file (#648) --- src-tauri/src/virtual_branches/mod.rs | 15 ++++++++++++++- src/lib/api/ipc/vbranches.ts | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/virtual_branches/mod.rs b/src-tauri/src/virtual_branches/mod.rs index 501efe55e..8bb68d287 100644 --- a/src-tauri/src/virtual_branches/mod.rs +++ b/src-tauri/src/virtual_branches/mod.rs @@ -73,6 +73,7 @@ pub struct VirtualBranchFile { pub id: String, pub path: String, pub hunks: Vec, + pub modified_at: u128, } // this struct is a mapping to the view `Hunk` type in Typescript @@ -739,6 +740,12 @@ pub fn list_virtual_branches( id: file_path.clone(), path: file_path.to_string(), hunks: hunks.clone(), + modified_at: hunks + .iter() + .map(|h| h.modified_at) + .max() + .unwrap_or(0) + .into(), }) .collect::>(); } else { @@ -1518,7 +1525,13 @@ pub fn get_status_by_branch( .map(|(file_path, hunks)| VirtualBranchFile { id: file_path.clone(), path: file_path, - hunks, + hunks: hunks.clone(), + modified_at: hunks + .iter() + .map(|h| h.modified_at) + .max() + .unwrap_or(0) + .into(), }) .collect::>(); diff --git a/src/lib/api/ipc/vbranches.ts b/src/lib/api/ipc/vbranches.ts index d2d522e6f..e3f47f932 100644 --- a/src/lib/api/ipc/vbranches.ts +++ b/src/lib/api/ipc/vbranches.ts @@ -19,6 +19,8 @@ export class File { @Type(() => Hunk) hunks!: Hunk[]; expanded?: boolean; + @Transform((obj) => new Date(obj.value)) + modifiedAt!: Date; } export class Branch {