xuang7 commented on code in PR #5220:
URL: https://github.com/apache/texera/pull/5220#discussion_r3307818393


##########
frontend/src/app/dashboard/component/user/list-item/list-item.component.ts:
##########
@@ -372,31 +373,7 @@ export class ListItemComponent implements OnChanges {
     }
   }
 
-  formatTime(timestamp: number | undefined): string {
-    if (timestamp === undefined) {
-      return "Unknown"; // Return "Unknown" if the timestamp is undefined
-    }
-
-    const currentTime = new Date().getTime();
-    const timeDifference = currentTime - timestamp;
-
-    const minutesAgo = Math.floor(timeDifference / (1000 * 60));
-    const hoursAgo = Math.floor(timeDifference / (1000 * 60 * 60));
-    const daysAgo = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
-    const weeksAgo = Math.floor(daysAgo / 7);
-
-    if (minutesAgo < 60) {
-      return `${minutesAgo} minutes ago`;
-    } else if (hoursAgo < 24) {
-      return `${hoursAgo} hours ago`;
-    } else if (daysAgo < 7) {
-      return `${daysAgo} days ago`;
-    } else if (weeksAgo < 4) {
-      return `${weeksAgo} weeks ago`;
-    } else {
-      return new Date(timestamp).toLocaleDateString();
-    }
-  }
+  formatRelativeTime = formatRelativeTime;

Review Comment:
   The reason is that Angular templates only resolve identifiers against the 
component instance, so top-level imports are not visible in the template scope. 
Because of that, we need to expose them as class fields. This followed the same 
pattern used in other places in the codebase.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to