refactor!: Rewrite of the old notification service (#2866)

The main goal was improving the readability of the original code however some ugliness remains.

- Swapped from pointer singleton to instance singleton
- Actually make use of the alpha logic that used to be present
- Added a counter to notifications to indicate if something is being spammed
- Notification timeouts reset if they're sent to the queue again
This commit is contained in:
Andreas Maerten
2024-03-23 00:04:49 +01:00
committed by GitHub
parent 313bfa24b3
commit cba19d0c33
99 changed files with 459 additions and 359 deletions

View File

@ -42,11 +42,11 @@ namespace big
try
{
const auto j = nlohmann::json::parse(response.text);
g_notification_service->push_success("PROXY_SETTINGS"_T.data(), "PROXY_SETTINGS_TEST_CURRENT_SUCCESS"_T.data());
g_notification_service.push_success("PROXY_SETTINGS"_T.data(), "PROXY_SETTINGS_TEST_CURRENT_SUCCESS"_T.data());
}
catch (const std::exception& e)
{
g_notification_service->push_error("PROXY_SETTINGS"_T.data(), "PROXY_SETTINGS_TEST_CURRENT_FAIL"_T.data());
g_notification_service.push_error("PROXY_SETTINGS"_T.data(), "PROXY_SETTINGS_TEST_CURRENT_FAIL"_T.data());
}
});
}
@ -66,7 +66,7 @@ namespace big
else
g_http_client.proxy_mgr().update(settings.proxy_host, settings.proxy_port, settings.protocol);
g_notification_service->push("PROXY_SETTINGS"_T.data(), "PROXY_SETTINGS_UPDATE_SUCCESS"_T.data());
g_notification_service.push("PROXY_SETTINGS"_T.data(), "PROXY_SETTINGS_UPDATE_SUCCESS"_T.data());
}
}
}
}

View File

@ -54,7 +54,7 @@ namespace big
g_thread_pool->push([] {
g_translation_service.update_n_reload_language_packs();
g_notification_service->push_success("LANGUAGE"_T.data(), "VIEW_SETTINGS_FINISHED_UPDATING_TRANSLATIONS"_T.data());
g_notification_service.push_success("LANGUAGE"_T.data(), "VIEW_SETTINGS_FINISHED_UPDATING_TRANSLATIONS"_T.data());
});
}
@ -67,4 +67,4 @@ namespace big
g.load();
}
}
}
}