From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED, URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1696301546; bh=CWw+0z49xUNeRr+g2XNqydQ7FLKis6XmmNW6Ld7X0is=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XBA8xj0KJZVHTSjvSM/cggd8OgPwjTfS0Vw1Mr13tDlCiUoRH6z0CjPrm/xQhvTKY HP2okvLpOd0CTbv9/XvCe3jBOlRX5omYgMIA2H7rJXzISxYcQXnCBkC1QLV0w1DdEy sUAwyJqZUWsj5OMNUKwTORSk+v/NxUANhR97UI1o1tlpHud4r0DFtmMU5YC3EWjW8V 8sVVfeRM5vGQ2DhTgSfJlGGM+rfVzH+hCUjmuPXfnavZBKUSMmRe/kBAEpRErS+Z0P ml+dHkYyNU68+WnXE4xW53w53PLg9yyB3drr/B+znUiPe7J53Etk4JhI9WHW2N5N73 h4BuRjXc3OdDg== Received: from localhost.localdomain (unknown [175.158.50.50]) by gnuweeb.org (Postfix) with ESMTPSA id 0BCB224B8B4; Tue, 3 Oct 2023 09:52:24 +0700 (WIB) From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , Irvan Malik Azantha , Memet Zx , GNU/Weeb Mailing List Subject: [PATCH v1 06/13] feat(lib/functions): add getRepliedMessage() function Date: Tue, 3 Oct 2023 09:51:39 +0700 Message-Id: <20231003025146.1557-7-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20231003025146.1557-1-kiizuha@gnuweeb.org> References: <20231003025146.1557-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This commit introduces the getRepliedMessage() function, designed to retrieve message data that is being replied to by the user. Signed-off-by: Muhammad Rizki --- src/lib/functions.ts | 9 +++++++++ src/lib/index.ts | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lib/functions.ts b/src/lib/functions.ts index 0357e6b..510f13e 100644 --- a/src/lib/functions.ts +++ b/src/lib/functions.ts @@ -93,3 +93,12 @@ export const setupUserName = (first: string, last: string | null) => { } return [ firstName, lastName ]; } + +export const getRepliedMessage = ( + current: RecentMessagesReturnType, + messages: RecentMessagesReturnType[] +): RecentMessagesReturnType[] => { + return messages.filter(msg => { + return msg.message_id === current.reply_to_message_id + }); +} diff --git a/src/lib/index.ts b/src/lib/index.ts index e8a9d9b..b62f0bd 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -8,7 +8,8 @@ import { getOrgMembers, getFixedRandomColor, cleanMessageText, - setupUserName + setupUserName, + getRepliedMessage } from "./functions"; export { @@ -18,5 +19,6 @@ export { getOrgMembers, getFixedRandomColor, cleanMessageText, - setupUserName + setupUserName, + getRepliedMessage }; -- Muhammad Rizki