From 9bc622888f6436d502513c4425dec246772b1531 Mon Sep 17 00:00:00 2001 From: Lukasz Mastalerz Date: Thu, 11 May 2023 14:54:25 +0200 Subject: [PATCH] [CP-1974] Deleting all templates leaves some text on pure screen Additional fix, previous one was not working correctly in all scenarios. --- .../models/SMSTemplateModel.cpp | 8 +++--- .../windows/SMSTemplatesWindow.cpp | 26 ++++++++++++------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/module-apps/application-messages/models/SMSTemplateModel.cpp b/module-apps/application-messages/models/SMSTemplateModel.cpp index 4ad7926535beeb883c2c3fdae93c985c5fe3d5d0..421e7664dc2cfa3ae0b34b21d71392a201761580 100644 --- a/module-apps/application-messages/models/SMSTemplateModel.cpp +++ b/module-apps/application-messages/models/SMSTemplateModel.cpp @@ -20,11 +20,9 @@ unsigned int SMSTemplateModel::requestRecordsCount() bool SMSTemplateModel::updateRecords(std::vector records) { - if (DatabaseModel::updateRecords(std::move(records))) { - list->onProviderDataUpdate(); - return true; - } - return false; + DatabaseModel::updateRecords(std::move(records)); + list->onProviderDataUpdate(); + return true; } unsigned int SMSTemplateModel::getMinimalItemSpaceRequired() const diff --git a/module-apps/application-messages/windows/SMSTemplatesWindow.cpp b/module-apps/application-messages/windows/SMSTemplatesWindow.cpp index 319e5538822215170479001d00f8b1a06cac58fa..a3f765a877e53ee687369982a7dda9aa6ef66be7 100644 --- a/module-apps/application-messages/windows/SMSTemplatesWindow.cpp +++ b/module-apps/application-messages/windows/SMSTemplatesWindow.cpp @@ -44,6 +44,7 @@ namespace gui navBar->setText(nav_bar::Side::Center, utils::translate(style::strings::common::use)); navBar->setText(nav_bar::Side::Right, utils::translate(style::strings::common::back)); + navBar->setActive(nav_bar::Side::Right, true); namespace style = style::messages::templates::list; @@ -61,6 +62,19 @@ namespace gui utils::translate("app_messages_no_templates")); emptyListIcon->setVisible(false); + list->setVisible(true); + + list->emptyListCallback = [this]() { + emptyListIcon->setVisible(true); + navBar->setActive(nav_bar::Side::Center, false); + application->refreshWindow(gui::RefreshModes::GUI_REFRESH_DEEP); + }; + + list->notEmptyListCallback = [this]() { + emptyListIcon->setVisible(false); + navBar->setActive(nav_bar::Side::Center, true); + application->refreshWindow(gui::RefreshModes::GUI_REFRESH_DEEP); + }; setFocusItem(list); } @@ -104,16 +118,6 @@ namespace gui void SMSTemplatesWindow::onBeforeShow(ShowMode mode, SwitchData *data) { preventsAutoLock = false; - if (mode == ShowMode::GUI_SHOW_INIT) { - list->rebuildList(); - } - - if (list->isEmpty()) { - list->clear(); - } - - navBar->setActive(nav_bar::Side::Center, !list->isEmpty()); - emptyListIcon->setVisible(list->isEmpty()); if (auto switchData = dynamic_cast(data)) { smsTemplateRequestHandler(switchData); @@ -123,6 +127,8 @@ namespace gui saveInfoAboutPreviousAppForProperSwitchBack(data); smsSendTemplateRequestHandler(switchData); } + + list->rebuildList(listview::RebuildType::InPlace); } bool SMSTemplatesWindow::onInput(const InputEvent &inputEvent)