diff --git a/ably.d.ts b/ably.d.ts index 08088741a1..0eb8e3f4f4 100644 --- a/ably.d.ts +++ b/ably.d.ts @@ -3460,13 +3460,13 @@ declare namespace Types { * * @param results - A function which, upon success, will be fulfilled with a page of results for message and presence history, stats, and REST presence requests. Upon failure, the function will be called with information about the error. */ - next(results: paginatedResultCallback): void; + next(results: StandardCallback | null>): void; /** * Returns a new `PaginatedResult` loaded with the next page of results. If there are no further pages, then `null` is returned. * * @returns A promise which, upon success, will be fulfilled with a page of results for message and presence history, stats, and REST presence requests. Upon failure, the promise will be rejected with an {@link ErrorInfo} object which explains the error. */ - next(): Promise>; + next(): Promise | null>; /** * Returns the `PaginatedResult` for the current page of results. * diff --git a/src/common/lib/client/paginatedresource.ts b/src/common/lib/client/paginatedresource.ts index 73eb89872d..700dba83c5 100644 --- a/src/common/lib/client/paginatedresource.ts +++ b/src/common/lib/client/paginatedresource.ts @@ -209,7 +209,7 @@ export class PaginatedResult { if ('next' in relParams) { self.get(relParams.next, callback); } else { - callback(null); + callback(null, null); } }; diff --git a/test/rest/history.test.js b/test/rest/history.test.js index f686c0db71..50f1059072 100644 --- a/test/rest/history.test.js +++ b/test/rest/history.test.js @@ -444,6 +444,26 @@ define(['shared_helper', 'async', 'chai'], function (helper, async, chai) { } }); + restTestOnJsonMsgpack('history_no_next_page', function (done, rest, channelName) { + const channel = rest.channels.get(channelName); + + channel.history(function (err, firstPage) { + if (err) { + done(err); + return; + } + firstPage.next(function (err, secondPage) { + if (err) { + done(err); + return; + } + + expect(secondPage).to.equal(null); + done(); + }); + }); + }); + if (typeof Promise !== 'undefined') { it('historyPromise', function (done) { var rest = helper.AblyRest({ promises: true });