Skip to content

Commit 8109f47

Browse files
committed
feat: add sync count tracking for remote conversations
1 parent 4ebe87d commit 8109f47

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

crates/restsend/src/client/conversation.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl Client {
231231
let mut last_updated_at_remote = before_updated_at;
232232
let mut last_removed_at = last_removed_at.clone();
233233
let mut total = 0;
234-
234+
let mut sync_count_from_remote = 0;
235235
loop {
236236
let st_0 = now_millis();
237237
match get_conversations(
@@ -255,7 +255,7 @@ impl Client {
255255
last_updated_at_remote = lr.last_updated_at.clone();
256256
0
257257
};
258-
258+
sync_count_from_remote += lr.items.len() as u32;
259259
if last_updated_at.is_empty() && !lr.items.is_empty() {
260260
last_updated_at = lr.items.first().unwrap().updated_at.clone();
261261
}
@@ -284,9 +284,9 @@ impl Client {
284284
}
285285

286286
log::info!(
287-
"sync conversations from remote, count: {} removed:{} api_cost:{:?} merge_cost: {:?}, callback_cost: {:?}, total_cost: {:?}",
288-
new_conversations_count,
287+
"sync conversations from remote, count: {new_conversations_count} removed:{} has_more:{} api_cost:{:?} merge_cost: {:?}, callback_cost: {:?}, total_cost: {:?}, sync_max_count: {sync_max_count}",
289288
lr.removed.len(),
289+
lr.has_more,
290290
api_cost,
291291
merge_cost,
292292
elapsed(st),
@@ -295,7 +295,7 @@ impl Client {
295295
if !lr.has_more {
296296
break;
297297
}
298-
if sync_max_count > 0 && conversations.len() as u32 >= sync_max_count {
298+
if sync_max_count > 0 && sync_count_from_remote >= sync_max_count {
299299
break;
300300
}
301301
}

js/restsend_wasm_bg.wasm

107 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)