M module-apps/application-messages/models/SMSTemplateModel.cpp => module-apps/application-messages/models/SMSTemplateModel.cpp +10 -12
@@ 10,11 10,7 @@
#include <service-db/DBServiceAPI.hpp>
SMSTemplateModel::SMSTemplateModel(app::ApplicationCommon *app) : DatabaseModel(app), app::AsyncCallbackReceiver{app}
-{
- /* In the base class DatabaseModel, this is initialised to maximal unsigned int value, but in fact should be 0.
- Not wanting to tinker with the whole database handling framework, let's correct this here in a smaller scale. */
- recordsCount = 0;
-}
+{}
unsigned int SMSTemplateModel::requestRecordsCount()
{
@@ 71,14 67,16 @@ auto SMSTemplateModel::handleQueryResponse(db::QueryResult *queryResult) -> bool
auto msgResponse = dynamic_cast<db::query::SMSTemplateGetForListResult *>(queryResult);
assert(msgResponse != nullptr);
- // If list record count has changed we need to rebuild list.
- if (recordsCount != (msgResponse->getCount())) {
- recordsCount = msgResponse->getCount();
- list->reSendLastRebuildRequest();
- return false;
+ if (recordsCount == msgResponse->getCount()) {
+ return this->updateRecords(msgResponse->getResults());
}
- auto records = msgResponse->getResults();
+ recordsCount = msgResponse->getCount();
+ if (list->isEmpty()) {
+ list->clear();
+ }
- return this->updateRecords(std::move(records));
+ // refreshWindow(...) does too few in this case
+ application->switchWindow(gui::name::window::sms_templates);
+ return false;
}
M module-apps/application-messages/windows/SMSTemplatesWindow.cpp => module-apps/application-messages/windows/SMSTemplatesWindow.cpp +6 -5
@@ 40,6 40,7 @@ namespace gui
setTitle(utils::translate("app_messages_templates"));
navBar->setText(nav_bar::Side::Center, utils::translate(style::strings::common::use));
+ navBar->setActive(nav_bar::Side::Center, false);
navBar->setText(nav_bar::Side::Right, utils::translate(style::strings::common::back));
namespace style = style::messages::templates::list;
@@ 103,11 104,11 @@ namespace gui
preventsAutoLock = false;
if (mode == ShowMode::GUI_SHOW_INIT) {
list->rebuildList();
- if (list->isEmpty()) {
- list->setVisible(false);
- navBar->setActive(nav_bar::Side::Center, false);
- emptyListIcon->setVisible(true);
- }
+ }
+
+ if (list->isEmpty()) {
+ navBar->setActive(nav_bar::Side::Center, false);
+ emptyListIcon->setVisible(true);
}
if (auto switchData = dynamic_cast<SMSTemplateRequest *>(data)) {