Register tg:// scheme on first launch.

Also, allow disabling tg:// re-registration on update.
This commit is contained in:
John Preston 2024-07-02 13:34:52 +04:00
parent 8cbeadc68a
commit 17bb430006
3 changed files with 21 additions and 2 deletions

View file

@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/battery_saving.h"
#include "base/event_filter.h"
#include "base/concurrent_timer.h"
#include "base/options.h"
#include "base/qt_signal_producer.h"
#include "base/timer.h"
#include "base/unixtime.h"
@ -140,10 +141,18 @@ void SetCrashAnnotationsGL() {
#endif // DESKTOP_APP_USE_ANGLE
}
base::options::toggle OptionSkipUrlSchemeRegister({
.id = kOptionSkipUrlSchemeRegister,
.name = "Skip URL scheme register",
.description = "Don't re-register tg:// URL scheme on autoupdate.",
});
} // namespace
Application *Application::Instance = nullptr;
const char kOptionSkipUrlSchemeRegister[] = "skip-url-scheme-register";
struct Application::Private {
base::Timer quitTimer;
UiIntegration uiIntegration;
@ -263,12 +272,12 @@ void Application::run() {
if (const auto old = Local::oldSettingsVersion()) {
if (old < AppVersion) {
InvokeQueued(this, [] { RegisterUrlScheme(); });
autoRegisterUrlScheme();
Platform::NewVersionLaunched(old);
}
} else {
// Initial launch.
InvokeQueued(this, [] { RegisterUrlScheme(); });
autoRegisterUrlScheme();
}
if (cAutoStart() && !Platform::AutostartSupported()) {
@ -410,6 +419,12 @@ void Application::run() {
processCreatedWindow(_lastActivePrimaryWindow);
}
void Application::autoRegisterUrlScheme() {
if (!OptionSkipUrlSchemeRegister.value()) {
InvokeQueued(this, [] { RegisterUrlScheme(); });
}
}
void Application::showAccount(not_null<Main::Account*> account) {
if (const auto separate = separateWindowFor(account)) {
_lastActivePrimaryWindow = separate;

View file

@ -126,6 +126,8 @@ enum class QuitReason {
QtQuitEvent,
};
extern const char kOptionSkipUrlSchemeRegister[];
class Application final : public QObject {
public:
struct ProxyChange {
@ -349,6 +351,7 @@ private:
friend bool IsAppLaunched();
friend Application &App();
void autoRegisterUrlScheme();
void clearEmojiSourceImages();
[[nodiscard]] auto prepareEmojiSourceImages()
-> std::shared_ptr<Ui::Emoji::UniversalImages>;

View file

@ -152,6 +152,7 @@ void SetupExperimental(
addToggle(kOptionAutoScrollInactiveChat);
addToggle(Window::Notifications::kOptionGNotification);
addToggle(Core::kOptionFreeType);
addToggle(Core::kOptionSkipUrlSchemeRegister);
addToggle(Data::kOptionExternalVideoPlayer);
addToggle(Window::kOptionNewWindowsSizeAsFirst);
}