newThreadToQueue method

Future<int> newThreadToQueue(
  1. String _baseUrl,
  2. String text,
  3. Uint8List attachement,
  4. String _nick,
  5. String _avatar,
  6. String shortLinkOfPrevious,
  7. String cid,
  8. String attachmentType,
  9. String xxHash,
  10. String _blurHash,
  11. int attachmentLength,
)

Implementation

Future<int> newThreadToQueue(
    String _baseUrl,
    String text,
    Uint8List attachement,
    String _nick,
    String _avatar,
    String shortLinkOfPrevious,
    String cid,
    String attachmentType,
    String xxHash,
    String _blurHash,
    int attachmentLength) async {
  if (shortLinkOfPrevious.isEmpty) {
    //patch in latest root
    final own = LatestThreads.latestMineShortLink;
    if (own.isEmpty) {
      shortLinkOfPrevious = LatestThreads.posts.last.shortLink;
    } else {
      shortLinkOfPrevious = own;
    }
  }

  final ogm = _ogMessages.addPost(
      _nick,
      _avatar,
      text,
      shortLinkOfPrevious,
      '',
      now,
      attachement,
      cid,
      attachmentType,
      xxHash,
      _blurHash,
      attachmentLength);

  if (ogm == null) return -1;

  //just push to disk when no net availablus
  _ogMessages.pushToDiskQueue(ogm.timestamp);

  //update cache of fake entries to show
  //dirty so flutter updates cache for queued entries
  _dirty = true;
  currentPendingAsModeratorEntries;
  return ogm.timestamp;
}