mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Use generic way for FAQ links.
This commit is contained in:
parent
ea178862d8
commit
23883ed4a1
8 changed files with 15 additions and 91 deletions
|
@ -508,8 +508,6 @@ PRIVATE
|
|||
data/data_drafts.h
|
||||
data/data_emoji_statuses.cpp
|
||||
data/data_emoji_statuses.h
|
||||
data/data_faq.cpp
|
||||
data/data_faq.h
|
||||
data/data_folder.cpp
|
||||
data/data_folder.h
|
||||
data/data_forum.cpp
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "data/data_faq.h"
|
||||
|
||||
#include "apiwrap.h"
|
||||
#include "core/application.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_web_page.h"
|
||||
#include "iv/iv_instance.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/session/session_show.h"
|
||||
#include "ui/basic_click_handlers.h"
|
||||
|
||||
namespace Data {
|
||||
|
||||
void Faq::open(std::shared_ptr<Main::SessionShow> show) {
|
||||
if (!_id) {
|
||||
show->session().api().request(MTPmessages_GetWebPage(
|
||||
MTP_string(tr::lng_settings_faq_link(tr::now)),
|
||||
MTP_int(0)
|
||||
)).done([=](const MTPmessages_WebPage &result) {
|
||||
show->session().data().processUsers(result.data().vusers());
|
||||
show->session().data().processChats(result.data().vchats());
|
||||
const auto page = show->session().data().processWebpage(
|
||||
result.data().vwebpage());
|
||||
if (page && page->iv) {
|
||||
_id = page->id;
|
||||
open(show);
|
||||
} else {
|
||||
UrlClickHandler::Open(tr::lng_settings_faq_link(tr::now));
|
||||
}
|
||||
}).fail([=] {
|
||||
UrlClickHandler::Open(tr::lng_settings_faq_link(tr::now));
|
||||
}).send();
|
||||
} else {
|
||||
const auto page = show->session().data().webpage(_id);
|
||||
if (page && page->iv) {
|
||||
const auto parts = tr::lng_settings_faq_link(tr::now).split('#');
|
||||
const auto hash = (parts.size() > 1) ? parts[1] : u""_q;
|
||||
Core::App().iv().show(show, page->iv.get(), hash);
|
||||
} else {
|
||||
UrlClickHandler::Open(tr::lng_settings_faq_link(tr::now));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Data
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace Main {
|
||||
class SessionShow;
|
||||
} // namespace Main
|
||||
|
||||
namespace Data {
|
||||
|
||||
class Faq final {
|
||||
public:
|
||||
constexpr Faq() = default;
|
||||
|
||||
void open(std::shared_ptr<Main::SessionShow> show);
|
||||
|
||||
private:
|
||||
WebPageId _id = 0;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Data
|
|
@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "storage/storage_databases.h"
|
||||
#include "dialogs/dialogs_main_list.h"
|
||||
#include "data/data_groups.h"
|
||||
#include "data/data_faq.h"
|
||||
#include "data/data_cloud_file.h"
|
||||
#include "history/history_location_manager.h"
|
||||
#include "base/timer.h"
|
||||
|
@ -102,9 +101,6 @@ public:
|
|||
[[nodiscard]] const Groups &groups() const {
|
||||
return _groups;
|
||||
}
|
||||
[[nodiscard]] Faq &faq() {
|
||||
return _faq;
|
||||
}
|
||||
[[nodiscard]] ChatFilters &chatsFilters() const {
|
||||
return *_chatsFilters;
|
||||
}
|
||||
|
@ -1072,7 +1068,6 @@ private:
|
|||
mtpRequestId> _viewAsMessagesRequests;
|
||||
|
||||
Groups _groups;
|
||||
Faq _faq;
|
||||
const std::unique_ptr<ChatFilters> _chatsFilters;
|
||||
const std::unique_ptr<CloudThemes> _cloudThemes;
|
||||
const std::unique_ptr<SendActionManager> _sendActionManager;
|
||||
|
|
|
@ -110,7 +110,7 @@ object_ptr<Ui::RpWidget> CreateIntroSettings(
|
|||
tr::lng_settings_faq(),
|
||||
st::settingsButtonNoIcon
|
||||
)->addClickHandler([] {
|
||||
UrlClickHandler::Open(tr::lng_telegram_features_url(tr::now));
|
||||
OpenFaq(nullptr);
|
||||
});
|
||||
|
||||
return result;
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "settings/settings_main.h"
|
||||
|
||||
#include "core/application.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "settings/settings_business.h"
|
||||
#include "settings/settings_codes.h"
|
||||
#include "settings/settings_chat.h"
|
||||
|
@ -613,7 +614,7 @@ void SetupHelp(
|
|||
st::settingsButton,
|
||||
{ &st::menuIconFaq }
|
||||
)->addClickHandler([=] {
|
||||
controller->session().data().faq().open(controller->uiShow());
|
||||
OpenFaq(controller);
|
||||
});
|
||||
|
||||
AddButtonWithIcon(
|
||||
|
@ -659,7 +660,7 @@ void SetupHelp(
|
|||
.text = tr::lng_settings_ask_sure(),
|
||||
.confirmed = sure,
|
||||
.cancelled = [=](Fn<void()> close) {
|
||||
controller->session().data().faq().open(controller->uiShow());
|
||||
OpenFaq(controller);
|
||||
close();
|
||||
},
|
||||
.confirmText = tr::lng_settings_ask_ok(),
|
||||
|
@ -740,4 +741,12 @@ void Main::setupContent(not_null<Window::SessionController*> controller) {
|
|||
controller->session().data().cloudThemes().refresh();
|
||||
}
|
||||
|
||||
void OpenFaq(base::weak_ptr<Window::SessionController> weak) {
|
||||
UrlClickHandler::Open(
|
||||
tr::lng_settings_faq_link(tr::now),
|
||||
QVariant::fromValue(ClickHandlerContext{
|
||||
.sessionWindow = weak,
|
||||
}));
|
||||
}
|
||||
|
||||
} // namespace Settings
|
||||
|
|
|
@ -29,6 +29,8 @@ void SetupInterfaceScale(
|
|||
not_null<Ui::VerticalLayout*> container,
|
||||
bool icon = true);
|
||||
|
||||
void OpenFaq(base::weak_ptr<Window::SessionController> weak);
|
||||
|
||||
class Main : public Section<Main> {
|
||||
public:
|
||||
Main(QWidget *parent, not_null<Window::SessionController*> controller);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 8d4b2efa0024016c6a6f6b4d8f1dfc3d62bafddc
|
||||
Subproject commit beef65fac578a812dade36557f4c666ac3d3ba78
|
Loading…
Add table
Reference in a new issue