getMessagesPage method

Future getMessagesPage(
  1. int limit,
  2. bool forward
)

Request more messages from the server

limit - number of messages to get. forward if true, request newer messages.

Implementation

Future getMessagesPage(int limit, bool forward) {
  var query = startMetaQuery();
  var future = getMeta(query.build());

  if (forward) {
    query.withLaterData(limit);
  } else {
    query.withEarlierData(limit);
    future = future.then((response) {
      var ctrl = CtrlMessage.fromMessage(response);
      if (ctrl.params != null &&
          (ctrl.params['count'] == null || ctrl.params['count'] == 0)) {
        _noEarlierMsgs = true;
      }
    });
  }

  return future;
}