@@ -7,6 +7,14 @@ import { Table } from "./types";
7
7
import { minutes_ago } from "../misc" ;
8
8
import { SCHEMA as schema } from "./index" ;
9
9
10
+ // Helper function to normalize dates for comparison
11
+ function getTime ( date : any ) : number {
12
+ if ( ! date ) return 0 ;
13
+ if ( date instanceof Date ) return date . getTime ( ) ;
14
+ if ( typeof date === "string" ) return new Date ( date ) . getTime ( ) ;
15
+ return 0 ;
16
+ }
17
+
10
18
/* TODO: for postgres rewrite after done we MIGHT completely redo file_use to eliminate
11
19
the id field, use project_id, path as a compound primary key, and maybe put users in
12
20
another table with a relation. There is also expert discussion about this table in the
@@ -92,12 +100,14 @@ Table({
92
100
// Otherwise we touch the project just for seeing notifications or opening
93
101
// the file, which is confusing and wastes a lot of resources.
94
102
const x = obj . users != null ? obj . users [ account_id ] : undefined ;
95
- // edit/chat/open fields are now strings due to using conat and not auto
96
- // autoconverting them to Dates at this point, hence comparing iso strings:
97
- const recent = minutes_ago ( 3 ) . toISOString ( ) ;
103
+ // edit/chat/open fields may be strings or Date objects depending on how they're processed
104
+ const recentTime = minutes_ago ( 3 ) . getTime ( ) ;
105
+
98
106
if (
99
107
x != null &&
100
- ( x . edit >= recent || x . chat >= recent || x . open >= recent )
108
+ ( getTime ( x . edit ) >= recentTime ||
109
+ getTime ( x . chat ) >= recentTime ||
110
+ getTime ( x . open ) >= recentTime )
101
111
) {
102
112
db . touch ( { project_id : obj . project_id , account_id } ) ;
103
113
// Also log that this particular file is being used/accessed; this
0 commit comments