This repository was archived by the owner on Apr 21, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +29
-11
lines changed Expand file tree Collapse file tree 1 file changed +29
-11
lines changed Original file line number Diff line number Diff line change @@ -274,25 +274,43 @@ export function Chat() {
274
274
// "npub1qf8e8cvfp60ywrah984zgsn8veggcrsv2cvttdr47tgz05ypf5yszwx308",
275
275
contact . npub ,
276
276
20n ,
277
+ undefined ,
277
278
refetchingTimestamp ? refetchingTimestamp : undefined
278
279
) ;
279
280
280
- const lastConvo = info . value as CombinedMessagesAndActivity [ ] ;
281
- if (
282
- lastConvo &&
283
- lastConvo . length === convo . length + activity . length
284
- ) {
285
- console . log ( "no new messages or activity" ) ;
286
- return lastConvo ;
287
- }
288
-
289
- console . log ( "dms" , convo ) ;
290
-
291
281
setLastFetch ( BigInt ( Math . floor ( Date . now ( ) / 1000 ) ) ) ;
292
282
293
283
const dms = convo as FakeDirectMessage [ ] ;
294
284
const acts = activity as IActivityItem [ ] ;
295
285
286
+ if ( info . refetching ) {
287
+ const lastConvo =
288
+ info . value as CombinedMessagesAndActivity [ ] ;
289
+
290
+ let lastConvoActivity = 0 ;
291
+
292
+ // TODO: remove this once we can do "since" for activity as well
293
+ for ( let i = 0 ; i < lastConvo . length ; i ++ ) {
294
+ if ( lastConvo [ i ] . kind === "activity" ) {
295
+ lastConvoActivity += 1 ;
296
+ }
297
+ }
298
+
299
+ if (
300
+ convo . length === 0 &&
301
+ activity . length === lastConvoActivity
302
+ ) {
303
+ console . log ( "no new messages or activity" ) ;
304
+ // Return early because we've determined there's nothing new
305
+ return lastConvo ;
306
+ } else {
307
+ console . log ( "new messages or activity" ) ;
308
+ dms . push ( convo ) ;
309
+ }
310
+ }
311
+
312
+ console . log ( "dms" , convo ) ;
313
+
296
314
// Combine both arrays into an array of CombinedMessagesAndActivity, then sort by date
297
315
const combined = [
298
316
...dms . map ( ( dm ) => ( {
You can’t perform that action at this time.
0 commit comments