From 88cda7f7861eaa8cca7394a86981a0b2a2425561 Mon Sep 17 00:00:00 2001 From: Felicio Mununga Date: Thu, 9 Jun 2022 19:33:01 +0200 Subject: [PATCH] change community fetch --- packages/status-js/src/client/community/community.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/status-js/src/client/community/community.ts b/packages/status-js/src/client/community/community.ts index b3f41bc5..e845a006 100644 --- a/packages/status-js/src/client/community/community.ts +++ b/packages/status-js/src/client/community/community.ts @@ -79,10 +79,13 @@ export class Community { await this.waku.store.queryHistory([this.communityContentTopic], { decryptionKeys: [this.communityDecryptionKey], + // oldest message first callback: wakuMessages => { - // todo: iterate from right - for (const wakuMessage of wakuMessages.reverse()) { - this.client.handleWakuMessage(wakuMessage) + let index = wakuMessages.length + + // most recent page first + while (--index >= 0) { + this.client.handleWakuMessage(wakuMessages[index]) if (!this.communityMetadata) { return shouldStop