2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Use generic way for FAQ links.

This commit is contained in:
John Preston
2024-04-04 21:08:56 +04:00
parent ea178862d8
commit 23883ed4a1
8 changed files with 15 additions and 91 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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;