From 83fefe585b8e4c03b2e0dad10f504a657df9a5a6 Mon Sep 17 00:00:00 2001 From: KnugiHK <24708955+KnugiHK@users.noreply.github.com> Date: Sat, 13 Jul 2024 12:18:18 +0800 Subject: [PATCH] Refactoring The added code should be placed above any platform specific code --- Whatsapp_Chat_Exporter/utility.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Whatsapp_Chat_Exporter/utility.py b/Whatsapp_Chat_Exporter/utility.py index ad8e1e1..09e6671 100644 --- a/Whatsapp_Chat_Exporter/utility.py +++ b/Whatsapp_Chat_Exporter/utility.py @@ -167,6 +167,12 @@ def get_chat_condition(filter, include, column): else: return "" +def _is_message_empty(message): + return (message.data is None or message.data == "") and not message.media + +def is_chat_empty(chat: ChatStore): + return len(chat.messages) == 0 or all(_is_message_empty(message) for message in chat.messages.values()) + # Android Specific CRYPT14_OFFSETS = ( @@ -344,10 +350,3 @@ class JidType(IntEnum): GROUP = 1 SYSTEM_BROADCAST = 5 STATUS = 11 - -def _is_message_empty(message): - return (message.data is None or message.data == "") and not message.media - -def is_chat_empty(chat: ChatStore): - is_empty = len(chat.messages) == 0 or all(_is_message_empty(f) for f in chat.messages.values()) - return is_empty