From 915f9893a54644e7ae1276d297c89e1effff8bc8 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Sat, 22 Feb 2020 09:03:27 +0800 Subject: [PATCH] api: item/sync: handle sync_token behind cursor_token this can happen e.g. the client synchronizes new items but have nothing new to send back to the server. --- src/api.rs | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/api.rs b/src/api.rs index 711f22e..b603fa1 100644 --- a/src/api.rs +++ b/src/api.rs @@ -194,6 +194,8 @@ fn items_sync(db: DbConn, u: user::User, params: Json) -> Custom = None; let mut max_id: Option = None; let mut had_cursor = false; + // mark if we have a larger sync_token than cursor_token + let mut sync_token_ahead = false; if let Some(cursor_token) = inner_params.cursor_token { // If the client provides cursor_token, @@ -211,7 +213,25 @@ fn items_sync(db: DbConn, u: user::User, params: Json) -> Custom) -> Custom