From 317652b6da2ea2831b1a42038ca04fbcc0fa1a20 Mon Sep 17 00:00:00 2001 From: Kristofer Berggren Date: Sat, 16 Mar 2024 21:54:05 +0800 Subject: [PATCH] fixes #205 - mute whatsapp status broadcast by default --- README.md | 6 ++++++ lib/common/src/version.h | 2 +- src/nchat.1 | 2 +- src/uiconfig.cpp | 1 + src/uimodel.cpp | 9 ++++++++- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 81fbe634..1231b6af 100644 --- a/README.md +++ b/README.md @@ -330,6 +330,7 @@ This configuration file holds general user interface settings. Default content: mark_read_on_view=1 mark_read_when_inactive=0 message_open_command= + mute_status_broadcast=1 muted_indicate_unread=1 muted_notify_unread=0 muted_position_by_timestamp=1 @@ -481,6 +482,11 @@ Specifies a custom command to use for opening/viewing message text part. If not specified, nchat will use `PAGER` environment variable if set, or otherwise use `less`. +### mute_status_broadcast + +Specifies whether (WhatsApp) status broadcast chat should be treated as +muted. + ### muted_indicate_unread Specifies whether chat list should indicate unread status `*` for muted chats. diff --git a/lib/common/src/version.h b/lib/common/src/version.h index 6c758f7d..fec6be3e 100644 --- a/lib/common/src/version.h +++ b/lib/common/src/version.h @@ -7,4 +7,4 @@ #pragma once -#define NCHAT_VERSION "4.40" +#define NCHAT_VERSION "4.41" diff --git a/src/nchat.1 b/src/nchat.1 index e8cdb0e3..3ebc48ee 100644 --- a/src/nchat.1 +++ b/src/nchat.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man. -.TH NCHAT "1" "March 2024" "nchat v4.40" "User Commands" +.TH NCHAT "1" "March 2024" "nchat v4.41" "User Commands" .SH NAME nchat \- ncurses chat .SH SYNOPSIS diff --git a/src/uiconfig.cpp b/src/uiconfig.cpp index 70afda99..23f5ffbc 100644 --- a/src/uiconfig.cpp +++ b/src/uiconfig.cpp @@ -39,6 +39,7 @@ void UiConfig::Init() { "mark_read_on_view", "1" }, { "mark_read_when_inactive", "0" }, { "message_open_command", "" }, + { "mute_status_broadcast", "1" }, { "muted_indicate_unread", "1" }, { "muted_notify_unread", "0" }, { "muted_position_by_timestamp", "1" }, diff --git a/src/uimodel.cpp b/src/uimodel.cpp index ce6b04fe..50e71b9f 100644 --- a/src/uimodel.cpp +++ b/src/uimodel.cpp @@ -1537,7 +1537,7 @@ void UiModel::MessageHandler(std::shared_ptr p_ServiceMessage) const std::vector& contactInfos = newContactsNotify->contactInfos; for (auto& contactInfo : contactInfos) { - LOG_TRACE("NewContacts"); + LOG_TRACE("NewContacts %s", contactInfo.id.c_str()); m_ContactInfos[profileId][contactInfo.id] = contactInfo; } @@ -1557,6 +1557,13 @@ void UiModel::MessageHandler(std::shared_ptr p_ServiceMessage) LOG_TRACE("new chats %d", newChatsNotify->chatInfos.size()); for (auto& chatInfo : newChatsNotify->chatInfos) { + LOG_TRACE("new chats %s", chatInfo.id.c_str()); + static const bool muteStatusBroadcast = UiConfig::GetBool("mute_status_broadcast"); + if (muteStatusBroadcast && (chatInfo.id == "status@broadcast")) + { + chatInfo.isMuted = true; + } + m_ChatInfos[profileId][chatInfo.id] = chatInfo; HandleChatInfoMutedUpdate(profileId, chatInfo.id);