~aleteoryx/muditaos

c82f16e3b18a05a592912c43bf2ccd96325ff44a — Maciej-Mudita 2 years ago a9ebeb4
[MOS-340] Fix notifications of unread SMS threads on the home screen

Conversation marked in OPTIONS as read did not disappear
from notifications about SMS threads on the main screen.
M module-apps/application-messages/ApplicationMessages.cpp => module-apps/application-messages/ApplicationMessages.cpp +14 -5
@@ 1,4 1,4 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "ApplicationMessages.hpp"


@@ 165,19 165,28 @@ namespace app
    void ApplicationMessages::destroyUserInterface()
    {}

    bool ApplicationMessages::markSmsThreadAsRead(const uint32_t id)
    bool ApplicationMessages::markSmsThreadAsRead(const ThreadRecord *record)
    {
        using namespace db::query;
        LOG_DEBUG("markSmsThreadAsRead");
        if (record == nullptr) {
            LOG_ERROR("Trying to mark as read a null SMS thread!");
            return false;
        }
        DBServiceAPI::GetQuery(
            this, db::Interface::Name::SMSThread, std::make_unique<MarkAsRead>(id, MarkAsRead::Read::True));
            this, db::Interface::Name::SMSThread, std::make_unique<MarkAsRead>(record->ID, MarkAsRead::Read::True));

        if (record->unreadMsgCount) {
            DBServiceAPI::GetQuery(
                this,
                db::Interface::Name::Notifications,
                std::make_unique<notifications::Decrement>(NotificationsRecord::Key::Sms, record->unreadMsgCount));
        }
        return true;
    }

    bool ApplicationMessages::markSmsThreadAsUnread(const uint32_t id)
    {
        using namespace db::query;
        LOG_DEBUG("markSmsThreadAsUnRead");
        DBServiceAPI::GetQuery(
            this, db::Interface::Name::SMSThread, std::make_unique<MarkAsRead>(id, MarkAsRead::Read::False));
        return true;

M module-apps/application-messages/include/application-messages/ApplicationMessages.hpp => module-apps/application-messages/include/application-messages/ApplicationMessages.hpp +2 -2
@@ 1,4 1,4 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 42,7 42,7 @@ namespace app

        bool removeSms(const SMSRecord &record);
        bool removeSmsThread(const ThreadRecord *record);
        bool markSmsThreadAsRead(const uint32_t id);
        bool markSmsThreadAsRead(const ThreadRecord *record);
        bool markSmsThreadAsUnread(const uint32_t id);
        /// show dialog with big search icon and text which was used for query
        bool searchEmpty(const std::string &query = "");

M module-apps/application-messages/windows/SMSThreadViewWindow.cpp => module-apps/application-messages/windows/SMSThreadViewWindow.cpp +2 -11
@@ 1,4 1,4 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "ApplicationMessages.hpp"


@@ 72,21 72,12 @@ namespace gui
                auto app = dynamic_cast<app::ApplicationMessages *>(application);
                assert(app != nullptr);
                if (application->getCurrentWindow() == this) {
                    app->markSmsThreadAsRead(pdata->thread->ID);
                    app->markSmsThreadAsRead(pdata->thread.get());
                }
            }
            smsModel->numberID    = pdata->thread->numberID;
            smsModel->smsThreadID = pdata->thread->ID;
            smsList->rebuildList();

            if (pdata->thread->unreadMsgCount) {
                const auto countToClear = pdata->thread->unreadMsgCount;

                DBServiceAPI::GetQuery(
                    application,
                    db::Interface::Name::Notifications,
                    std::make_unique<db::query::notifications::Decrement>(NotificationsRecord::Key::Sms, countToClear));
            }
        }
        else if (smsModel->numberID != DB_ID_NONE) {
            requestContact(smsModel->numberID);

M module-apps/application-messages/windows/ThreadWindowOptions.cpp => module-apps/application-messages/windows/ThreadWindowOptions.cpp +2 -2
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "ThreadWindowOptions.hpp"


@@ 74,7 74,7 @@ namespace gui

        if (record->isUnread()) {
            options.emplace_back(gui::Option{utils::translate("sms_mark_read"), [=](gui::Item &item) {
                                                 app->markSmsThreadAsRead(record->ID);
                                                 app->markSmsThreadAsRead(record);
                                                 app->returnToPreviousWindow();
                                                 return true;
                                             }});

M pure_changelog.md => pure_changelog.md +1 -0
@@ 36,6 36,7 @@
* Fixed crash when trying to play 96kHz FLAC with USB cable connected
* Fixed the notification of unread messages are not deleted with the thread
* Fixed several MTP issues
* Fixed notifications of unread SMS threads on the home screen

### Added