From c1bf8ae026d475d46e422cd879d1db7485480d4a Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Fri, 30 Oct 2015 22:20:29 -0700 Subject: [PATCH] fix(deltas): Use the official API to create cursors --- .../worker-sync/lib/nylas-long-connection.coffee | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/internal_packages/worker-sync/lib/nylas-long-connection.coffee b/internal_packages/worker-sync/lib/nylas-long-connection.coffee index 6d03e3839..19c8c4407 100644 --- a/internal_packages/worker-sync/lib/nylas-long-connection.coffee +++ b/internal_packages/worker-sync/lib/nylas-long-connection.coffee @@ -46,17 +46,14 @@ class NylasLongConnection cursor = atom.config.get(@_cursorKey) return callback(cursor) if cursor - stamp = Math.round(new Date().getTime() / 1000.0) @_api.makeRequest - path: "/delta/generate_cursor" + path: "/delta/latest_cursor" accountId: @_accountId method: 'POST' - body: { "start": stamp } - success: (json) => - @setCursor(json['cursor']) - callback(json['cursor']) - console.log("Retrieved cursor #{json['cursor']} from \ - `generate_cursor` with timestamp: #{stamp}") + success: ({cursor}) => + console.log("Obtained stream cursor #{cursor}.") + @setCursor(cursor) + callback(cursor) setCursor: (cursor) -> atom.config.set(@_cursorKey, cursor)