From e1a8c89ff186c7d6ea8221614eee57e1f8f545e6 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 3 Oct 2016 11:20:02 +0300 Subject: [PATCH] Version 0.10.9: don't handle cStartUrl() while passcoded. --- Telegram/SourceFiles/application.cpp | 5 ++--- Telegram/SourceFiles/mainwidget.cpp | 16 ++++++++++++---- Telegram/SourceFiles/mainwidget.h | 1 + Telegram/SourceFiles/mainwindow.cpp | 9 ++++++--- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index 9a21f66af..7ca8ba389 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -303,9 +303,8 @@ void Application::readClients() { if (!startUrl.isEmpty()) { cSetStartUrl(startUrl); } - if (!cStartUrl().isEmpty() && App::main() && App::self()) { - App::main()->openLocalUrl(cStartUrl()); - cSetStartUrl(QString()); + if (auto main = App::main()) { + main->checkStartUrl(); } } diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 37ac2441b..a84d6bec3 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -3301,10 +3301,7 @@ void MainWidget::start(const MTPUser &user) { App::feedUsers(MTP_vector(1, user)); MTP::send(MTPupdates_GetState(), rpcDone(&MainWidget::gotState)); update(); - if (!cStartUrl().isEmpty()) { - openLocalUrl(cStartUrl()); - cSetStartUrl(QString()); - } + _started = true; App::wnd()->sendServiceHistoryRequest(); Local::readInstalledStickers(); @@ -3312,12 +3309,23 @@ void MainWidget::start(const MTPUser &user) { Local::readRecentStickers(); Local::readSavedGifs(); _history->start(); + + checkStartUrl(); } bool MainWidget::started() { return _started; } +void MainWidget::checkStartUrl() { + if (!cStartUrl().isEmpty() && App::self() && !App::passcoded()) { + auto url = cStartUrl(); + cSetStartUrl(QString()); + + openLocalUrl(url); + } +} + void MainWidget::openLocalUrl(const QString &url) { auto urlTrimmed = url.trimmed(); if (urlTrimmed.size() > 8192) urlTrimmed = urlTrimmed.mid(0, 8192); diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 84fb26380..a6d3547ee 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -155,6 +155,7 @@ public: void start(const MTPUser &user); + void checkStartUrl(); void openLocalUrl(const QString &str); void openPeerByName(const QString &name, MsgId msgId = ShowAtUnreadMsgId, const QString &startToken = QString()); void joinGroupByHash(const QString &hash); diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 43c59329e..fb2c6e1fa 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -550,6 +550,10 @@ void MainWindow::clearPasscode() { notifyUpdateAll(); title->updateBackButton(); updateGlobalMenu(); + + if (auto main = App::main()) { + main->checkStartUrl(); + } } void MainWindow::setupPasscode(bool anim) { @@ -1040,9 +1044,8 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *e) { QString url = static_cast(e)->url().toEncoded().trimmed(); if (url.startsWith(qstr("tg://"), Qt::CaseInsensitive)) { cSetStartUrl(url.mid(0, 8192)); - if (!cStartUrl().isEmpty() && App::main() && App::self()) { - App::main()->openLocalUrl(cStartUrl()); - cSetStartUrl(QString()); + if (auto main = App::main()) { + main->checkStartUrl(); } } activate();