2017-03-27 12:24:38 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-03-27 12:24:38 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-03-27 12:24:38 +00:00
|
|
|
*/
|
2019-06-06 10:21:40 +00:00
|
|
|
#include "window/window_session_controller.h"
|
2017-03-27 12:24:38 +00:00
|
|
|
|
2021-02-03 01:17:03 +00:00
|
|
|
#include "boxes/add_contact_box.h"
|
2022-03-23 14:22:09 +00:00
|
|
|
#include "boxes/peers/add_bot_to_chat_box.h"
|
2019-03-17 08:14:31 +00:00
|
|
|
#include "boxes/peers/edit_peer_info_box.h"
|
2020-09-22 15:05:07 +00:00
|
|
|
#include "boxes/peer_list_controllers.h"
|
2021-11-16 07:26:35 +00:00
|
|
|
#include "boxes/delete_messages_box.h"
|
2021-05-26 23:20:27 +00:00
|
|
|
#include "window/window_adaptive.h"
|
2019-09-03 15:24:51 +00:00
|
|
|
#include "window/window_controller.h"
|
2017-04-07 18:10:49 +00:00
|
|
|
#include "window/main_window.h"
|
2020-03-03 12:07:22 +00:00
|
|
|
#include "window/window_filters_menu.h"
|
2017-09-16 16:53:41 +00:00
|
|
|
#include "info/info_memento.h"
|
2018-09-05 19:05:49 +00:00
|
|
|
#include "info/info_controller.h"
|
2022-03-29 09:00:10 +00:00
|
|
|
#include "inline_bots/bot_attach_web_view.h"
|
2018-01-13 12:45:11 +00:00
|
|
|
#include "history/history.h"
|
2018-01-11 19:33:26 +00:00
|
|
|
#include "history/history_item.h"
|
2022-08-19 08:27:02 +00:00
|
|
|
#include "history/view/reactions/history_view_reactions.h"
|
|
|
|
#include "history/view/reactions/history_view_reactions_button.h"
|
2020-09-03 08:21:31 +00:00
|
|
|
#include "history/view/history_view_replies_section.h"
|
2022-01-26 09:41:27 +00:00
|
|
|
#include "history/view/history_view_scheduled_section.h"
|
2020-06-25 14:17:37 +00:00
|
|
|
#include "media/player/media_player_instance.h"
|
2021-06-14 06:33:54 +00:00
|
|
|
#include "media/view/media_view_open_common.h"
|
2021-06-14 06:21:56 +00:00
|
|
|
#include "data/data_document_resolver.h"
|
2019-03-26 08:54:51 +00:00
|
|
|
#include "data/data_media_types.h"
|
2018-01-21 14:49:42 +00:00
|
|
|
#include "data/data_session.h"
|
2019-04-15 11:54:03 +00:00
|
|
|
#include "data/data_folder.h"
|
2019-01-04 11:09:48 +00:00
|
|
|
#include "data/data_channel.h"
|
|
|
|
#include "data/data_chat.h"
|
2020-09-22 15:05:07 +00:00
|
|
|
#include "data/data_user.h"
|
2021-08-27 11:32:18 +00:00
|
|
|
#include "data/data_document.h"
|
|
|
|
#include "data/data_document_media.h"
|
|
|
|
#include "data/data_document_resolver.h"
|
2020-09-22 15:05:07 +00:00
|
|
|
#include "data/data_changes.h"
|
2021-03-16 13:16:01 +00:00
|
|
|
#include "data/data_group_call.h"
|
2022-10-04 15:34:45 +00:00
|
|
|
#include "data/data_forum.h"
|
|
|
|
#include "data/data_forum_topic.h"
|
2020-03-18 09:19:58 +00:00
|
|
|
#include "data/data_chat_filters.h"
|
2022-10-20 09:33:04 +00:00
|
|
|
#include "data/data_replies_list.h"
|
2022-06-07 08:41:10 +00:00
|
|
|
#include "data/data_peer_values.h"
|
2018-03-18 08:51:14 +00:00
|
|
|
#include "passport/passport_form_controller.h"
|
2019-08-16 12:44:20 +00:00
|
|
|
#include "chat_helpers/tabbed_selector.h"
|
2021-09-14 20:42:34 +00:00
|
|
|
#include "chat_helpers/emoji_interactions.h"
|
2018-12-30 12:50:23 +00:00
|
|
|
#include "core/shortcuts.h"
|
2020-06-25 12:16:09 +00:00
|
|
|
#include "core/application.h"
|
|
|
|
#include "core/core_settings.h"
|
2021-02-25 15:12:51 +00:00
|
|
|
#include "core/click_handler_types.h"
|
2019-07-10 17:28:33 +00:00
|
|
|
#include "base/unixtime.h"
|
2022-03-28 14:02:54 +00:00
|
|
|
#include "base/random.h"
|
2020-07-06 14:08:28 +00:00
|
|
|
#include "ui/layers/generic_box.h"
|
|
|
|
#include "ui/text/text_utilities.h"
|
2022-03-01 11:44:29 +00:00
|
|
|
#include "ui/text/format_values.h" // Ui::FormatPhone.
|
2020-07-06 14:08:28 +00:00
|
|
|
#include "ui/delayed_activation.h"
|
2022-03-25 14:13:30 +00:00
|
|
|
#include "ui/chat/attach/attach_bot_webview.h"
|
2021-08-19 14:22:12 +00:00
|
|
|
#include "ui/chat/message_bubble.h"
|
2021-08-27 20:44:47 +00:00
|
|
|
#include "ui/chat/chat_style.h"
|
2021-08-26 15:02:21 +00:00
|
|
|
#include "ui/chat/chat_theme.h"
|
2022-02-08 19:19:01 +00:00
|
|
|
#include "ui/effects/message_sending_animation_controller.h"
|
2021-09-02 16:58:04 +00:00
|
|
|
#include "ui/style/style_palette_colorizer.h"
|
2020-10-01 13:42:31 +00:00
|
|
|
#include "ui/toast/toast.h"
|
2020-12-08 15:09:13 +00:00
|
|
|
#include "ui/toasts/common_toasts.h"
|
|
|
|
#include "calls/calls_instance.h" // Core::App().calls().inCall().
|
2021-04-22 16:05:17 +00:00
|
|
|
#include "calls/group/calls_group_call.h"
|
2021-01-19 07:14:50 +00:00
|
|
|
#include "ui/boxes/calendar_box.h"
|
2021-10-18 21:36:55 +00:00
|
|
|
#include "ui/boxes/confirm_box.h"
|
2017-04-09 18:06:06 +00:00
|
|
|
#include "mainwidget.h"
|
2017-09-15 17:34:41 +00:00
|
|
|
#include "mainwindow.h"
|
2023-01-17 15:47:58 +00:00
|
|
|
#include "main/main_account.h"
|
|
|
|
#include "main/main_domain.h"
|
2019-07-24 11:45:24 +00:00
|
|
|
#include "main/main_session.h"
|
2020-06-18 12:47:09 +00:00
|
|
|
#include "main/main_session_settings.h"
|
2017-08-01 11:43:50 +00:00
|
|
|
#include "apiwrap.h"
|
2020-07-01 14:19:25 +00:00
|
|
|
#include "api/api_chat_invite.h"
|
2020-07-06 14:08:28 +00:00
|
|
|
#include "api/api_global_privacy.h"
|
2022-07-17 23:58:24 +00:00
|
|
|
#include "api/api_blocked_peers.h"
|
2018-11-15 15:36:04 +00:00
|
|
|
#include "support/support_helper.h"
|
2021-06-18 06:39:10 +00:00
|
|
|
#include "storage/file_upload.h"
|
2021-08-13 15:39:50 +00:00
|
|
|
#include "window/themes/window_theme.h"
|
2022-11-01 09:00:17 +00:00
|
|
|
#include "window/window_peer_menu.h"
|
2022-04-01 11:53:23 +00:00
|
|
|
#include "settings/settings_main.h"
|
|
|
|
#include "settings/settings_privacy_security.h"
|
2018-01-21 14:49:42 +00:00
|
|
|
#include "styles/style_window.h"
|
|
|
|
#include "styles/style_dialogs.h"
|
2020-07-06 14:08:28 +00:00
|
|
|
#include "styles/style_layers.h" // st::boxLabel
|
2017-04-07 18:10:49 +00:00
|
|
|
|
|
|
|
namespace Window {
|
2018-12-30 12:50:23 +00:00
|
|
|
namespace {
|
|
|
|
|
2021-09-19 15:15:46 +00:00
|
|
|
constexpr auto kCustomThemesInMemory = 5;
|
2018-12-30 12:50:23 +00:00
|
|
|
constexpr auto kMaxChatEntryHistorySize = 50;
|
2021-09-19 09:43:12 +00:00
|
|
|
constexpr auto kDayBaseFile = ":/gui/day-custom-base.tdesktop-theme"_cs;
|
2021-09-19 08:40:15 +00:00
|
|
|
constexpr auto kNightBaseFile = ":/gui/night-custom-base.tdesktop-theme"_cs;
|
2021-08-16 13:07:43 +00:00
|
|
|
|
2021-08-27 11:32:18 +00:00
|
|
|
[[nodiscard]] Fn<void(style::palette&)> PreparePaletteCallback(
|
2022-03-25 14:13:30 +00:00
|
|
|
bool dark,
|
|
|
|
std::optional<QColor> accent) {
|
2021-08-27 11:32:18 +00:00
|
|
|
return [=](style::palette &palette) {
|
|
|
|
using namespace Theme;
|
2021-09-02 17:48:12 +00:00
|
|
|
const auto &embedded = EmbeddedThemes();
|
|
|
|
const auto i = ranges::find(
|
|
|
|
embedded,
|
|
|
|
dark ? EmbeddedType::Night : EmbeddedType::Default,
|
|
|
|
&EmbeddedScheme::type);
|
|
|
|
Assert(i != end(embedded));
|
|
|
|
const auto colorizer = accent
|
|
|
|
? ColorizerFrom(*i, *accent)
|
|
|
|
: style::colorizer();
|
2021-08-27 11:32:18 +00:00
|
|
|
|
2021-09-19 09:43:12 +00:00
|
|
|
auto instance = Instance();
|
|
|
|
const auto loaded = LoadFromFile(
|
|
|
|
(dark ? kNightBaseFile : kDayBaseFile).utf16(),
|
|
|
|
&instance,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
colorizer);
|
|
|
|
Assert(loaded);
|
|
|
|
palette.finalize();
|
|
|
|
palette = instance.palette;
|
2021-08-27 11:32:18 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-09-06 10:18:14 +00:00
|
|
|
[[nodiscard]] Ui::ChatThemeBubblesData PrepareBubblesData(
|
2022-03-25 14:13:30 +00:00
|
|
|
const Data::CloudTheme &theme,
|
|
|
|
Data::CloudThemeType type) {
|
2021-10-22 18:14:44 +00:00
|
|
|
const auto i = theme.settings.find(type);
|
2021-09-06 10:18:14 +00:00
|
|
|
return {
|
2021-10-22 18:14:44 +00:00
|
|
|
.colors = (i != end(theme.settings)
|
|
|
|
? i->second.outgoingMessagesColors
|
|
|
|
: std::vector<QColor>()),
|
|
|
|
.accent = (i != end(theme.settings)
|
|
|
|
? i->second.outgoingAccentColor
|
|
|
|
: std::optional<QColor>()),
|
2021-09-06 10:18:14 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-12-30 12:50:23 +00:00
|
|
|
} // namespace
|
2017-04-07 18:10:49 +00:00
|
|
|
|
2020-06-13 12:49:21 +00:00
|
|
|
void ActivateWindow(not_null<SessionController*> controller) {
|
|
|
|
const auto window = controller->widget();
|
2021-06-07 07:25:19 +00:00
|
|
|
window->raise();
|
2020-06-13 12:49:21 +00:00
|
|
|
window->activateWindow();
|
|
|
|
Ui::ActivateWindowDelayed(window);
|
|
|
|
}
|
|
|
|
|
2022-08-20 04:45:44 +00:00
|
|
|
bool IsPaused(
|
|
|
|
not_null<SessionController*> controller,
|
|
|
|
GifPauseReason level) {
|
|
|
|
return controller->isGifPausedAtLeastFor(level);
|
|
|
|
}
|
|
|
|
|
|
|
|
Fn<bool()> PausedIn(
|
|
|
|
not_null<SessionController*> controller,
|
|
|
|
GifPauseReason level) {
|
|
|
|
return [=] { return IsPaused(controller, level); };
|
|
|
|
}
|
|
|
|
|
2021-09-24 15:10:25 +00:00
|
|
|
bool operator==(const PeerThemeOverride &a, const PeerThemeOverride &b) {
|
|
|
|
return (a.peer == b.peer) && (a.theme == b.theme);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const PeerThemeOverride &a, const PeerThemeOverride &b) {
|
|
|
|
return !(a == b);
|
|
|
|
}
|
|
|
|
|
2018-02-21 21:17:36 +00:00
|
|
|
DateClickHandler::DateClickHandler(Dialogs::Key chat, QDate date)
|
2022-10-27 07:52:18 +00:00
|
|
|
: _chat(chat)
|
|
|
|
, _weak(chat.topic())
|
|
|
|
, _date(date) {
|
2018-02-21 21:17:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DateClickHandler::setDate(QDate date) {
|
|
|
|
_date = date;
|
|
|
|
}
|
|
|
|
|
2018-07-09 18:13:48 +00:00
|
|
|
void DateClickHandler::onClick(ClickContext context) const {
|
2021-02-25 15:12:51 +00:00
|
|
|
const auto my = context.other.value<ClickHandlerContext>();
|
|
|
|
if (const auto window = my.sessionWindow.get()) {
|
2022-10-27 07:52:18 +00:00
|
|
|
if (!_chat.topic()) {
|
|
|
|
window->showCalendar(_chat, _date);
|
|
|
|
} else if (const auto strong = _weak.get()) {
|
|
|
|
window->showCalendar(strong, _date);
|
|
|
|
}
|
2021-02-25 15:12:51 +00:00
|
|
|
}
|
2018-02-21 21:17:36 +00:00
|
|
|
}
|
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
SessionNavigation::SessionNavigation(not_null<Main::Session*> session)
|
2022-03-25 14:13:30 +00:00
|
|
|
: _session(session)
|
|
|
|
, _api(&_session->mtp()) {
|
2019-01-18 12:27:37 +00:00
|
|
|
}
|
|
|
|
|
2022-03-25 14:13:30 +00:00
|
|
|
SessionNavigation::~SessionNavigation() = default;
|
2020-09-03 08:21:31 +00:00
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
Main::Session &SessionNavigation::session() const {
|
2019-01-18 12:27:37 +00:00
|
|
|
return *_session;
|
|
|
|
}
|
|
|
|
|
2020-09-22 15:05:07 +00:00
|
|
|
void SessionNavigation::showPeerByLink(const PeerByLinkInfo &info) {
|
|
|
|
Core::App().hideMediaView();
|
2022-03-01 11:44:29 +00:00
|
|
|
if (!info.phone.isEmpty()) {
|
|
|
|
resolvePhone(info.phone, [=](not_null<PeerData*> peer) {
|
|
|
|
showPeerByLinkResolved(peer, info);
|
|
|
|
});
|
|
|
|
} else if (const auto name = std::get_if<QString>(&info.usernameOrId)) {
|
|
|
|
resolveUsername(*name, [=](not_null<PeerData*> peer) {
|
2022-07-17 23:58:24 +00:00
|
|
|
if (info.startAutoSubmit) {
|
|
|
|
peer->session().api().blockedPeers().unblock(
|
|
|
|
peer,
|
|
|
|
[=] { showPeerByLinkResolved(peer, info); },
|
|
|
|
true);
|
|
|
|
} else {
|
|
|
|
showPeerByLinkResolved(peer, info);
|
|
|
|
}
|
2020-09-22 15:05:07 +00:00
|
|
|
});
|
|
|
|
} else if (const auto id = std::get_if<ChannelId>(&info.usernameOrId)) {
|
|
|
|
resolveChannelById(*id, [=](not_null<ChannelData*> channel) {
|
|
|
|
showPeerByLinkResolved(channel, info);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-01 11:44:29 +00:00
|
|
|
void SessionNavigation::resolvePhone(
|
2022-03-29 09:00:10 +00:00
|
|
|
const QString &phone,
|
|
|
|
Fn<void(not_null<PeerData*>)> done) {
|
2022-03-01 11:44:29 +00:00
|
|
|
if (const auto peer = _session->data().userByPhone(phone)) {
|
|
|
|
done(peer);
|
|
|
|
return;
|
|
|
|
}
|
2022-03-25 14:13:30 +00:00
|
|
|
_api.request(base::take(_resolveRequestId)).cancel();
|
|
|
|
_resolveRequestId = _api.request(MTPcontacts_ResolvePhone(
|
2022-03-01 11:44:29 +00:00
|
|
|
MTP_string(phone)
|
|
|
|
)).done([=](const MTPcontacts_ResolvedPeer &result) {
|
|
|
|
resolveDone(result, done);
|
|
|
|
}).fail([=](const MTP::Error &error) {
|
|
|
|
_resolveRequestId = 0;
|
|
|
|
if (error.code() == 400) {
|
2022-06-09 01:16:19 +00:00
|
|
|
parentController()->show(
|
|
|
|
Ui::MakeInformBox(tr::lng_username_by_phone_not_found(
|
|
|
|
tr::now,
|
|
|
|
lt_phone,
|
|
|
|
Ui::FormatPhone(phone))),
|
|
|
|
Ui::LayerOption::CloseOther);
|
2022-03-01 11:44:29 +00:00
|
|
|
}
|
|
|
|
}).send();
|
|
|
|
}
|
|
|
|
|
2020-09-22 15:05:07 +00:00
|
|
|
void SessionNavigation::resolveUsername(
|
2022-03-29 09:00:10 +00:00
|
|
|
const QString &username,
|
|
|
|
Fn<void(not_null<PeerData*>)> done) {
|
2020-09-22 15:05:07 +00:00
|
|
|
if (const auto peer = _session->data().peerByUsername(username)) {
|
|
|
|
done(peer);
|
|
|
|
return;
|
|
|
|
}
|
2022-03-25 14:13:30 +00:00
|
|
|
_api.request(base::take(_resolveRequestId)).cancel();
|
|
|
|
_resolveRequestId = _api.request(MTPcontacts_ResolveUsername(
|
2020-09-22 15:05:07 +00:00
|
|
|
MTP_string(username)
|
|
|
|
)).done([=](const MTPcontacts_ResolvedPeer &result) {
|
2022-03-01 11:44:29 +00:00
|
|
|
resolveDone(result, done);
|
2021-03-12 12:48:00 +00:00
|
|
|
}).fail([=](const MTP::Error &error) {
|
2020-09-22 15:05:07 +00:00
|
|
|
_resolveRequestId = 0;
|
|
|
|
if (error.code() == 400) {
|
2022-06-09 01:16:19 +00:00
|
|
|
parentController()->show(
|
|
|
|
Ui::MakeInformBox(
|
|
|
|
tr::lng_username_not_found(tr::now, lt_user, username)),
|
|
|
|
Ui::LayerOption::CloseOther);
|
2020-09-22 15:05:07 +00:00
|
|
|
}
|
|
|
|
}).send();
|
|
|
|
}
|
|
|
|
|
2022-03-01 11:44:29 +00:00
|
|
|
void SessionNavigation::resolveDone(
|
2022-03-29 09:00:10 +00:00
|
|
|
const MTPcontacts_ResolvedPeer &result,
|
|
|
|
Fn<void(not_null<PeerData*>)> done) {
|
2022-03-01 11:44:29 +00:00
|
|
|
_resolveRequestId = 0;
|
2022-06-07 18:05:37 +00:00
|
|
|
parentController()->hideLayer();
|
2022-03-01 11:44:29 +00:00
|
|
|
result.match([&](const MTPDcontacts_resolvedPeer &data) {
|
|
|
|
_session->data().processUsers(data.vusers());
|
|
|
|
_session->data().processChats(data.vchats());
|
|
|
|
if (const auto peerId = peerFromMTP(data.vpeer())) {
|
|
|
|
done(_session->data().peer(peerId));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-09-22 15:05:07 +00:00
|
|
|
void SessionNavigation::resolveChannelById(
|
2022-03-29 09:00:10 +00:00
|
|
|
ChannelId channelId,
|
|
|
|
Fn<void(not_null<ChannelData*>)> done) {
|
2020-09-22 15:05:07 +00:00
|
|
|
if (const auto channel = _session->data().channelLoaded(channelId)) {
|
|
|
|
done(channel);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto fail = [=] {
|
2021-03-15 16:49:32 +00:00
|
|
|
Ui::ShowMultilineToast({
|
2022-06-15 03:25:18 +00:00
|
|
|
.parentOverride = Window::Show(this).toastParent(),
|
2021-03-15 16:49:32 +00:00
|
|
|
.text = { tr::lng_error_post_link_invalid(tr::now) }
|
2022-06-15 03:25:18 +00:00
|
|
|
});
|
2020-09-22 15:05:07 +00:00
|
|
|
};
|
2022-03-25 14:13:30 +00:00
|
|
|
_api.request(base::take(_resolveRequestId)).cancel();
|
|
|
|
_resolveRequestId = _api.request(MTPchannels_GetChannels(
|
2020-09-22 15:05:07 +00:00
|
|
|
MTP_vector<MTPInputChannel>(
|
|
|
|
1,
|
2021-08-25 08:15:05 +00:00
|
|
|
MTP_inputChannel(MTP_long(channelId.bare), MTP_long(0)))
|
2020-09-22 15:05:07 +00:00
|
|
|
)).done([=](const MTPmessages_Chats &result) {
|
|
|
|
result.match([&](const auto &data) {
|
|
|
|
const auto peer = _session->data().processChats(data.vchats());
|
|
|
|
if (peer && peer->id == peerFromChannel(channelId)) {
|
|
|
|
done(peer->asChannel());
|
|
|
|
} else {
|
|
|
|
fail();
|
|
|
|
}
|
|
|
|
});
|
2021-11-26 20:46:53 +00:00
|
|
|
}).fail(fail).send();
|
2020-09-22 15:05:07 +00:00
|
|
|
}
|
|
|
|
|
2022-10-28 12:30:59 +00:00
|
|
|
void SessionNavigation::showMessageByLinkResolved(
|
|
|
|
not_null<HistoryItem*> item,
|
|
|
|
const PeerByLinkInfo &info) {
|
|
|
|
auto params = SectionShow{
|
|
|
|
SectionShow::Way::Forward
|
|
|
|
};
|
|
|
|
params.origin = SectionShow::OriginMessage{
|
|
|
|
info.clickFromMessageId
|
|
|
|
};
|
|
|
|
const auto peer = item->history()->peer;
|
|
|
|
const auto topicId = peer->isForum() ? item->topicRootId() : 0;
|
|
|
|
if (topicId) {
|
|
|
|
const auto messageId = (item->id == topicId) ? MsgId() : item->id;
|
|
|
|
showRepliesForMessage(item->history(), topicId, messageId, params);
|
|
|
|
} else {
|
|
|
|
showPeerHistory(peer, params, item->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-22 15:05:07 +00:00
|
|
|
void SessionNavigation::showPeerByLinkResolved(
|
2022-03-29 09:00:10 +00:00
|
|
|
not_null<PeerData*> peer,
|
|
|
|
const PeerByLinkInfo &info) {
|
2021-03-22 13:24:53 +00:00
|
|
|
auto params = SectionShow{
|
|
|
|
SectionShow::Way::Forward
|
|
|
|
};
|
|
|
|
params.origin = SectionShow::OriginMessage{
|
|
|
|
info.clickFromMessageId
|
|
|
|
};
|
2021-03-10 20:03:20 +00:00
|
|
|
if (info.voicechatHash && peer->isChannel()) {
|
2021-03-22 13:24:53 +00:00
|
|
|
// First show the channel itself.
|
|
|
|
crl::on_main(this, [=] {
|
2022-10-28 12:30:59 +00:00
|
|
|
showPeerHistory(peer, params, ShowAtUnreadMsgId);
|
2021-03-22 13:24:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Then try to join the voice chat.
|
2022-03-31 09:24:13 +00:00
|
|
|
joinVoiceChatFromLink(peer, info);
|
2021-03-10 20:03:20 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-03-24 09:46:44 +00:00
|
|
|
using Scope = AddBotToGroupBoxController::Scope;
|
2022-03-31 09:24:13 +00:00
|
|
|
const auto user = peer->asUser();
|
|
|
|
const auto bot = (user && user->isBot()) ? user : nullptr;
|
2020-09-22 15:05:07 +00:00
|
|
|
const auto &replies = info.repliesInfo;
|
|
|
|
if (const auto threadId = std::get_if<ThreadId>(&replies)) {
|
|
|
|
showRepliesForMessage(
|
|
|
|
session().data().history(peer),
|
|
|
|
threadId->id,
|
|
|
|
info.messageId,
|
|
|
|
params);
|
|
|
|
} else if (const auto commentId = std::get_if<CommentId>(&replies)) {
|
|
|
|
showRepliesForMessage(
|
|
|
|
session().data().history(peer),
|
|
|
|
info.messageId,
|
|
|
|
commentId->id,
|
|
|
|
params);
|
2022-10-14 14:34:04 +00:00
|
|
|
} else if (peer->isForum()) {
|
2022-10-28 12:30:59 +00:00
|
|
|
const auto itemId = info.messageId;
|
|
|
|
if (!itemId) {
|
2022-11-30 06:31:33 +00:00
|
|
|
parentController()->showForum(peer->forum(), params);
|
2022-10-28 12:30:59 +00:00
|
|
|
} else if (const auto item = peer->owner().message(peer, itemId)) {
|
|
|
|
showMessageByLinkResolved(item, info);
|
|
|
|
} else {
|
|
|
|
const auto callback = crl::guard(this, [=] {
|
|
|
|
if (const auto item = peer->owner().message(peer, itemId)) {
|
|
|
|
showMessageByLinkResolved(item, info);
|
|
|
|
} else {
|
|
|
|
showPeerHistory(peer, params, itemId);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
peer->session().api().requestMessageData(
|
|
|
|
peer,
|
|
|
|
info.messageId,
|
|
|
|
callback);
|
|
|
|
}
|
2022-11-01 09:00:17 +00:00
|
|
|
} else if (bot && info.resolveType == ResolveType::ShareGame) {
|
|
|
|
Window::ShowShareGameBox(parentController(), bot, info.startToken);
|
2022-03-31 09:24:13 +00:00
|
|
|
} else if (bot
|
2022-04-14 10:14:50 +00:00
|
|
|
&& (info.resolveType == ResolveType::AddToGroup
|
2022-11-01 09:00:17 +00:00
|
|
|
|| info.resolveType == ResolveType::AddToChannel)) {
|
|
|
|
const auto scope = (info.resolveType == ResolveType::AddToGroup)
|
2022-03-24 09:46:44 +00:00
|
|
|
? (info.startAdminRights ? Scope::GroupAdmin : Scope::All)
|
2022-04-14 10:14:50 +00:00
|
|
|
: (info.resolveType == ResolveType::AddToChannel)
|
2022-03-24 09:46:44 +00:00
|
|
|
? Scope::ChannelAdmin
|
|
|
|
: Scope::None;
|
2022-03-31 09:24:13 +00:00
|
|
|
Assert(scope != Scope::None);
|
|
|
|
|
|
|
|
AddBotToGroupBoxController::Start(
|
2022-06-09 05:19:11 +00:00
|
|
|
parentController(),
|
2022-03-31 09:24:13 +00:00
|
|
|
bot,
|
|
|
|
scope,
|
|
|
|
info.startToken,
|
|
|
|
info.startAdminRights);
|
2022-04-14 10:14:50 +00:00
|
|
|
} else if (info.resolveType == ResolveType::Mention) {
|
|
|
|
if (bot || peer->isChannel()) {
|
2020-09-22 15:05:07 +00:00
|
|
|
crl::on_main(this, [=] {
|
2022-10-28 12:30:59 +00:00
|
|
|
showPeerHistory(peer, params);
|
2020-09-22 15:05:07 +00:00
|
|
|
});
|
2022-03-31 09:24:13 +00:00
|
|
|
} else {
|
|
|
|
showPeerInfo(peer, params);
|
2020-09-22 15:05:07 +00:00
|
|
|
}
|
|
|
|
} else {
|
2022-03-31 09:24:13 +00:00
|
|
|
// Show specific posts only in channels / supergroups.
|
|
|
|
const auto msgId = peer->isChannel()
|
|
|
|
? info.messageId
|
2022-05-23 11:45:22 +00:00
|
|
|
: info.startAutoSubmit
|
|
|
|
? ShowAndStartBotMsgId
|
2022-03-31 09:24:13 +00:00
|
|
|
: ShowAtUnreadMsgId;
|
2022-03-24 13:41:59 +00:00
|
|
|
const auto attachBotUsername = info.attachBotUsername;
|
2022-03-31 09:24:13 +00:00
|
|
|
if (bot && bot->botInfo->startToken != info.startToken) {
|
|
|
|
bot->botInfo->startToken = info.startToken;
|
|
|
|
bot->session().changes().peerUpdated(
|
|
|
|
bot,
|
2020-09-22 15:05:07 +00:00
|
|
|
Data::PeerUpdate::Flag::BotStartToken);
|
|
|
|
}
|
2022-03-31 09:24:13 +00:00
|
|
|
if (!attachBotUsername.isEmpty()) {
|
|
|
|
crl::on_main(this, [=] {
|
2022-10-28 07:57:09 +00:00
|
|
|
const auto history = peer->owner().history(peer);
|
|
|
|
showPeerHistory(history, params, msgId);
|
2022-03-31 09:24:13 +00:00
|
|
|
peer->session().attachWebView().request(
|
2022-10-28 07:57:09 +00:00
|
|
|
Api::SendAction(history),
|
2022-03-31 09:24:13 +00:00
|
|
|
attachBotUsername,
|
|
|
|
info.attachBotToggleCommand.value_or(QString()));
|
|
|
|
});
|
|
|
|
} else if (bot && info.attachBotToggleCommand) {
|
|
|
|
const auto itemId = info.clickFromMessageId;
|
|
|
|
const auto item = _session->data().message(itemId);
|
|
|
|
const auto contextPeer = item
|
|
|
|
? item->history()->peer.get()
|
|
|
|
: nullptr;
|
|
|
|
const auto contextUser = contextPeer
|
|
|
|
? contextPeer->asUser()
|
|
|
|
: nullptr;
|
|
|
|
bot->session().attachWebView().requestAddToMenu(
|
2022-10-28 07:57:09 +00:00
|
|
|
(contextUser
|
|
|
|
? Api::SendAction(
|
|
|
|
contextUser->owner().history(contextUser))
|
|
|
|
: std::optional<Api::SendAction>()),
|
2022-03-31 09:24:13 +00:00
|
|
|
bot,
|
2022-06-02 20:26:41 +00:00
|
|
|
*info.attachBotToggleCommand,
|
|
|
|
parentController(),
|
|
|
|
info.attachBotChooseTypes);
|
2022-03-29 14:14:11 +00:00
|
|
|
} else {
|
|
|
|
crl::on_main(this, [=] {
|
2022-10-28 12:30:59 +00:00
|
|
|
showPeerHistory(peer, params, msgId);
|
2022-03-29 14:14:11 +00:00
|
|
|
});
|
|
|
|
}
|
2020-09-22 15:05:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-31 09:24:13 +00:00
|
|
|
void SessionNavigation::joinVoiceChatFromLink(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
const PeerByLinkInfo &info) {
|
|
|
|
Expects(info.voicechatHash.has_value());
|
|
|
|
|
|
|
|
const auto bad = [=] {
|
|
|
|
Ui::ShowMultilineToast({
|
2022-06-15 03:25:18 +00:00
|
|
|
.parentOverride = Window::Show(this).toastParent(),
|
2022-03-31 09:24:13 +00:00
|
|
|
.text = { tr::lng_group_invite_bad_link(tr::now) }
|
|
|
|
});
|
|
|
|
};
|
|
|
|
const auto hash = *info.voicechatHash;
|
|
|
|
_api.request(base::take(_resolveRequestId)).cancel();
|
|
|
|
_resolveRequestId = _api.request(
|
|
|
|
MTPchannels_GetFullChannel(peer->asChannel()->inputChannel)
|
|
|
|
).done([=](const MTPmessages_ChatFull &result) {
|
|
|
|
_session->api().processFullPeer(peer, result);
|
|
|
|
const auto call = peer->groupCall();
|
|
|
|
if (!call) {
|
|
|
|
bad();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto join = [=] {
|
|
|
|
parentController()->startOrJoinGroupCall(
|
|
|
|
peer,
|
|
|
|
{ hash, Calls::StartGroupCallArgs::JoinConfirm::Always });
|
|
|
|
};
|
|
|
|
if (call->loaded()) {
|
|
|
|
join();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto id = call->id();
|
|
|
|
const auto limit = 5;
|
|
|
|
_resolveRequestId = _api.request(
|
|
|
|
MTPphone_GetGroupCall(call->input(), MTP_int(limit))
|
|
|
|
).done([=](const MTPphone_GroupCall &result) {
|
2022-06-15 03:25:18 +00:00
|
|
|
if (const auto now = peer->groupCall(); now && now->id() == id) {
|
2022-03-31 09:24:13 +00:00
|
|
|
if (!now->loaded()) {
|
|
|
|
now->processFullCall(result);
|
|
|
|
}
|
|
|
|
join();
|
|
|
|
} else {
|
|
|
|
bad();
|
|
|
|
}
|
|
|
|
}).fail(bad).send();
|
|
|
|
}).send();
|
|
|
|
}
|
|
|
|
|
2020-09-03 08:21:31 +00:00
|
|
|
void SessionNavigation::showRepliesForMessage(
|
|
|
|
not_null<History*> history,
|
|
|
|
MsgId rootId,
|
2020-09-17 17:57:06 +00:00
|
|
|
MsgId commentId,
|
2020-09-03 08:21:31 +00:00
|
|
|
const SectionShow ¶ms) {
|
2022-10-20 09:33:04 +00:00
|
|
|
if (const auto topic = history->peer->forumTopicFor(rootId)) {
|
|
|
|
auto replies = topic->replies();
|
|
|
|
if (replies->unreadCountKnown()) {
|
|
|
|
auto memento = std::make_shared<HistoryView::RepliesMemento>(
|
|
|
|
history,
|
|
|
|
rootId,
|
|
|
|
commentId);
|
2022-11-03 12:29:22 +00:00
|
|
|
memento->setFromTopic(topic);
|
2022-10-20 09:33:04 +00:00
|
|
|
showSection(std::move(memento), params);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-09-03 08:21:31 +00:00
|
|
|
if (_showingRepliesRequestId
|
|
|
|
&& _showingRepliesHistory == history.get()
|
|
|
|
&& _showingRepliesRootId == rootId) {
|
|
|
|
return;
|
2020-09-30 11:06:08 +00:00
|
|
|
} else if (!history->peer->asChannel()) {
|
|
|
|
// HistoryView::RepliesWidget right now handles only channels.
|
|
|
|
return;
|
2020-09-03 08:21:31 +00:00
|
|
|
}
|
2022-03-25 14:13:30 +00:00
|
|
|
_api.request(base::take(_showingRepliesRequestId)).cancel();
|
2020-09-03 08:21:31 +00:00
|
|
|
|
2021-12-09 07:32:54 +00:00
|
|
|
const auto postPeer = history->peer;
|
2020-09-03 08:21:31 +00:00
|
|
|
_showingRepliesHistory = history;
|
|
|
|
_showingRepliesRootId = rootId;
|
2022-03-25 14:13:30 +00:00
|
|
|
_showingRepliesRequestId = _api.request(
|
2020-09-03 08:21:31 +00:00
|
|
|
MTPmessages_GetDiscussionMessage(
|
|
|
|
history->peer->input,
|
|
|
|
MTP_int(rootId))
|
|
|
|
).done([=](const MTPmessages_DiscussionMessage &result) {
|
|
|
|
_showingRepliesRequestId = 0;
|
|
|
|
result.match([&](const MTPDmessages_discussionMessage &data) {
|
|
|
|
_session->data().processUsers(data.vusers());
|
|
|
|
_session->data().processChats(data.vchats());
|
|
|
|
_session->data().processMessages(
|
|
|
|
data.vmessages(),
|
|
|
|
NewMessageType::Existing);
|
|
|
|
const auto list = data.vmessages().v;
|
2022-10-07 11:46:27 +00:00
|
|
|
const auto deleted = list.isEmpty();
|
|
|
|
const auto comments = history->peer->isBroadcast();
|
|
|
|
if (comments && deleted) {
|
2020-09-03 08:21:31 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-10-07 11:46:27 +00:00
|
|
|
const auto id = deleted ? rootId : IdFromMessage(list.front());
|
|
|
|
const auto peer = deleted
|
|
|
|
? history->peer->id
|
|
|
|
: PeerFromMessage(list.front());
|
2020-09-03 08:21:31 +00:00
|
|
|
if (!peer || !id) {
|
|
|
|
return;
|
|
|
|
}
|
2022-10-07 11:46:27 +00:00
|
|
|
auto item = deleted
|
|
|
|
? nullptr
|
|
|
|
: _session->data().message(peer, id);
|
|
|
|
if (comments && !item) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto &groups = _session->data().groups();
|
|
|
|
if (const auto group = item ? groups.find(item) : nullptr) {
|
2020-09-03 08:21:31 +00:00
|
|
|
item = group->items.front();
|
|
|
|
}
|
2022-10-07 11:46:27 +00:00
|
|
|
if (comments) {
|
2021-12-09 07:32:54 +00:00
|
|
|
const auto post = _session->data().message(postPeer, rootId);
|
2022-10-07 11:46:27 +00:00
|
|
|
if (post) {
|
2020-09-03 08:21:31 +00:00
|
|
|
post->setCommentsItemId(item->fullId());
|
2020-09-15 08:39:39 +00:00
|
|
|
if (const auto maxId = data.vmax_id()) {
|
2022-10-07 11:46:27 +00:00
|
|
|
post->setCommentsMaxId(maxId->v);
|
2020-09-15 08:39:39 +00:00
|
|
|
}
|
2022-10-07 11:46:27 +00:00
|
|
|
post->setCommentsInboxReadTill(
|
|
|
|
data.vread_inbox_max_id().value_or_empty());
|
2020-09-08 11:19:44 +00:00
|
|
|
}
|
2022-10-07 11:46:27 +00:00
|
|
|
}
|
|
|
|
if (deleted || item) {
|
2022-10-20 09:33:04 +00:00
|
|
|
auto memento = item
|
|
|
|
? std::make_shared<HistoryView::RepliesMemento>(
|
|
|
|
item,
|
|
|
|
commentId)
|
|
|
|
: std::make_shared<HistoryView::RepliesMemento>(
|
|
|
|
history,
|
|
|
|
rootId,
|
|
|
|
commentId);
|
2022-10-07 11:46:27 +00:00
|
|
|
memento->setReadInformation(
|
|
|
|
data.vread_inbox_max_id().value_or_empty(),
|
|
|
|
data.vunread_count().v,
|
|
|
|
data.vread_outbox_max_id().value_or_empty());
|
|
|
|
showSection(std::move(memento), params);
|
2020-09-03 08:21:31 +00:00
|
|
|
}
|
|
|
|
});
|
2021-03-12 12:48:00 +00:00
|
|
|
}).fail([=](const MTP::Error &error) {
|
2020-09-03 08:21:31 +00:00
|
|
|
_showingRepliesRequestId = 0;
|
2020-10-01 13:42:31 +00:00
|
|
|
if (error.type() == u"CHANNEL_PRIVATE"_q
|
|
|
|
|| error.type() == u"USER_BANNED_IN_CHANNEL"_q) {
|
2022-06-14 09:48:25 +00:00
|
|
|
Ui::Toast::Show(
|
|
|
|
Show(this).toastParent(),
|
|
|
|
tr::lng_group_not_accessible(tr::now));
|
2020-10-01 13:42:31 +00:00
|
|
|
}
|
2020-09-03 08:21:31 +00:00
|
|
|
}).send();
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionNavigation::showPeerInfo(
|
2019-01-18 12:27:37 +00:00
|
|
|
PeerId peerId,
|
|
|
|
const SectionShow ¶ms) {
|
2020-06-08 09:06:50 +00:00
|
|
|
showPeerInfo(_session->data().peer(peerId), params);
|
2019-01-18 12:27:37 +00:00
|
|
|
}
|
|
|
|
|
2022-10-27 07:35:35 +00:00
|
|
|
void SessionNavigation::showTopic(
|
|
|
|
not_null<Data::ForumTopic*> topic,
|
2022-11-01 04:46:31 +00:00
|
|
|
MsgId itemId,
|
2022-10-27 07:35:35 +00:00
|
|
|
const SectionShow ¶ms) {
|
|
|
|
return showRepliesForMessage(
|
|
|
|
topic->history(),
|
|
|
|
topic->rootId(),
|
2022-11-01 04:46:31 +00:00
|
|
|
itemId,
|
2022-10-27 07:35:35 +00:00
|
|
|
params);
|
|
|
|
}
|
|
|
|
|
2022-11-01 04:46:31 +00:00
|
|
|
void SessionNavigation::showThread(
|
|
|
|
not_null<Data::Thread*> thread,
|
|
|
|
MsgId itemId,
|
|
|
|
const SectionShow ¶ms) {
|
|
|
|
if (const auto topic = thread->asTopic()) {
|
|
|
|
showTopic(topic, itemId, params);
|
|
|
|
} else {
|
|
|
|
showPeerHistory(thread->asHistory(), params, itemId);
|
|
|
|
}
|
|
|
|
if (parentController()->activeChatCurrent().thread() == thread) {
|
2022-11-30 12:02:40 +00:00
|
|
|
parentController()->content()->hideDragForwardInfo();
|
2022-11-01 04:46:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionNavigation::showPeerInfo(
|
2019-01-18 12:27:37 +00:00
|
|
|
not_null<PeerData*> peer,
|
|
|
|
const SectionShow ¶ms) {
|
2020-06-08 09:06:50 +00:00
|
|
|
//if (Adaptive::ThreeColumn()
|
2020-06-25 12:16:09 +00:00
|
|
|
// && !Core::App().settings().thirdSectionInfoEnabled()) {
|
|
|
|
// Core::App().settings().setThirdSectionInfoEnabled(true);
|
|
|
|
// Core::App().saveSettingsDelayed();
|
2020-06-08 09:06:50 +00:00
|
|
|
//}
|
2020-12-14 14:48:10 +00:00
|
|
|
showSection(std::make_shared<Info::Memento>(peer), params);
|
2019-01-18 12:27:37 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionNavigation::showPeerInfo(
|
2022-10-13 17:34:04 +00:00
|
|
|
not_null<Data::Thread*> thread,
|
2019-01-18 12:27:37 +00:00
|
|
|
const SectionShow ¶ms) {
|
2022-10-13 17:34:04 +00:00
|
|
|
if (const auto topic = thread->asTopic()) {
|
|
|
|
showSection(std::make_shared<Info::Memento>(topic), params);
|
|
|
|
} else {
|
|
|
|
showPeerInfo(thread->peer()->id, params);
|
|
|
|
}
|
2019-01-18 12:27:37 +00:00
|
|
|
}
|
|
|
|
|
2020-09-22 15:05:07 +00:00
|
|
|
void SessionNavigation::showPeerHistory(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
const SectionShow ¶ms,
|
|
|
|
MsgId msgId) {
|
2022-01-04 16:36:33 +00:00
|
|
|
showPeerHistory(peer->id, params, msgId);
|
2020-09-22 15:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SessionNavigation::showPeerHistory(
|
|
|
|
not_null<History*> history,
|
|
|
|
const SectionShow ¶ms,
|
|
|
|
MsgId msgId) {
|
2022-01-04 16:36:33 +00:00
|
|
|
showPeerHistory(history->peer->id, params, msgId);
|
2020-09-22 15:05:07 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionNavigation::showSettings(
|
2019-01-18 12:27:37 +00:00
|
|
|
Settings::Type type,
|
|
|
|
const SectionShow ¶ms) {
|
|
|
|
showSection(
|
2020-12-14 14:48:10 +00:00
|
|
|
std::make_shared<Info::Memento>(
|
2019-01-18 12:27:37 +00:00
|
|
|
Info::Settings::Tag{ _session->user() },
|
|
|
|
Info::Section(type)),
|
|
|
|
params);
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionNavigation::showSettings(const SectionShow ¶ms) {
|
2022-04-01 11:53:23 +00:00
|
|
|
showSettings(Settings::Main::Id(), params);
|
2019-01-18 12:27:37 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 11:53:42 +00:00
|
|
|
void SessionNavigation::showPollResults(
|
|
|
|
not_null<PollData*> poll,
|
|
|
|
FullMsgId contextId,
|
|
|
|
const SectionShow ¶ms) {
|
2020-12-14 14:48:10 +00:00
|
|
|
showSection(std::make_shared<Info::Memento>(poll, contextId), params);
|
2020-01-15 11:53:42 +00:00
|
|
|
}
|
|
|
|
|
2021-08-27 11:32:18 +00:00
|
|
|
struct SessionController::CachedTheme {
|
2021-09-19 15:15:46 +00:00
|
|
|
std::weak_ptr<Ui::ChatTheme> theme;
|
2021-08-27 11:32:18 +00:00
|
|
|
std::shared_ptr<Data::DocumentMedia> media;
|
|
|
|
Data::WallPaper paper;
|
2021-09-19 15:15:46 +00:00
|
|
|
bool caching = false;
|
2021-08-27 11:32:18 +00:00
|
|
|
rpl::lifetime lifetime;
|
|
|
|
};
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
SessionController::SessionController(
|
2019-07-24 11:45:24 +00:00
|
|
|
not_null<Main::Session*> session,
|
2019-09-03 15:24:51 +00:00
|
|
|
not_null<Controller*> window)
|
2019-06-06 10:21:40 +00:00
|
|
|
: SessionNavigation(session)
|
2019-08-16 12:44:20 +00:00
|
|
|
, _window(window)
|
2021-09-14 20:42:34 +00:00
|
|
|
, _emojiInteractions(
|
|
|
|
std::make_unique<ChatHelpers::EmojiInteractions>(session))
|
2022-06-07 18:05:37 +00:00
|
|
|
, _isPrimary(window->isPrimary())
|
2022-02-08 19:19:01 +00:00
|
|
|
, _sendingAnimation(
|
|
|
|
std::make_unique<Ui::MessageSendingAnimationController>(this))
|
2019-08-16 12:44:20 +00:00
|
|
|
, _tabbedSelector(
|
2019-09-03 15:24:51 +00:00
|
|
|
std::make_unique<ChatHelpers::TabbedSelector>(
|
|
|
|
_window->widget(),
|
2022-07-25 10:34:18 +00:00
|
|
|
this,
|
|
|
|
GifPauseReason::TabbedPanel))
|
2021-08-13 15:39:50 +00:00
|
|
|
, _invitePeekTimer([=] { checkInvitePeek(); })
|
2022-05-17 13:56:15 +00:00
|
|
|
, _activeChatsFilter(session->data().chatsFilters().defaultId())
|
2021-08-27 20:44:47 +00:00
|
|
|
, _defaultChatTheme(std::make_shared<Ui::ChatTheme>())
|
2022-01-10 20:44:05 +00:00
|
|
|
, _chatStyle(std::make_unique<Ui::ChatStyle>())
|
2022-07-03 14:56:12 +00:00
|
|
|
, _cachedReactionIconFactory(std::make_unique<ReactionIconFactory>())
|
2022-12-14 07:53:36 +00:00
|
|
|
, _giftPremiumValidator(this) {
|
2019-01-18 12:27:37 +00:00
|
|
|
init();
|
2019-03-17 08:14:31 +00:00
|
|
|
|
2021-08-27 20:44:47 +00:00
|
|
|
_chatStyleTheme = _defaultChatTheme;
|
|
|
|
_chatStyle->apply(_defaultChatTheme.get());
|
|
|
|
|
2021-08-26 15:02:21 +00:00
|
|
|
pushDefaultChatBackground();
|
|
|
|
Theme::Background()->updates(
|
|
|
|
) | rpl::start_with_next([=](const Theme::BackgroundUpdate &update) {
|
|
|
|
if (update.type == Theme::BackgroundUpdate::Type::New
|
|
|
|
|| update.type == Theme::BackgroundUpdate::Type::Changed) {
|
|
|
|
pushDefaultChatBackground();
|
|
|
|
}
|
|
|
|
}, _lifetime);
|
|
|
|
|
2023-02-03 13:51:26 +00:00
|
|
|
_authedName = session->user()->name();
|
2021-10-12 12:50:18 +00:00
|
|
|
session->changes().peerUpdates(
|
|
|
|
Data::PeerUpdate::Flag::FullInfo
|
2023-02-03 13:51:26 +00:00
|
|
|
| Data::PeerUpdate::Flag::Name
|
2021-10-12 12:50:18 +00:00
|
|
|
) | rpl::filter([=](const Data::PeerUpdate &update) {
|
2023-02-03 13:51:26 +00:00
|
|
|
if (update.flags & Data::PeerUpdate::Flag::Name) {
|
|
|
|
const auto user = session->user();
|
|
|
|
if (update.peer == user) {
|
|
|
|
_authedName = user->name();
|
|
|
|
const auto &settings = Core::App().settings();
|
|
|
|
if (!settings.windowTitleContent().hideAccountName) {
|
|
|
|
widget()->updateTitle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (update.flags & Data::PeerUpdate::Flag::FullInfo)
|
|
|
|
&& (update.peer == _showEditPeer);
|
2021-10-12 12:50:18 +00:00
|
|
|
}) | rpl::start_with_next([=] {
|
|
|
|
show(Box<EditPeerInfoBox>(this, base::take(_showEditPeer)));
|
2021-05-25 10:35:38 +00:00
|
|
|
}, lifetime());
|
2019-04-24 10:15:10 +00:00
|
|
|
|
|
|
|
session->data().chatsListChanges(
|
|
|
|
) | rpl::filter([=](Data::Folder *folder) {
|
|
|
|
return (folder != nullptr)
|
|
|
|
&& (folder == _openedFolder.current())
|
2020-02-07 09:43:12 +00:00
|
|
|
&& folder->chatsList()->indexed()->empty();
|
2019-04-24 10:15:10 +00:00
|
|
|
}) | rpl::start_with_next([=](Data::Folder *folder) {
|
|
|
|
folder->updateChatListSortPosition();
|
|
|
|
closeFolder();
|
|
|
|
}, lifetime());
|
2020-03-18 09:19:58 +00:00
|
|
|
|
|
|
|
session->data().chatsFilters().changed(
|
|
|
|
) | rpl::start_with_next([=] {
|
2020-03-18 14:10:22 +00:00
|
|
|
checkOpenedFilter();
|
2020-06-22 07:30:32 +00:00
|
|
|
crl::on_main(this, [=] {
|
2020-03-18 09:19:58 +00:00
|
|
|
refreshFiltersMenu();
|
|
|
|
});
|
2020-06-26 17:50:36 +00:00
|
|
|
}, lifetime());
|
2020-06-11 09:41:03 +00:00
|
|
|
|
2022-10-04 15:34:45 +00:00
|
|
|
session->data().itemIdChanged(
|
|
|
|
) | rpl::start_with_next([=](Data::Session::IdChange change) {
|
|
|
|
const auto current = _activeChatEntry.current();
|
|
|
|
if (const auto topic = current.key.topic()) {
|
|
|
|
if (topic->rootId() == change.oldId) {
|
|
|
|
setActiveChatEntry({
|
|
|
|
Dialogs::Key(topic->forum()->topicFor(change.newId.msg)),
|
|
|
|
current.fullId,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (auto &entry : _chatEntryHistory) {
|
|
|
|
if (const auto topic = entry.key.topic()) {
|
|
|
|
if (topic->rootId() == change.oldId) {
|
|
|
|
entry.key = Dialogs::Key(
|
|
|
|
topic->forum()->topicFor(change.newId.msg));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, lifetime());
|
|
|
|
|
2020-07-06 14:08:28 +00:00
|
|
|
session->api().globalPrivacy().suggestArchiveAndMute(
|
|
|
|
) | rpl::take(1) | rpl::start_with_next([=] {
|
|
|
|
session->api().globalPrivacy().reload(crl::guard(this, [=] {
|
|
|
|
if (!session->api().globalPrivacy().archiveAndMuteCurrent()) {
|
|
|
|
suggestArchiveAndMute();
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}, _lifetime);
|
|
|
|
|
2020-06-11 09:41:03 +00:00
|
|
|
session->addWindow(this);
|
2022-05-17 13:56:15 +00:00
|
|
|
|
|
|
|
crl::on_main(this, [=] {
|
|
|
|
activateFirstChatsFilter();
|
2022-06-07 08:41:10 +00:00
|
|
|
setupPremiumToast();
|
2022-05-17 13:56:15 +00:00
|
|
|
});
|
2019-03-17 08:14:31 +00:00
|
|
|
}
|
|
|
|
|
2020-07-06 14:08:28 +00:00
|
|
|
void SessionController::suggestArchiveAndMute() {
|
|
|
|
const auto weak = base::make_weak(this);
|
|
|
|
_window->show(Box([=](not_null<Ui::GenericBox*> box) {
|
|
|
|
box->setTitle(tr::lng_suggest_hide_new_title());
|
|
|
|
box->addRow(object_ptr<Ui::FlatLabel>(
|
|
|
|
box,
|
|
|
|
tr::lng_suggest_hide_new_about(Ui::Text::RichLangValue),
|
|
|
|
st::boxLabel));
|
|
|
|
box->addButton(tr::lng_suggest_hide_new_to_settings(), [=] {
|
2022-04-01 11:53:23 +00:00
|
|
|
showSettings(Settings::PrivacySecurity::Id());
|
2020-07-06 14:08:28 +00:00
|
|
|
});
|
|
|
|
box->setCloseByOutsideClick(false);
|
|
|
|
box->boxClosing(
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
crl::on_main(weak, [=] {
|
|
|
|
auto &privacy = session().api().globalPrivacy();
|
|
|
|
privacy.dismissArchiveAndMuteSuggestion();
|
|
|
|
});
|
|
|
|
}, box->lifetime());
|
|
|
|
box->addButton(tr::lng_cancel(), [=] {
|
|
|
|
box->closeBox();
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2022-01-04 13:13:00 +00:00
|
|
|
PeerData *SessionController::singlePeer() const {
|
|
|
|
return _window->singlePeer();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SessionController::isPrimary() const {
|
2022-06-07 18:05:37 +00:00
|
|
|
return _isPrimary;
|
2022-01-04 13:13:00 +00:00
|
|
|
}
|
|
|
|
|
2019-09-03 15:24:51 +00:00
|
|
|
not_null<::MainWindow*> SessionController::widget() const {
|
|
|
|
return _window->widget();
|
|
|
|
}
|
|
|
|
|
2022-02-08 19:19:01 +00:00
|
|
|
auto SessionController::sendingAnimation() const
|
|
|
|
-> Ui::MessageSendingAnimationController & {
|
|
|
|
return *_sendingAnimation;
|
|
|
|
}
|
|
|
|
|
2019-08-16 12:44:20 +00:00
|
|
|
auto SessionController::tabbedSelector() const
|
|
|
|
-> not_null<ChatHelpers::TabbedSelector*> {
|
|
|
|
return _tabbedSelector.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SessionController::takeTabbedSelectorOwnershipFrom(
|
|
|
|
not_null<QWidget*> parent) {
|
|
|
|
if (_tabbedSelector->parent() == parent) {
|
2020-06-10 18:08:17 +00:00
|
|
|
if (const auto chats = widget()->sessionContent()) {
|
2019-08-16 12:44:20 +00:00
|
|
|
chats->returnTabbedSelector();
|
|
|
|
}
|
|
|
|
if (_tabbedSelector->parent() == parent) {
|
|
|
|
_tabbedSelector->hide();
|
2019-09-03 15:24:51 +00:00
|
|
|
_tabbedSelector->setParent(widget());
|
2019-08-16 12:44:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SessionController::hasTabbedSelectorOwnership() const {
|
2019-09-03 15:24:51 +00:00
|
|
|
return (_tabbedSelector->parent() == widget());
|
2019-08-16 12:44:20 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::showEditPeerBox(PeerData *peer) {
|
2019-03-17 08:14:31 +00:00
|
|
|
_showEditPeer = peer;
|
2019-06-06 11:59:00 +00:00
|
|
|
session().api().requestFullPeer(peer);
|
2019-01-18 12:27:37 +00:00
|
|
|
}
|
|
|
|
|
2022-07-03 14:56:12 +00:00
|
|
|
void SessionController::showGiftPremiumBox(UserData *user) {
|
|
|
|
if (user) {
|
|
|
|
_giftPremiumValidator.showBox(user);
|
|
|
|
} else {
|
|
|
|
_giftPremiumValidator.cancel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::init() {
|
2019-01-18 12:27:37 +00:00
|
|
|
if (session().supportMode()) {
|
2018-12-30 12:50:23 +00:00
|
|
|
initSupportMode();
|
2018-11-15 15:36:04 +00:00
|
|
|
}
|
2018-01-21 14:49:42 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::initSupportMode() {
|
2019-01-18 12:27:37 +00:00
|
|
|
session().supportHelper().registerWindow(this);
|
2018-12-30 12:50:23 +00:00
|
|
|
|
|
|
|
Shortcuts::Requests(
|
2022-07-07 00:19:39 +00:00
|
|
|
) | rpl::filter([=] {
|
|
|
|
return (Core::App().activeWindow() == &window());
|
|
|
|
}) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) {
|
2018-12-30 12:50:23 +00:00
|
|
|
using C = Shortcuts::Command;
|
|
|
|
|
|
|
|
request->check(C::SupportHistoryBack) && request->handle([=] {
|
|
|
|
return chatEntryHistoryMove(-1);
|
|
|
|
});
|
|
|
|
request->check(C::SupportHistoryForward) && request->handle([=] {
|
|
|
|
return chatEntryHistoryMove(1);
|
|
|
|
});
|
|
|
|
}, lifetime());
|
|
|
|
}
|
|
|
|
|
2020-03-03 12:07:22 +00:00
|
|
|
void SessionController::toggleFiltersMenu(bool enabled) {
|
2022-06-07 18:05:37 +00:00
|
|
|
if (!_isPrimary || (!enabled == !_filters)) {
|
2020-03-03 12:07:22 +00:00
|
|
|
return;
|
|
|
|
} else if (enabled) {
|
2020-03-06 11:37:48 +00:00
|
|
|
_filters = std::make_unique<FiltersMenu>(
|
|
|
|
widget()->bodyWidget(),
|
|
|
|
this);
|
2020-03-03 12:07:22 +00:00
|
|
|
} else {
|
|
|
|
_filters = nullptr;
|
|
|
|
}
|
2020-03-18 12:14:45 +00:00
|
|
|
_filtersMenuChanged.fire({});
|
2020-03-03 12:07:22 +00:00
|
|
|
}
|
|
|
|
|
2020-03-18 09:19:58 +00:00
|
|
|
void SessionController::refreshFiltersMenu() {
|
2022-05-17 09:24:35 +00:00
|
|
|
toggleFiltersMenu(session().data().chatsFilters().has());
|
2020-03-18 09:19:58 +00:00
|
|
|
}
|
|
|
|
|
2020-03-18 12:14:45 +00:00
|
|
|
rpl::producer<> SessionController::filtersMenuChanged() const {
|
|
|
|
return _filtersMenuChanged.events();
|
|
|
|
}
|
|
|
|
|
2020-03-18 14:10:22 +00:00
|
|
|
void SessionController::checkOpenedFilter() {
|
2022-05-17 13:56:15 +00:00
|
|
|
activateFirstChatsFilter();
|
2020-03-18 14:10:22 +00:00
|
|
|
if (const auto filterId = activeChatsFilterCurrent()) {
|
|
|
|
const auto &list = session().data().chatsFilters().list();
|
|
|
|
const auto i = ranges::find(list, filterId, &Data::ChatFilter::id);
|
|
|
|
if (i == end(list)) {
|
2022-09-26 13:37:32 +00:00
|
|
|
setActiveChatsFilter(
|
|
|
|
0,
|
|
|
|
{ anim::type::normal, anim::activation::background });
|
2020-03-18 14:10:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-17 13:56:15 +00:00
|
|
|
void SessionController::activateFirstChatsFilter() {
|
|
|
|
if (_filtersActivated || !session().data().chatsFilters().loaded()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_filtersActivated = true;
|
|
|
|
setActiveChatsFilter(session().data().chatsFilters().defaultId());
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
bool SessionController::uniqueChatsInSearchResults() const {
|
2019-04-24 10:15:10 +00:00
|
|
|
return session().supportMode()
|
|
|
|
&& !session().settings().supportAllSearchResults()
|
|
|
|
&& !searchInChat.current();
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::openFolder(not_null<Data::Folder*> folder) {
|
2020-05-12 08:18:52 +00:00
|
|
|
if (_openedFolder.current() != folder) {
|
|
|
|
resetFakeUnreadWhileOpened();
|
|
|
|
}
|
2020-03-20 13:12:13 +00:00
|
|
|
setActiveChatsFilter(0);
|
2022-09-20 09:35:47 +00:00
|
|
|
closeForum();
|
2019-04-24 10:15:10 +00:00
|
|
|
_openedFolder = folder.get();
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::closeFolder() {
|
2019-04-24 10:15:10 +00:00
|
|
|
_openedFolder = nullptr;
|
|
|
|
}
|
|
|
|
|
2022-11-30 06:31:33 +00:00
|
|
|
void SessionController::showForum(
|
|
|
|
not_null<Data::Forum*> forum,
|
2022-09-26 13:37:32 +00:00
|
|
|
const SectionShow ¶ms) {
|
2022-11-30 06:31:33 +00:00
|
|
|
if (!isPrimary()) {
|
2023-01-17 15:47:58 +00:00
|
|
|
auto primary = Core::App().windowFor(&session().account());
|
2022-11-30 06:31:33 +00:00
|
|
|
if (&primary->account() != &session().account()) {
|
2023-01-17 15:47:58 +00:00
|
|
|
Core::App().domain().activate(&session().account());
|
|
|
|
primary = Core::App().windowFor(&session().account());
|
2022-11-30 06:31:33 +00:00
|
|
|
}
|
|
|
|
if (&primary->account() == &session().account()) {
|
|
|
|
primary->sessionController()->showForum(forum, params);
|
|
|
|
}
|
|
|
|
primary->activate();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_shownForumLifetime.destroy();
|
|
|
|
if (_shownForum.current() != forum) {
|
2022-09-20 09:35:47 +00:00
|
|
|
resetFakeUnreadWhileOpened();
|
|
|
|
}
|
2022-11-08 16:27:12 +00:00
|
|
|
if (forum
|
|
|
|
&& _activeChatEntry.current().key.peer()
|
|
|
|
&& adaptive().isOneColumn()) {
|
2022-11-07 09:14:52 +00:00
|
|
|
clearSectionStack(params);
|
|
|
|
}
|
2022-11-30 06:31:33 +00:00
|
|
|
_shownForum = forum.get();
|
|
|
|
if (_shownForum.current() != forum) {
|
|
|
|
return;
|
2022-11-08 16:27:12 +00:00
|
|
|
}
|
2022-11-30 06:31:33 +00:00
|
|
|
forum->destroyed(
|
|
|
|
) | rpl::start_with_next([=, history = forum->history()] {
|
2023-01-21 05:42:57 +00:00
|
|
|
const auto now = activeChatCurrent().owningHistory();
|
|
|
|
const auto showHistory = !now || (now == history);
|
2022-11-30 06:31:33 +00:00
|
|
|
closeForum();
|
2023-01-21 05:42:57 +00:00
|
|
|
if (showHistory) {
|
|
|
|
showPeerHistory(history, {
|
|
|
|
SectionShow::Way::Backward,
|
|
|
|
anim::type::normal,
|
|
|
|
anim::activation::background,
|
|
|
|
});
|
|
|
|
}
|
2022-11-30 06:31:33 +00:00
|
|
|
}, _shownForumLifetime);
|
|
|
|
content()->showForum(forum, params);
|
2022-09-20 09:35:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SessionController::closeForum() {
|
2022-11-30 06:31:33 +00:00
|
|
|
_shownForumLifetime.destroy();
|
|
|
|
_shownForum = nullptr;
|
2022-09-20 09:35:47 +00:00
|
|
|
}
|
|
|
|
|
2022-06-07 08:41:10 +00:00
|
|
|
void SessionController::setupPremiumToast() {
|
|
|
|
rpl::combine(
|
|
|
|
Data::AmPremiumValue(&session()),
|
|
|
|
session().changes().peerUpdates(
|
|
|
|
Data::PeerUpdate::Flag::FullInfo
|
|
|
|
)
|
|
|
|
) | rpl::filter([=] {
|
|
|
|
return session().user()->isFullLoaded();
|
|
|
|
}) | rpl::map([=](bool premium, const auto&) {
|
|
|
|
return premium;
|
|
|
|
}) | rpl::distinct_until_changed() | rpl::skip(
|
|
|
|
1
|
|
|
|
) | rpl::filter([=](bool premium) {
|
2022-06-28 13:13:20 +00:00
|
|
|
session().mtp().requestConfig();
|
2022-06-07 08:41:10 +00:00
|
|
|
return premium;
|
|
|
|
}) | rpl::start_with_next([=] {
|
|
|
|
Ui::Toast::Show(
|
|
|
|
Window::Show(this).toastParent(),
|
|
|
|
{
|
2022-06-10 13:38:52 +00:00
|
|
|
.text = { tr::lng_premium_success(tr::now) },
|
2022-06-07 08:41:10 +00:00
|
|
|
.st = &st::defaultToast,
|
|
|
|
});
|
|
|
|
}, _lifetime);
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
const rpl::variable<Data::Folder*> &SessionController::openedFolder() const {
|
2019-04-24 10:15:10 +00:00
|
|
|
return _openedFolder;
|
|
|
|
}
|
|
|
|
|
2022-11-30 06:31:33 +00:00
|
|
|
const rpl::variable<Data::Forum*> &SessionController::shownForum() const {
|
|
|
|
return _shownForum;
|
2022-09-20 09:35:47 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::setActiveChatEntry(Dialogs::RowDescriptor row) {
|
2020-03-23 10:09:27 +00:00
|
|
|
const auto was = _activeChatEntry.current().key.history();
|
|
|
|
const auto now = row.key.history();
|
|
|
|
if (was && was != now) {
|
2022-09-26 13:37:32 +00:00
|
|
|
_activeHistoryLifetime.destroy();
|
2020-03-23 10:09:27 +00:00
|
|
|
was->setFakeUnreadWhileOpened(false);
|
2020-07-01 14:19:25 +00:00
|
|
|
_invitePeekTimer.cancel();
|
2020-03-20 15:19:55 +00:00
|
|
|
}
|
2018-01-22 16:42:25 +00:00
|
|
|
_activeChatEntry = row;
|
2020-03-23 10:09:27 +00:00
|
|
|
if (now) {
|
|
|
|
now->setFakeUnreadWhileOpened(true);
|
2022-09-26 13:37:32 +00:00
|
|
|
if (const auto channel = now->peer->asChannel()
|
|
|
|
; channel && !channel->isForum()) {
|
2022-10-24 11:52:28 +00:00
|
|
|
Data::PeerFlagValue(
|
|
|
|
channel,
|
|
|
|
ChannelData::Flag::Forum
|
|
|
|
) | rpl::filter(
|
|
|
|
rpl::mappers::_1
|
|
|
|
) | rpl::start_with_next([=] {
|
2022-09-26 13:37:32 +00:00
|
|
|
clearSectionStack(
|
|
|
|
{ anim::type::normal, anim::activation::background });
|
2022-11-30 06:31:33 +00:00
|
|
|
showForum(channel->forum(),
|
2022-09-26 13:37:32 +00:00
|
|
|
{ anim::type::normal, anim::activation::background });
|
2022-11-30 06:31:33 +00:00
|
|
|
}, _shownForumLifetime);
|
2022-09-26 13:37:32 +00:00
|
|
|
}
|
2020-03-20 15:19:55 +00:00
|
|
|
}
|
2019-01-18 12:27:37 +00:00
|
|
|
if (session().supportMode()) {
|
2018-12-30 12:50:23 +00:00
|
|
|
pushToChatEntryHistory(row);
|
|
|
|
}
|
2020-07-01 14:19:25 +00:00
|
|
|
checkInvitePeek();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SessionController::checkInvitePeek() {
|
|
|
|
const auto history = activeChatCurrent().history();
|
|
|
|
if (!history) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto channel = history->peer->asChannel();
|
|
|
|
if (!channel) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto expires = channel->invitePeekExpires();
|
|
|
|
if (!expires) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto now = base::unixtime::now();
|
|
|
|
if (expires > now) {
|
|
|
|
_invitePeekTimer.callOnce((expires - now) * crl::time(1000));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto hash = channel->invitePeekHash();
|
|
|
|
channel->clearInvitePeek();
|
|
|
|
Api::CheckChatInvite(this, hash, channel);
|
2018-12-30 12:50:23 +00:00
|
|
|
}
|
|
|
|
|
2020-05-12 08:18:52 +00:00
|
|
|
void SessionController::resetFakeUnreadWhileOpened() {
|
|
|
|
if (const auto history = _activeChatEntry.current().key.history()) {
|
|
|
|
history->setFakeUnreadWhileOpened(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
bool SessionController::chatEntryHistoryMove(int steps) {
|
2018-12-30 12:50:23 +00:00
|
|
|
if (_chatEntryHistory.empty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const auto position = _chatEntryHistoryPosition + steps;
|
|
|
|
if (!base::in_range(position, 0, int(_chatEntryHistory.size()))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
_chatEntryHistoryPosition = position;
|
|
|
|
return jumpToChatListEntry(_chatEntryHistory[position]);
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
bool SessionController::jumpToChatListEntry(Dialogs::RowDescriptor row) {
|
2022-12-06 10:32:34 +00:00
|
|
|
if (const auto thread = row.key.thread()) {
|
|
|
|
showThread(
|
|
|
|
thread,
|
|
|
|
row.fullId.msg,
|
|
|
|
SectionShow::Way::ClearStack);
|
2018-12-30 12:50:23 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-02-05 15:15:24 +00:00
|
|
|
Dialogs::RowDescriptor SessionController::resolveChatNext(
|
|
|
|
Dialogs::RowDescriptor from) const {
|
|
|
|
return content()->resolveChatNext(from);
|
|
|
|
}
|
|
|
|
|
|
|
|
Dialogs::RowDescriptor SessionController::resolveChatPrevious(
|
|
|
|
Dialogs::RowDescriptor from) const {
|
|
|
|
return content()->resolveChatPrevious(from);
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::pushToChatEntryHistory(Dialogs::RowDescriptor row) {
|
2018-12-30 12:50:23 +00:00
|
|
|
if (!_chatEntryHistory.empty()
|
|
|
|
&& _chatEntryHistory[_chatEntryHistoryPosition] == row) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_chatEntryHistory.resize(++_chatEntryHistoryPosition);
|
|
|
|
_chatEntryHistory.push_back(row);
|
|
|
|
if (_chatEntryHistory.size() > kMaxChatEntryHistorySize) {
|
|
|
|
_chatEntryHistory.pop_front();
|
|
|
|
--_chatEntryHistoryPosition;
|
|
|
|
}
|
2018-01-22 16:42:25 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::setActiveChatEntry(Dialogs::Key key) {
|
2018-02-16 15:46:24 +00:00
|
|
|
setActiveChatEntry({ key, FullMsgId() });
|
2018-01-22 16:42:25 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
Dialogs::RowDescriptor SessionController::activeChatEntryCurrent() const {
|
2018-01-22 16:42:25 +00:00
|
|
|
return _activeChatEntry.current();
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
Dialogs::Key SessionController::activeChatCurrent() const {
|
2018-01-22 16:42:25 +00:00
|
|
|
return activeChatEntryCurrent().key;
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
auto SessionController::activeChatEntryChanges() const
|
2018-01-22 16:42:25 +00:00
|
|
|
-> rpl::producer<Dialogs::RowDescriptor> {
|
|
|
|
return _activeChatEntry.changes();
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
rpl::producer<Dialogs::Key> SessionController::activeChatChanges() const {
|
2018-01-22 16:42:25 +00:00
|
|
|
return activeChatEntryChanges(
|
|
|
|
) | rpl::map([](const Dialogs::RowDescriptor &value) {
|
|
|
|
return value.key;
|
|
|
|
}) | rpl::distinct_until_changed();
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
auto SessionController::activeChatEntryValue() const
|
2018-01-22 16:42:25 +00:00
|
|
|
-> rpl::producer<Dialogs::RowDescriptor> {
|
|
|
|
return _activeChatEntry.value();
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
rpl::producer<Dialogs::Key> SessionController::activeChatValue() const {
|
2018-01-22 16:42:25 +00:00
|
|
|
return activeChatEntryValue(
|
|
|
|
) | rpl::map([](const Dialogs::RowDescriptor &value) {
|
|
|
|
return value.key;
|
|
|
|
}) | rpl::distinct_until_changed();
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::enableGifPauseReason(GifPauseReason reason) {
|
2017-04-07 18:10:49 +00:00
|
|
|
if (!(_gifPauseReasons & reason)) {
|
|
|
|
auto notify = (static_cast<int>(_gifPauseReasons) < static_cast<int>(reason));
|
|
|
|
_gifPauseReasons |= reason;
|
|
|
|
if (notify) {
|
2021-05-25 10:35:38 +00:00
|
|
|
_gifPauseLevelChanged.fire({});
|
2017-04-07 18:10:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::disableGifPauseReason(GifPauseReason reason) {
|
2017-04-07 18:10:49 +00:00
|
|
|
if (_gifPauseReasons & reason) {
|
2017-08-31 16:28:58 +00:00
|
|
|
_gifPauseReasons &= ~reason;
|
|
|
|
if (_gifPauseReasons < reason) {
|
2021-05-25 10:35:38 +00:00
|
|
|
_gifPauseLevelChanged.fire({});
|
2017-04-07 18:10:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
bool SessionController::isGifPausedAtLeastFor(GifPauseReason reason) const {
|
2017-04-07 18:10:49 +00:00
|
|
|
if (reason == GifPauseReason::Any) {
|
2019-09-03 15:24:51 +00:00
|
|
|
return (_gifPauseReasons != 0) || !widget()->isActive();
|
2017-04-07 18:10:49 +00:00
|
|
|
}
|
2019-09-03 15:24:51 +00:00
|
|
|
return (static_cast<int>(_gifPauseReasons) >= 2 * static_cast<int>(reason)) || !widget()->isActive();
|
2017-04-07 18:10:49 +00:00
|
|
|
}
|
|
|
|
|
2020-06-25 14:17:37 +00:00
|
|
|
void SessionController::floatPlayerAreaUpdated() {
|
|
|
|
if (const auto main = widget()->sessionContent()) {
|
|
|
|
main->floatPlayerAreaUpdated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-18 12:38:43 +00:00
|
|
|
void SessionController::materializeLocalDrafts() {
|
|
|
|
_materializeLocalDraftsRequests.fire({});
|
|
|
|
}
|
|
|
|
|
|
|
|
rpl::producer<> SessionController::materializeLocalDraftsRequests() const {
|
|
|
|
return _materializeLocalDraftsRequests.events();
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
int SessionController::dialogsSmallColumnWidth() const {
|
2022-09-29 10:33:17 +00:00
|
|
|
return st::defaultDialogRow.padding.left()
|
|
|
|
+ st::defaultDialogRow.photoSize
|
|
|
|
+ st::defaultDialogRow.padding.left();
|
2017-05-13 12:02:07 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
int SessionController::minimalThreeColumnWidth() const {
|
2022-06-07 18:05:37 +00:00
|
|
|
return (_isPrimary ? st::columnMinimalWidthLeft : 0)
|
2017-09-16 16:53:41 +00:00
|
|
|
+ st::columnMinimalWidthMain
|
|
|
|
+ st::columnMinimalWidthThird;
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
bool SessionController::forceWideDialogs() const {
|
2022-11-11 07:21:40 +00:00
|
|
|
if (_dialogsListDisplayForced.current()) {
|
2017-09-19 18:59:10 +00:00
|
|
|
return true;
|
2022-11-11 07:21:40 +00:00
|
|
|
} else if (_dialogsListFocused.current()) {
|
2017-09-19 18:59:10 +00:00
|
|
|
return true;
|
|
|
|
}
|
2020-06-10 18:08:17 +00:00
|
|
|
return !content()->isMainSectionShown();
|
2017-09-19 18:59:10 +00:00
|
|
|
}
|
|
|
|
|
2020-03-06 11:37:48 +00:00
|
|
|
auto SessionController::computeColumnLayout() const -> ColumnLayout {
|
2021-05-27 13:54:24 +00:00
|
|
|
auto layout = Adaptive::WindowLayout::OneColumn;
|
2017-04-09 18:06:06 +00:00
|
|
|
|
2020-03-06 11:37:48 +00:00
|
|
|
auto bodyWidth = widget()->bodyWidget()->width() - filtersWidth();
|
2017-09-19 18:59:10 +00:00
|
|
|
auto dialogsWidth = 0, chatWidth = 0, thirdWidth = 0;
|
|
|
|
|
2018-04-07 08:47:08 +00:00
|
|
|
auto useOneColumnLayout = [&] {
|
2017-09-16 16:53:41 +00:00
|
|
|
auto minimalNormal = st::columnMinimalWidthLeft
|
|
|
|
+ st::columnMinimalWidthMain;
|
2022-06-07 18:05:37 +00:00
|
|
|
if (_isPrimary && bodyWidth < minimalNormal) {
|
2017-04-09 18:06:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
2017-05-17 11:50:00 +00:00
|
|
|
|
2018-04-07 08:47:08 +00:00
|
|
|
auto useNormalLayout = [&] {
|
2017-09-16 16:53:41 +00:00
|
|
|
// Used if useSmallColumnLayout() == false.
|
|
|
|
if (bodyWidth < minimalThreeColumnWidth()) {
|
|
|
|
return true;
|
|
|
|
}
|
2020-06-25 12:16:09 +00:00
|
|
|
if (!Core::App().settings().tabbedSelectorSectionEnabled()
|
|
|
|
&& !Core::App().settings().thirdSectionInfoEnabled()) {
|
2017-09-16 16:53:41 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2017-04-09 18:06:06 +00:00
|
|
|
if (useOneColumnLayout()) {
|
2017-05-17 11:50:00 +00:00
|
|
|
dialogsWidth = chatWidth = bodyWidth;
|
2017-09-16 16:53:41 +00:00
|
|
|
} else if (useNormalLayout()) {
|
2021-05-27 13:54:24 +00:00
|
|
|
layout = Adaptive::WindowLayout::Normal;
|
2017-11-12 16:50:58 +00:00
|
|
|
dialogsWidth = countDialogsWidthFromRatio(bodyWidth);
|
2017-09-19 18:59:10 +00:00
|
|
|
accumulate_min(dialogsWidth, bodyWidth - st::columnMinimalWidthMain);
|
2017-05-17 11:50:00 +00:00
|
|
|
chatWidth = bodyWidth - dialogsWidth;
|
2017-09-16 16:53:41 +00:00
|
|
|
} else {
|
2021-05-27 13:54:24 +00:00
|
|
|
layout = Adaptive::WindowLayout::ThreeColumn;
|
2017-11-12 16:50:58 +00:00
|
|
|
dialogsWidth = countDialogsWidthFromRatio(bodyWidth);
|
|
|
|
thirdWidth = countThirdColumnWidthFromRatio(bodyWidth);
|
|
|
|
auto shrink = shrinkDialogsAndThirdColumns(
|
2017-09-16 16:53:41 +00:00
|
|
|
dialogsWidth,
|
2017-11-12 16:50:58 +00:00
|
|
|
thirdWidth,
|
|
|
|
bodyWidth);
|
|
|
|
dialogsWidth = shrink.dialogsWidth;
|
|
|
|
thirdWidth = shrink.thirdWidth;
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
chatWidth = bodyWidth - dialogsWidth - thirdWidth;
|
2017-04-09 18:06:06 +00:00
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
return { bodyWidth, dialogsWidth, chatWidth, thirdWidth, layout };
|
2017-04-09 18:06:06 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
int SessionController::countDialogsWidthFromRatio(int bodyWidth) const {
|
2022-06-07 18:05:37 +00:00
|
|
|
if (!_isPrimary) {
|
|
|
|
return 0;
|
|
|
|
}
|
2020-06-25 12:16:09 +00:00
|
|
|
auto result = qRound(bodyWidth * Core::App().settings().dialogsWidthRatio());
|
2017-11-12 16:50:58 +00:00
|
|
|
accumulate_max(result, st::columnMinimalWidthLeft);
|
2017-12-12 10:38:59 +00:00
|
|
|
// accumulate_min(result, st::columnMaximalWidthLeft);
|
2017-11-12 16:50:58 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
int SessionController::countThirdColumnWidthFromRatio(int bodyWidth) const {
|
2020-06-25 12:16:09 +00:00
|
|
|
auto result = Core::App().settings().thirdColumnWidth();
|
2017-11-12 16:50:58 +00:00
|
|
|
accumulate_max(result, st::columnMinimalWidthThird);
|
|
|
|
accumulate_min(result, st::columnMaximalWidthThird);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
SessionController::ShrinkResult SessionController::shrinkDialogsAndThirdColumns(
|
2017-11-12 16:50:58 +00:00
|
|
|
int dialogsWidth,
|
|
|
|
int thirdWidth,
|
|
|
|
int bodyWidth) const {
|
|
|
|
auto chatWidth = st::columnMinimalWidthMain;
|
|
|
|
if (dialogsWidth + thirdWidth + chatWidth <= bodyWidth) {
|
|
|
|
return { dialogsWidth, thirdWidth };
|
|
|
|
}
|
|
|
|
auto thirdWidthNew = ((bodyWidth - chatWidth) * thirdWidth)
|
|
|
|
/ (dialogsWidth + thirdWidth);
|
|
|
|
auto dialogsWidthNew = ((bodyWidth - chatWidth) * dialogsWidth)
|
|
|
|
/ (dialogsWidth + thirdWidth);
|
|
|
|
if (thirdWidthNew < st::columnMinimalWidthThird) {
|
|
|
|
thirdWidthNew = st::columnMinimalWidthThird;
|
|
|
|
dialogsWidthNew = bodyWidth - thirdWidthNew - chatWidth;
|
2022-06-07 18:05:37 +00:00
|
|
|
Assert(!_isPrimary || dialogsWidthNew >= st::columnMinimalWidthLeft);
|
|
|
|
} else if (_isPrimary && dialogsWidthNew < st::columnMinimalWidthLeft) {
|
2017-11-12 16:50:58 +00:00
|
|
|
dialogsWidthNew = st::columnMinimalWidthLeft;
|
|
|
|
thirdWidthNew = bodyWidth - dialogsWidthNew - chatWidth;
|
|
|
|
Assert(thirdWidthNew >= st::columnMinimalWidthThird);
|
|
|
|
}
|
|
|
|
return { dialogsWidthNew, thirdWidthNew };
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
bool SessionController::canShowThirdSection() const {
|
2017-04-09 18:06:06 +00:00
|
|
|
auto currentLayout = computeColumnLayout();
|
2017-11-16 16:43:52 +00:00
|
|
|
auto minimalExtendBy = minimalThreeColumnWidth()
|
2017-09-16 16:53:41 +00:00
|
|
|
- currentLayout.bodyWidth;
|
2019-09-03 15:24:51 +00:00
|
|
|
return (minimalExtendBy <= widget()->maximalExtendBy());
|
2017-05-17 11:50:00 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
bool SessionController::canShowThirdSectionWithoutResize() const {
|
2017-09-19 10:32:34 +00:00
|
|
|
auto currentWidth = computeColumnLayout().bodyWidth;
|
|
|
|
return currentWidth >= minimalThreeColumnWidth();
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
bool SessionController::takeThirdSectionFromLayer() {
|
2020-06-10 18:08:17 +00:00
|
|
|
return widget()->takeThirdSectionFromLayer();
|
2017-09-19 10:32:34 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::resizeForThirdSection() {
|
2021-05-26 23:20:27 +00:00
|
|
|
if (adaptive().isThreeColumn()) {
|
2017-05-17 11:50:00 +00:00
|
|
|
return;
|
2017-04-09 18:06:06 +00:00
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
|
2020-06-25 12:16:09 +00:00
|
|
|
auto &settings = Core::App().settings();
|
2017-11-14 08:15:14 +00:00
|
|
|
auto layout = computeColumnLayout();
|
2017-09-16 16:53:41 +00:00
|
|
|
auto tabbedSelectorSectionEnabled =
|
2020-06-25 12:16:09 +00:00
|
|
|
settings.tabbedSelectorSectionEnabled();
|
2017-09-16 16:53:41 +00:00
|
|
|
auto thirdSectionInfoEnabled =
|
2020-06-25 12:16:09 +00:00
|
|
|
settings.thirdSectionInfoEnabled();
|
|
|
|
settings.setTabbedSelectorSectionEnabled(false);
|
|
|
|
settings.setThirdSectionInfoEnabled(false);
|
2017-09-16 16:53:41 +00:00
|
|
|
|
2017-11-16 16:43:52 +00:00
|
|
|
auto wanted = countThirdColumnWidthFromRatio(layout.bodyWidth);
|
|
|
|
auto minimal = st::columnMinimalWidthThird;
|
|
|
|
auto extendBy = wanted;
|
|
|
|
auto extendedBy = [&] {
|
|
|
|
// Best - extend by third column without moving the window.
|
|
|
|
// Next - extend by minimal third column without moving.
|
|
|
|
// Next - show third column inside the window without moving.
|
|
|
|
// Last - extend with moving.
|
2019-09-03 15:24:51 +00:00
|
|
|
if (widget()->canExtendNoMove(wanted)) {
|
|
|
|
return widget()->tryToExtendWidthBy(wanted);
|
|
|
|
} else if (widget()->canExtendNoMove(minimal)) {
|
2017-11-16 16:43:52 +00:00
|
|
|
extendBy = minimal;
|
2019-09-03 15:24:51 +00:00
|
|
|
return widget()->tryToExtendWidthBy(minimal);
|
2017-11-16 16:43:52 +00:00
|
|
|
} else if (layout.bodyWidth >= minimalThreeColumnWidth()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2019-09-03 15:24:51 +00:00
|
|
|
return widget()->tryToExtendWidthBy(minimal);
|
2017-11-16 16:43:52 +00:00
|
|
|
}();
|
|
|
|
if (extendedBy) {
|
2020-06-25 12:16:09 +00:00
|
|
|
if (extendBy != settings.thirdColumnWidth()) {
|
|
|
|
settings.setThirdColumnWidth(extendBy);
|
2017-11-16 16:43:52 +00:00
|
|
|
}
|
|
|
|
auto newBodyWidth = layout.bodyWidth + extendedBy;
|
2020-06-25 12:16:09 +00:00
|
|
|
auto currentRatio = settings.dialogsWidthRatio();
|
|
|
|
settings.setDialogsWidthRatio(
|
2017-11-16 16:43:52 +00:00
|
|
|
(currentRatio * layout.bodyWidth) / newBodyWidth);
|
|
|
|
}
|
|
|
|
auto savedValue = (extendedBy == extendBy) ? -1 : extendedBy;
|
2020-06-25 12:16:09 +00:00
|
|
|
settings.setThirdSectionExtendedBy(savedValue);
|
2017-09-16 16:53:41 +00:00
|
|
|
|
2020-06-25 12:16:09 +00:00
|
|
|
settings.setTabbedSelectorSectionEnabled(
|
2017-09-16 16:53:41 +00:00
|
|
|
tabbedSelectorSectionEnabled);
|
2020-06-25 12:16:09 +00:00
|
|
|
settings.setThirdSectionInfoEnabled(
|
2017-09-16 16:53:41 +00:00
|
|
|
thirdSectionInfoEnabled);
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::closeThirdSection() {
|
2020-06-25 12:16:09 +00:00
|
|
|
auto &settings = Core::App().settings();
|
2019-09-03 15:24:51 +00:00
|
|
|
auto newWindowSize = widget()->size();
|
2017-09-16 16:53:41 +00:00
|
|
|
auto layout = computeColumnLayout();
|
2021-05-27 13:54:24 +00:00
|
|
|
if (layout.windowLayout == Adaptive::WindowLayout::ThreeColumn) {
|
2019-09-03 15:24:51 +00:00
|
|
|
auto noResize = widget()->isFullScreen()
|
|
|
|
|| widget()->isMaximized();
|
2020-06-25 12:16:09 +00:00
|
|
|
auto savedValue = settings.thirdSectionExtendedBy();
|
2017-11-16 16:43:52 +00:00
|
|
|
auto extendedBy = (savedValue == -1)
|
|
|
|
? layout.thirdWidth
|
|
|
|
: savedValue;
|
2017-09-16 16:53:41 +00:00
|
|
|
auto newBodyWidth = noResize
|
|
|
|
? layout.bodyWidth
|
2017-11-16 16:43:52 +00:00
|
|
|
: (layout.bodyWidth - extendedBy);
|
2020-06-25 12:16:09 +00:00
|
|
|
auto currentRatio = settings.dialogsWidthRatio();
|
|
|
|
settings.setDialogsWidthRatio(
|
2017-11-16 16:43:52 +00:00
|
|
|
(currentRatio * layout.bodyWidth) / newBodyWidth);
|
2017-09-16 16:53:41 +00:00
|
|
|
newWindowSize = QSize(
|
2019-09-03 15:24:51 +00:00
|
|
|
widget()->width() + (newBodyWidth - layout.bodyWidth),
|
|
|
|
widget()->height());
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
2020-06-25 12:16:09 +00:00
|
|
|
settings.setTabbedSelectorSectionEnabled(false);
|
|
|
|
settings.setThirdSectionInfoEnabled(false);
|
|
|
|
Core::App().saveSettingsDelayed();
|
2019-09-03 15:24:51 +00:00
|
|
|
if (widget()->size() != newWindowSize) {
|
|
|
|
widget()->resize(newWindowSize);
|
2017-09-16 16:53:41 +00:00
|
|
|
} else {
|
|
|
|
updateColumnLayout();
|
2017-04-09 18:06:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-22 11:30:56 +00:00
|
|
|
bool SessionController::canShowSeparateWindow(
|
|
|
|
not_null<PeerData*> peer) const {
|
2023-02-03 15:32:25 +00:00
|
|
|
return !peer->isForum() && peer->computeUnavailableReason().isEmpty();
|
2022-06-22 11:30:56 +00:00
|
|
|
}
|
|
|
|
|
2021-10-07 16:16:42 +00:00
|
|
|
void SessionController::showPeer(not_null<PeerData*> peer, MsgId msgId) {
|
|
|
|
const auto currentPeer = activeChatCurrent().peer();
|
|
|
|
if (peer && peer->isChannel() && currentPeer != peer) {
|
|
|
|
const auto clickedChannel = peer->asChannel();
|
|
|
|
if (!clickedChannel->isPublic()
|
|
|
|
&& !clickedChannel->amIn()
|
|
|
|
&& (!currentPeer->isChannel()
|
|
|
|
|| currentPeer->asChannel()->linkedChat()
|
|
|
|
!= clickedChannel)) {
|
|
|
|
Ui::ShowMultilineToast({
|
2022-06-15 03:25:18 +00:00
|
|
|
.parentOverride = Window::Show(this).toastParent(),
|
2021-10-07 16:16:42 +00:00
|
|
|
.text = {
|
|
|
|
.text = peer->isMegagroup()
|
|
|
|
? tr::lng_group_not_accessible(tr::now)
|
|
|
|
: tr::lng_channel_not_accessible(tr::now)
|
|
|
|
},
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
showPeerHistory(peer->id, SectionShow(), msgId);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
showPeerInfo(peer, SectionShow());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-21 14:10:56 +00:00
|
|
|
void SessionController::startOrJoinGroupCall(not_null<PeerData*> peer) {
|
|
|
|
startOrJoinGroupCall(peer, {});
|
|
|
|
}
|
|
|
|
|
2020-12-08 15:09:13 +00:00
|
|
|
void SessionController::startOrJoinGroupCall(
|
2020-12-14 12:52:18 +00:00
|
|
|
not_null<PeerData*> peer,
|
2022-08-08 15:19:04 +00:00
|
|
|
Calls::StartGroupCallArgs args) {
|
|
|
|
Core::App().calls().startOrJoinGroupCall(
|
|
|
|
std::make_shared<Show>(this),
|
|
|
|
peer,
|
|
|
|
args);
|
2020-12-08 15:09:13 +00:00
|
|
|
}
|
|
|
|
|
2021-11-16 07:26:35 +00:00
|
|
|
void SessionController::showCalendar(Dialogs::Key chat, QDate requestedDate) {
|
2022-10-27 07:14:49 +00:00
|
|
|
const auto topic = chat.topic();
|
|
|
|
const auto history = chat.owningHistory();
|
2021-11-15 09:09:44 +00:00
|
|
|
if (!history) {
|
|
|
|
return;
|
|
|
|
}
|
2018-02-21 21:17:36 +00:00
|
|
|
const auto currentPeerDate = [&] {
|
2022-10-27 07:14:49 +00:00
|
|
|
if (topic) {
|
|
|
|
if (const auto item = topic->lastMessage()) {
|
|
|
|
return base::unixtime::parse(item->date()).date();
|
|
|
|
}
|
|
|
|
return QDate();
|
|
|
|
} else if (history->scrollTopItem) {
|
2021-11-15 09:09:44 +00:00
|
|
|
return history->scrollTopItem->dateTime().date();
|
|
|
|
} else if (history->loadedAtTop()
|
|
|
|
&& !history->isEmpty()
|
|
|
|
&& history->peer->migrateFrom()) {
|
|
|
|
if (const auto migrated = history->owner().historyLoaded(history->peer->migrateFrom())) {
|
|
|
|
if (migrated->scrollTopItem) {
|
|
|
|
// We're up in the migrated history.
|
|
|
|
// So current date is the date of first message here.
|
|
|
|
return history->blocks.front()->messages.front()->dateTime().date();
|
2017-08-01 11:43:50 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-15 09:09:44 +00:00
|
|
|
} else if (const auto item = history->lastMessage()) {
|
|
|
|
return base::unixtime::parse(item->date()).date();
|
2017-08-01 11:43:50 +00:00
|
|
|
}
|
2019-05-28 12:33:42 +00:00
|
|
|
return QDate();
|
|
|
|
}();
|
2021-11-15 09:09:44 +00:00
|
|
|
const auto maxPeerDate = [&] {
|
2022-10-27 07:14:49 +00:00
|
|
|
if (topic) {
|
|
|
|
if (const auto item = topic->lastMessage()) {
|
|
|
|
return base::unixtime::parse(item->date()).date();
|
|
|
|
}
|
|
|
|
return QDate();
|
|
|
|
}
|
2021-11-15 09:09:44 +00:00
|
|
|
const auto check = history->peer->migrateTo()
|
|
|
|
? history->owner().historyLoaded(history->peer->migrateTo())
|
|
|
|
: history;
|
|
|
|
if (const auto item = check ? check->lastMessage() : nullptr) {
|
|
|
|
return base::unixtime::parse(item->date()).date();
|
2017-08-01 11:43:50 +00:00
|
|
|
}
|
2021-11-15 09:09:44 +00:00
|
|
|
return QDate();
|
|
|
|
}();
|
|
|
|
const auto minPeerDate = [&] {
|
2022-10-27 07:14:49 +00:00
|
|
|
const auto startDate = [&] {
|
2017-11-30 12:50:13 +00:00
|
|
|
// Telegram was launched in August 2013 :)
|
|
|
|
return QDate(2013, 8, 1);
|
|
|
|
};
|
2022-10-27 07:14:49 +00:00
|
|
|
if (topic) {
|
|
|
|
return base::unixtime::parse(topic->creationDate()).date();
|
|
|
|
} else if (const auto chat = history->peer->migrateFrom()) {
|
2021-11-15 09:09:44 +00:00
|
|
|
if (const auto history = chat->owner().historyLoaded(chat)) {
|
|
|
|
if (history->loadedAtTop()) {
|
|
|
|
if (!history->isEmpty()) {
|
|
|
|
return history->blocks.front()->messages.front()->dateTime().date();
|
2017-11-30 12:50:13 +00:00
|
|
|
}
|
2021-11-15 09:09:44 +00:00
|
|
|
} else {
|
|
|
|
return startDate();
|
2017-11-30 12:50:13 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-15 09:09:44 +00:00
|
|
|
}
|
|
|
|
if (history->loadedAtTop()) {
|
|
|
|
if (!history->isEmpty()) {
|
|
|
|
return history->blocks.front()->messages.front()->dateTime().date();
|
2017-08-01 11:43:50 +00:00
|
|
|
}
|
2021-11-15 09:09:44 +00:00
|
|
|
return QDate::currentDate();
|
2017-08-01 11:43:50 +00:00
|
|
|
}
|
2017-11-30 12:50:13 +00:00
|
|
|
return startDate();
|
2021-11-15 09:09:44 +00:00
|
|
|
}();
|
2019-05-28 12:33:42 +00:00
|
|
|
const auto highlighted = !requestedDate.isNull()
|
|
|
|
? requestedDate
|
|
|
|
: !currentPeerDate.isNull()
|
|
|
|
? currentPeerDate
|
|
|
|
: QDate::currentDate();
|
2021-11-16 05:52:13 +00:00
|
|
|
struct ButtonState {
|
|
|
|
enum class Type {
|
|
|
|
None,
|
|
|
|
Disabled,
|
|
|
|
Active,
|
|
|
|
};
|
|
|
|
Type type = Type::None;
|
|
|
|
style::complex_color disabledFg = style::complex_color([] {
|
|
|
|
auto result = st::attentionBoxButton.textFg->c;
|
|
|
|
result.setAlpha(result.alpha() / 2);
|
|
|
|
return result;
|
|
|
|
});
|
|
|
|
style::RoundButton disabled = st::attentionBoxButton;
|
|
|
|
};
|
|
|
|
const auto buttonState = std::make_shared<ButtonState>();
|
|
|
|
buttonState->disabled.textFg
|
|
|
|
= buttonState->disabled.textFgOver
|
|
|
|
= buttonState->disabledFg.color();
|
|
|
|
buttonState->disabled.ripple.color
|
|
|
|
= buttonState->disabled.textBgOver
|
|
|
|
= buttonState->disabled.textBg;
|
|
|
|
const auto selectionChanged = [=](
|
|
|
|
not_null<Ui::CalendarBox*> box,
|
|
|
|
std::optional<int> selected) {
|
|
|
|
if (!selected.has_value()) {
|
|
|
|
buttonState->type = ButtonState::Type::None;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto type = (*selected > 0)
|
|
|
|
? ButtonState::Type::Active
|
|
|
|
: ButtonState::Type::Disabled;
|
|
|
|
if (buttonState->type == type) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
buttonState->type = type;
|
|
|
|
box->clearButtons();
|
|
|
|
box->addButton(tr::lng_cancel(), [=] {
|
|
|
|
box->toggleSelectionMode(false);
|
|
|
|
});
|
|
|
|
auto text = tr::lng_profile_clear_history();
|
|
|
|
const auto button = box->addLeftButton(std::move(text), [=] {
|
2021-11-16 07:26:35 +00:00
|
|
|
const auto firstDate = box->selectedFirstDate();
|
|
|
|
const auto lastDate = box->selectedLastDate();
|
|
|
|
if (!firstDate.isNull()) {
|
|
|
|
auto confirm = Box<DeleteMessagesBox>(
|
|
|
|
history->peer,
|
|
|
|
firstDate,
|
|
|
|
lastDate);
|
|
|
|
confirm->setDeleteConfirmedCallback(crl::guard(box, [=] {
|
|
|
|
box->closeBox();
|
|
|
|
}));
|
|
|
|
box->getDelegate()->show(std::move(confirm));
|
|
|
|
}
|
2021-11-16 05:52:13 +00:00
|
|
|
}, (*selected > 0) ? st::attentionBoxButton : buttonState->disabled);
|
|
|
|
if (!*selected) {
|
|
|
|
button->setPointerCursor(false);
|
|
|
|
}
|
|
|
|
};
|
2022-07-19 11:29:04 +00:00
|
|
|
const auto weak = base::make_weak(this);
|
2022-10-27 07:14:49 +00:00
|
|
|
const auto weakTopic = base::make_weak(topic);
|
2022-07-19 11:29:04 +00:00
|
|
|
const auto jump = [=](const QDate &date) {
|
|
|
|
const auto open = [=](not_null<PeerData*> peer, MsgId id) {
|
|
|
|
if (const auto strong = weak.get()) {
|
2022-10-27 07:14:49 +00:00
|
|
|
if (!topic) {
|
|
|
|
strong->showPeerHistory(
|
|
|
|
peer,
|
|
|
|
SectionShow::Way::Forward,
|
|
|
|
id);
|
|
|
|
} else if (const auto strongTopic = weakTopic.get()) {
|
2022-10-27 07:35:35 +00:00
|
|
|
strong->showTopic(
|
|
|
|
strongTopic,
|
2022-10-27 07:14:49 +00:00
|
|
|
id,
|
|
|
|
SectionShow::Way::Forward);
|
|
|
|
strong->hideLayer(anim::type::normal);
|
|
|
|
}
|
2022-07-19 11:29:04 +00:00
|
|
|
}
|
|
|
|
};
|
2022-10-27 07:14:49 +00:00
|
|
|
if (!topic || weakTopic) {
|
|
|
|
session().api().resolveJumpToDate(chat, date, open);
|
|
|
|
}
|
2022-07-19 11:29:04 +00:00
|
|
|
};
|
2021-11-11 11:44:12 +00:00
|
|
|
show(Box<Ui::CalendarBox>(Ui::CalendarBoxArgs{
|
|
|
|
.month = highlighted,
|
|
|
|
.highlighted = highlighted,
|
2022-07-19 11:29:04 +00:00
|
|
|
.callback = [=](const QDate &date) { jump(date); },
|
2021-11-15 09:09:44 +00:00
|
|
|
.minDate = minPeerDate,
|
|
|
|
.maxDate = maxPeerDate,
|
|
|
|
.allowsSelection = history->peer->isUser(),
|
2021-11-16 05:52:13 +00:00
|
|
|
.selectionChanged = selectionChanged,
|
2021-11-11 11:44:12 +00:00
|
|
|
}));
|
2017-08-01 11:43:50 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::showPassportForm(const Passport::FormRequest &request) {
|
2018-04-06 18:47:29 +00:00
|
|
|
_passportForm = std::make_unique<Passport::FormController>(
|
|
|
|
this,
|
|
|
|
request);
|
|
|
|
_passportForm->show();
|
2018-03-18 08:51:14 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::clearPassportForm() {
|
2018-04-06 18:47:29 +00:00
|
|
|
_passportForm = nullptr;
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
2021-02-15 17:37:22 +00:00
|
|
|
void SessionController::showChooseReportMessages(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
Ui::ReportReason reason,
|
|
|
|
Fn<void(MessageIdsList)> done) {
|
|
|
|
content()->showChooseReportMessages(peer, reason, std::move(done));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SessionController::clearChooseReportMessages() {
|
|
|
|
content()->clearChooseReportMessages();
|
|
|
|
}
|
|
|
|
|
2023-02-03 15:32:25 +00:00
|
|
|
void SessionController::showInNewWindow(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
MsgId msgId) {
|
|
|
|
if (!canShowSeparateWindow(peer)) {
|
|
|
|
showThread(
|
|
|
|
peer->owner().history(peer),
|
|
|
|
msgId,
|
|
|
|
Window::SectionShow::Way::ClearStack);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto active = activeChatCurrent();
|
|
|
|
const auto fromActive = active.history()
|
|
|
|
? (active.history()->peer == peer)
|
|
|
|
: false;
|
|
|
|
const auto toSeparate = [=] {
|
|
|
|
Core::App().ensureSeparateWindowForPeer(peer, msgId);
|
|
|
|
};
|
|
|
|
if (fromActive) {
|
|
|
|
window().preventOrInvoke([=] {
|
|
|
|
clearSectionStack();
|
|
|
|
toSeparate();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
toSeparate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-24 15:10:25 +00:00
|
|
|
void SessionController::toggleChooseChatTheme(not_null<PeerData*> peer) {
|
|
|
|
content()->toggleChooseChatTheme(peer);
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::updateColumnLayout() {
|
2020-06-10 18:08:17 +00:00
|
|
|
content()->updateColumnLayout();
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::showPeerHistory(
|
2017-09-16 16:53:41 +00:00
|
|
|
PeerId peerId,
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms,
|
|
|
|
MsgId msgId) {
|
2023-01-27 15:56:43 +00:00
|
|
|
content()->showHistory(peerId, params, msgId);
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
|
|
|
|
2022-10-28 12:30:59 +00:00
|
|
|
void SessionController::showMessage(
|
2022-11-01 07:18:56 +00:00
|
|
|
not_null<const HistoryItem*> item,
|
|
|
|
const SectionShow ¶ms) {
|
2021-06-15 23:06:22 +00:00
|
|
|
_window->invokeForSessionController(
|
2022-11-01 07:18:56 +00:00
|
|
|
&item->history()->session().account(),
|
2022-06-10 10:59:19 +00:00
|
|
|
item->history()->peer,
|
|
|
|
[&](not_null<SessionController*> controller) {
|
2022-01-26 09:41:27 +00:00
|
|
|
if (item->isScheduled()) {
|
|
|
|
controller->showSection(
|
|
|
|
std::make_shared<HistoryView::ScheduledMemento>(
|
2022-10-28 12:30:59 +00:00
|
|
|
item->history()),
|
2022-11-01 07:18:56 +00:00
|
|
|
params);
|
2022-01-26 09:41:27 +00:00
|
|
|
} else {
|
2022-11-01 07:18:56 +00:00
|
|
|
controller->content()->showMessage(item, params);
|
2022-01-26 09:41:27 +00:00
|
|
|
}
|
2023-01-18 10:53:41 +00:00
|
|
|
if (params.activation != anim::activation::background) {
|
|
|
|
controller->window().activate();
|
|
|
|
}
|
2021-06-15 23:06:22 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-06-18 06:39:10 +00:00
|
|
|
void SessionController::cancelUploadLayer(not_null<HistoryItem*> item) {
|
|
|
|
const auto itemId = item->fullId();
|
|
|
|
session().uploader().pause(itemId);
|
2022-03-14 09:15:27 +00:00
|
|
|
const auto stopUpload = [=](Fn<void()> close) {
|
2021-06-18 06:39:10 +00:00
|
|
|
auto &data = session().data();
|
|
|
|
if (const auto item = data.message(itemId)) {
|
|
|
|
if (!item->isEditingMedia()) {
|
|
|
|
const auto history = item->history();
|
|
|
|
item->destroy();
|
|
|
|
history->requestChatListMessage();
|
|
|
|
} else {
|
|
|
|
item->returnSavedMedia();
|
|
|
|
session().uploader().cancel(item->fullId());
|
|
|
|
}
|
|
|
|
data.sendHistoryChangeNotifications();
|
|
|
|
}
|
|
|
|
session().uploader().unpause();
|
2022-03-14 09:15:27 +00:00
|
|
|
close();
|
2021-06-18 06:39:10 +00:00
|
|
|
};
|
2022-03-14 09:15:27 +00:00
|
|
|
const auto continueUpload = [=](Fn<void()> close) {
|
2021-06-18 06:39:10 +00:00
|
|
|
session().uploader().unpause();
|
2022-03-14 09:15:27 +00:00
|
|
|
close();
|
2021-06-18 06:39:10 +00:00
|
|
|
};
|
|
|
|
|
2022-02-27 08:23:20 +00:00
|
|
|
show(Ui::MakeConfirmBox({
|
|
|
|
.text = tr::lng_selected_cancel_sure_this(),
|
|
|
|
.confirmed = stopUpload,
|
|
|
|
.cancelled = continueUpload,
|
2022-03-14 09:15:27 +00:00
|
|
|
.confirmText = tr::lng_box_yes(),
|
|
|
|
.cancelText = tr::lng_box_no(),
|
2022-02-27 08:23:20 +00:00
|
|
|
}));
|
2021-06-18 06:39:10 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::showSection(
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_ptr<SectionMemento> memento,
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms) {
|
2022-09-27 12:05:47 +00:00
|
|
|
if (!params.thirdColumn
|
|
|
|
&& widget()->showSectionInExistingLayer(memento.get(), params)) {
|
2017-10-03 13:05:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-06-10 18:08:17 +00:00
|
|
|
content()->showSection(std::move(memento), params);
|
2017-09-15 17:34:41 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::showBackFromStack(const SectionShow ¶ms) {
|
2022-12-28 08:44:01 +00:00
|
|
|
const auto bad = [&] {
|
|
|
|
// If we show a currently-being-destroyed topic, then
|
|
|
|
// skip it and show back one more.
|
|
|
|
const auto topic = _activeChatEntry.current().key.topic();
|
|
|
|
return topic && topic->forum()->topicDeleted(topic->rootId());
|
|
|
|
};
|
|
|
|
do {
|
|
|
|
content()->showBackFromStack(params);
|
|
|
|
} while (bad());
|
2017-09-15 17:34:41 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::showSpecialLayer(
|
2019-09-18 11:19:05 +00:00
|
|
|
object_ptr<Ui::LayerWidget> &&layer,
|
2017-09-20 10:23:57 +00:00
|
|
|
anim::type animated) {
|
2020-06-10 18:08:17 +00:00
|
|
|
widget()->showSpecialLayer(std::move(layer), animated);
|
2017-09-15 17:34:41 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 05:48:39 +00:00
|
|
|
void SessionController::showLayer(
|
|
|
|
std::unique_ptr<Ui::LayerWidget> &&layer,
|
|
|
|
Ui::LayerOptions options,
|
|
|
|
anim::type animated) {
|
2021-02-21 03:48:32 +00:00
|
|
|
_window->showLayer(std::move(layer), options, animated);
|
2021-02-17 05:48:39 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void SessionController::removeLayerBlackout() {
|
2020-06-10 18:08:17 +00:00
|
|
|
widget()->ui_removeLayerBlackout();
|
2018-09-06 14:58:43 +00:00
|
|
|
}
|
|
|
|
|
2022-11-30 13:28:09 +00:00
|
|
|
bool SessionController::isLayerShown() const {
|
|
|
|
return _window->isLayerShown();
|
|
|
|
}
|
|
|
|
|
2020-06-10 18:08:17 +00:00
|
|
|
not_null<MainWidget*> SessionController::content() const {
|
|
|
|
return widget()->sessionContent();
|
2017-09-15 17:34:41 +00:00
|
|
|
}
|
|
|
|
|
2020-03-03 12:07:22 +00:00
|
|
|
int SessionController::filtersWidth() const {
|
|
|
|
return _filters ? st::windowFiltersWidth : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
rpl::producer<FilterId> SessionController::activeChatsFilter() const {
|
|
|
|
return _activeChatsFilter.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
FilterId SessionController::activeChatsFilterCurrent() const {
|
|
|
|
return _activeChatsFilter.current();
|
|
|
|
}
|
|
|
|
|
2022-09-26 13:37:32 +00:00
|
|
|
void SessionController::setActiveChatsFilter(
|
|
|
|
FilterId id,
|
|
|
|
const SectionShow ¶ms) {
|
2020-05-12 08:18:52 +00:00
|
|
|
if (activeChatsFilterCurrent() != id) {
|
|
|
|
resetFakeUnreadWhileOpened();
|
|
|
|
}
|
2020-03-27 09:41:54 +00:00
|
|
|
_activeChatsFilter.force_assign(id);
|
2020-03-20 13:12:13 +00:00
|
|
|
if (id) {
|
2022-10-19 12:09:45 +00:00
|
|
|
closeForum();
|
2020-03-20 13:12:13 +00:00
|
|
|
closeFolder();
|
|
|
|
}
|
2021-05-26 23:20:27 +00:00
|
|
|
if (adaptive().isOneColumn()) {
|
2022-09-26 13:37:32 +00:00
|
|
|
clearSectionStack(params);
|
2020-03-20 13:23:52 +00:00
|
|
|
}
|
2020-03-03 12:07:22 +00:00
|
|
|
}
|
|
|
|
|
2021-02-03 01:17:03 +00:00
|
|
|
void SessionController::showAddContact() {
|
|
|
|
_window->show(
|
|
|
|
Box<AddContactBox>(&session()),
|
|
|
|
Ui::LayerOption::KeepOther);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SessionController::showNewGroup() {
|
|
|
|
_window->show(
|
|
|
|
Box<GroupInfoBox>(this, GroupInfoBox::Type::Group),
|
|
|
|
Ui::LayerOption::KeepOther);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SessionController::showNewChannel() {
|
|
|
|
_window->show(
|
|
|
|
Box<GroupInfoBox>(this, GroupInfoBox::Type::Channel),
|
|
|
|
Ui::LayerOption::KeepOther);
|
|
|
|
}
|
|
|
|
|
2021-05-27 13:54:24 +00:00
|
|
|
Window::Adaptive &SessionController::adaptive() const {
|
2021-05-26 23:16:12 +00:00
|
|
|
return _window->adaptive();
|
|
|
|
}
|
|
|
|
|
2022-03-01 15:38:45 +00:00
|
|
|
void SessionController::setConnectingBottomSkip(int skip) {
|
|
|
|
_connectingBottomSkip = skip;
|
|
|
|
}
|
|
|
|
|
|
|
|
rpl::producer<int> SessionController::connectingBottomSkipValue() const {
|
|
|
|
return _connectingBottomSkip.value();
|
|
|
|
}
|
|
|
|
|
2022-09-14 10:45:23 +00:00
|
|
|
void SessionController::stickerOrEmojiChosen(FileChosen chosen) {
|
|
|
|
_stickerOrEmojiChosen.fire(std::move(chosen));
|
|
|
|
}
|
|
|
|
|
|
|
|
auto SessionController::stickerOrEmojiChosen() const
|
|
|
|
-> rpl::producer<FileChosen> {
|
|
|
|
return _stickerOrEmojiChosen.events();
|
|
|
|
}
|
|
|
|
|
2021-06-13 07:37:52 +00:00
|
|
|
QPointer<Ui::BoxContent> SessionController::show(
|
|
|
|
object_ptr<Ui::BoxContent> content,
|
|
|
|
Ui::LayerOptions options,
|
|
|
|
anim::type animated) {
|
|
|
|
return _window->show(std::move(content), options, animated);
|
|
|
|
}
|
|
|
|
|
2022-02-20 22:40:22 +00:00
|
|
|
void SessionController::hideLayer(anim::type animated) {
|
2022-06-07 18:05:37 +00:00
|
|
|
_window->hideLayer(animated);
|
2022-02-20 22:40:22 +00:00
|
|
|
}
|
|
|
|
|
2023-01-10 18:56:20 +00:00
|
|
|
void SessionController::showToast(TextWithEntities &&text) {
|
|
|
|
Ui::ShowMultilineToast({
|
|
|
|
.parentOverride = Window::Show(this).toastParent(),
|
|
|
|
.text = std::move(text),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-06-14 06:33:54 +00:00
|
|
|
void SessionController::openPhoto(
|
|
|
|
not_null<PhotoData*> photo,
|
2022-10-11 15:08:19 +00:00
|
|
|
FullMsgId contextId,
|
|
|
|
MsgId topicRootId) {
|
2021-06-14 06:33:54 +00:00
|
|
|
_window->openInMediaView(Media::View::OpenRequest(
|
2021-06-15 18:54:31 +00:00
|
|
|
this,
|
2021-06-14 06:33:54 +00:00
|
|
|
photo,
|
2022-10-11 15:08:19 +00:00
|
|
|
session().data().message(contextId),
|
|
|
|
topicRootId));
|
2021-06-14 06:33:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SessionController::openPhoto(
|
|
|
|
not_null<PhotoData*> photo,
|
|
|
|
not_null<PeerData*> peer) {
|
2021-06-15 18:54:31 +00:00
|
|
|
_window->openInMediaView(Media::View::OpenRequest(this, photo, peer));
|
2021-06-14 06:33:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SessionController::openDocument(
|
|
|
|
not_null<DocumentData*> document,
|
2021-06-16 21:31:15 +00:00
|
|
|
FullMsgId contextId,
|
2022-10-11 15:08:19 +00:00
|
|
|
MsgId topicRootId,
|
2021-06-16 21:31:15 +00:00
|
|
|
bool showInMediaView) {
|
|
|
|
if (showInMediaView) {
|
|
|
|
_window->openInMediaView(Media::View::OpenRequest(
|
2021-06-15 18:54:31 +00:00
|
|
|
this,
|
2021-06-16 21:31:15 +00:00
|
|
|
document,
|
2022-10-11 15:08:19 +00:00
|
|
|
session().data().message(contextId),
|
|
|
|
topicRootId));
|
2021-06-16 21:31:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-06-16 21:33:51 +00:00
|
|
|
Data::ResolveDocument(
|
|
|
|
this,
|
|
|
|
document,
|
2022-10-11 15:08:19 +00:00
|
|
|
session().data().message(contextId),
|
|
|
|
topicRootId);
|
2021-06-14 06:33:54 +00:00
|
|
|
}
|
|
|
|
|
2021-08-26 13:25:48 +00:00
|
|
|
auto SessionController::cachedChatThemeValue(
|
2021-10-22 18:14:44 +00:00
|
|
|
const Data::CloudTheme &data,
|
|
|
|
Data::CloudThemeType type)
|
2021-08-26 15:02:21 +00:00
|
|
|
-> rpl::producer<std::shared_ptr<Ui::ChatTheme>> {
|
2021-10-22 18:14:44 +00:00
|
|
|
const auto key = Ui::ChatThemeKey{
|
|
|
|
data.id,
|
|
|
|
(type == Data::CloudThemeType::Dark),
|
|
|
|
};
|
|
|
|
const auto settings = data.settings.find(type);
|
|
|
|
if (!key
|
|
|
|
|| (settings == end(data.settings))
|
|
|
|
|| !settings->second.paper
|
|
|
|
|| settings->second.paper->backgroundColors().empty()) {
|
2021-08-26 13:25:48 +00:00
|
|
|
return rpl::single(_defaultChatTheme);
|
2021-08-16 13:07:43 +00:00
|
|
|
}
|
2021-08-26 13:25:48 +00:00
|
|
|
const auto i = _customChatThemes.find(key);
|
2021-09-19 15:15:46 +00:00
|
|
|
if (i != end(_customChatThemes)) {
|
|
|
|
if (auto strong = i->second.theme.lock()) {
|
2021-09-24 15:10:25 +00:00
|
|
|
pushLastUsedChatTheme(strong);
|
2021-09-19 15:15:46 +00:00
|
|
|
return rpl::single(std::move(strong));
|
|
|
|
}
|
2021-08-16 13:07:43 +00:00
|
|
|
}
|
2021-09-19 15:15:46 +00:00
|
|
|
if (i == end(_customChatThemes) || !i->second.caching) {
|
2021-10-22 18:14:44 +00:00
|
|
|
cacheChatTheme(data, type);
|
2021-08-13 15:39:50 +00:00
|
|
|
}
|
2021-09-10 19:29:30 +00:00
|
|
|
const auto limit = Data::CloudThemes::TestingColors() ? (1 << 20) : 1;
|
2021-08-26 13:25:48 +00:00
|
|
|
using namespace rpl::mappers;
|
|
|
|
return rpl::single(
|
|
|
|
_defaultChatTheme
|
|
|
|
) | rpl::then(_cachedThemesStream.events(
|
2021-08-26 15:02:21 +00:00
|
|
|
) | rpl::filter([=](const std::shared_ptr<Ui::ChatTheme> &theme) {
|
2021-09-19 15:15:46 +00:00
|
|
|
if (theme->key() != key) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-09-24 15:10:25 +00:00
|
|
|
pushLastUsedChatTheme(theme);
|
2021-09-19 15:15:46 +00:00
|
|
|
return true;
|
2021-09-10 19:29:30 +00:00
|
|
|
}) | rpl::take(limit));
|
2021-08-16 13:07:43 +00:00
|
|
|
}
|
|
|
|
|
2021-09-24 15:10:25 +00:00
|
|
|
void SessionController::pushLastUsedChatTheme(
|
2021-09-19 15:15:46 +00:00
|
|
|
const std::shared_ptr<Ui::ChatTheme> &theme) {
|
|
|
|
const auto i = ranges::find(_lastUsedCustomChatThemes, theme);
|
|
|
|
if (i == end(_lastUsedCustomChatThemes)) {
|
|
|
|
if (_lastUsedCustomChatThemes.size() >= kCustomThemesInMemory) {
|
|
|
|
_lastUsedCustomChatThemes.pop_back();
|
|
|
|
}
|
|
|
|
_lastUsedCustomChatThemes.push_front(theme);
|
|
|
|
} else if (i != begin(_lastUsedCustomChatThemes)) {
|
|
|
|
std::rotate(begin(_lastUsedCustomChatThemes), i, i + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-18 10:18:17 +00:00
|
|
|
not_null<Ui::ChatTheme*> SessionController::currentChatTheme() const {
|
|
|
|
if (const auto custom = content()->customChatTheme()) {
|
|
|
|
return custom;
|
|
|
|
}
|
|
|
|
return defaultChatTheme().get();
|
|
|
|
}
|
|
|
|
|
2021-08-27 20:44:47 +00:00
|
|
|
void SessionController::setChatStyleTheme(
|
|
|
|
const std::shared_ptr<Ui::ChatTheme> &theme) {
|
|
|
|
if (_chatStyleTheme.lock() == theme) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_chatStyleTheme = theme;
|
|
|
|
_chatStyle->apply(theme.get());
|
|
|
|
}
|
|
|
|
|
2021-09-10 19:29:30 +00:00
|
|
|
void SessionController::clearCachedChatThemes() {
|
|
|
|
_customChatThemes.clear();
|
|
|
|
}
|
|
|
|
|
2021-09-24 15:10:25 +00:00
|
|
|
void SessionController::overridePeerTheme(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
std::shared_ptr<Ui::ChatTheme> theme) {
|
|
|
|
_peerThemeOverride = PeerThemeOverride{
|
|
|
|
peer,
|
|
|
|
theme ? theme : _defaultChatTheme,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void SessionController::clearPeerThemeOverride(not_null<PeerData*> peer) {
|
|
|
|
if (_peerThemeOverride.current().peer == peer.get()) {
|
|
|
|
_peerThemeOverride = PeerThemeOverride();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-26 15:02:21 +00:00
|
|
|
void SessionController::pushDefaultChatBackground() {
|
|
|
|
const auto background = Theme::Background();
|
|
|
|
const auto &paper = background->paper();
|
|
|
|
_defaultChatTheme->setBackground({
|
|
|
|
.prepared = background->prepared(),
|
|
|
|
.preparedForTiled = background->preparedForTiled(),
|
|
|
|
.gradientForFill = background->gradientForFill(),
|
|
|
|
.colorForFill = background->colorForFill(),
|
|
|
|
.colors = paper.backgroundColors(),
|
|
|
|
.patternOpacity = paper.patternOpacity(),
|
|
|
|
.gradientRotation = paper.gradientRotation(),
|
|
|
|
.isPattern = paper.isPattern(),
|
|
|
|
.tile = background->tile(),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-10-22 18:14:44 +00:00
|
|
|
void SessionController::cacheChatTheme(
|
|
|
|
const Data::CloudTheme &data,
|
|
|
|
Data::CloudThemeType type) {
|
2021-08-26 13:25:48 +00:00
|
|
|
Expects(data.id != 0);
|
2021-08-26 15:02:21 +00:00
|
|
|
|
2021-10-22 18:14:44 +00:00
|
|
|
const auto dark = (type == Data::CloudThemeType::Dark);
|
|
|
|
const auto key = Ui::ChatThemeKey{ data.id, dark };
|
|
|
|
const auto i = data.settings.find(type);
|
|
|
|
Assert(i != end(data.settings));
|
|
|
|
const auto &paper = i->second.paper;
|
|
|
|
Assert(paper.has_value());
|
|
|
|
Assert(!paper->backgroundColors().empty());
|
|
|
|
const auto document = paper->document();
|
2021-08-27 11:32:18 +00:00
|
|
|
const auto media = document ? document->createMediaView() : nullptr;
|
2021-10-22 18:14:44 +00:00
|
|
|
paper->loadDocument();
|
2021-09-19 15:15:46 +00:00
|
|
|
auto &theme = [&]() -> CachedTheme& {
|
|
|
|
const auto i = _customChatThemes.find(key);
|
|
|
|
if (i != end(_customChatThemes)) {
|
|
|
|
i->second.media = media;
|
2021-10-22 18:14:44 +00:00
|
|
|
i->second.paper = *paper;
|
2021-09-19 15:15:46 +00:00
|
|
|
i->second.caching = true;
|
|
|
|
return i->second;
|
|
|
|
}
|
|
|
|
return _customChatThemes.emplace(
|
|
|
|
key,
|
|
|
|
CachedTheme{
|
|
|
|
.media = media,
|
2021-10-22 18:14:44 +00:00
|
|
|
.paper = *paper,
|
2021-09-19 15:15:46 +00:00
|
|
|
.caching = true,
|
|
|
|
}).first->second;
|
|
|
|
}();
|
2021-08-26 15:02:21 +00:00
|
|
|
auto descriptor = Ui::ChatThemeDescriptor{
|
2021-10-22 18:14:44 +00:00
|
|
|
.key = key,
|
2021-08-27 11:32:18 +00:00
|
|
|
.preparePalette = PreparePaletteCallback(
|
2021-10-22 18:14:44 +00:00
|
|
|
dark,
|
|
|
|
i->second.accentColor),
|
2021-09-06 10:18:14 +00:00
|
|
|
.backgroundData = backgroundData(theme),
|
2021-10-22 18:14:44 +00:00
|
|
|
.bubblesData = PrepareBubblesData(data, type),
|
|
|
|
.basedOnDark = dark,
|
2021-08-26 15:02:21 +00:00
|
|
|
};
|
2021-08-27 11:32:18 +00:00
|
|
|
crl::async([
|
|
|
|
this,
|
|
|
|
descriptor = std::move(descriptor),
|
|
|
|
weak = base::make_weak(this)
|
2021-08-28 05:51:39 +00:00
|
|
|
]() mutable {
|
2021-08-27 11:32:18 +00:00
|
|
|
crl::on_main(weak,[
|
2021-08-26 13:25:48 +00:00
|
|
|
this,
|
2021-08-26 15:02:21 +00:00
|
|
|
result = std::make_shared<Ui::ChatTheme>(std::move(descriptor))
|
2021-08-26 13:25:48 +00:00
|
|
|
]() mutable {
|
2022-02-01 12:24:28 +00:00
|
|
|
result->finishCreateOnMain();
|
2021-08-27 11:32:18 +00:00
|
|
|
cacheChatThemeDone(std::move(result));
|
2021-08-13 18:18:06 +00:00
|
|
|
});
|
2021-08-16 13:07:43 +00:00
|
|
|
});
|
2021-08-27 11:32:18 +00:00
|
|
|
if (media && media->loaded(true)) {
|
|
|
|
theme.media = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SessionController::cacheChatThemeDone(
|
|
|
|
std::shared_ptr<Ui::ChatTheme> result) {
|
|
|
|
Expects(result != nullptr);
|
|
|
|
|
|
|
|
const auto key = result->key();
|
|
|
|
const auto i = _customChatThemes.find(key);
|
|
|
|
if (i == end(_customChatThemes)) {
|
|
|
|
return;
|
|
|
|
}
|
2021-09-19 15:15:46 +00:00
|
|
|
i->second.caching = false;
|
2021-08-27 11:32:18 +00:00
|
|
|
i->second.theme = result;
|
|
|
|
if (i->second.media) {
|
|
|
|
if (i->second.media->loaded(true)) {
|
|
|
|
updateCustomThemeBackground(i->second);
|
|
|
|
} else {
|
|
|
|
session().downloaderTaskFinished(
|
|
|
|
) | rpl::filter([=] {
|
|
|
|
const auto i = _customChatThemes.find(key);
|
|
|
|
Assert(i != end(_customChatThemes));
|
|
|
|
return !i->second.media || i->second.media->loaded(true);
|
|
|
|
}) | rpl::start_with_next([=] {
|
|
|
|
const auto i = _customChatThemes.find(key);
|
|
|
|
Assert(i != end(_customChatThemes));
|
|
|
|
updateCustomThemeBackground(i->second);
|
|
|
|
}, i->second.lifetime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_cachedThemesStream.fire(std::move(result));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SessionController::updateCustomThemeBackground(CachedTheme &theme) {
|
|
|
|
const auto guard = gsl::finally([&] {
|
|
|
|
theme.lifetime.destroy();
|
|
|
|
theme.media = nullptr;
|
|
|
|
});
|
2021-09-19 15:15:46 +00:00
|
|
|
const auto strong = theme.theme.lock();
|
|
|
|
if (!theme.media || !strong || !theme.media->loaded(true)) {
|
2021-08-27 11:32:18 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-09-19 15:15:46 +00:00
|
|
|
const auto key = strong->key();
|
2021-08-27 11:32:18 +00:00
|
|
|
const auto weak = base::make_weak(this);
|
2021-09-06 10:18:14 +00:00
|
|
|
crl::async([=, data = backgroundData(theme, false)] {
|
|
|
|
crl::on_main(weak, [
|
|
|
|
=,
|
|
|
|
result = Ui::PrepareBackgroundImage(data)
|
|
|
|
]() mutable {
|
2021-08-27 11:32:18 +00:00
|
|
|
const auto i = _customChatThemes.find(key);
|
|
|
|
if (i != end(_customChatThemes)) {
|
2021-09-19 15:15:46 +00:00
|
|
|
if (const auto strong = i->second.theme.lock()) {
|
|
|
|
strong->updateBackgroundImageFrom(std::move(result));
|
|
|
|
}
|
2021-08-27 11:32:18 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-09-06 10:18:14 +00:00
|
|
|
Ui::ChatThemeBackgroundData SessionController::backgroundData(
|
2021-08-27 11:32:18 +00:00
|
|
|
CachedTheme &theme,
|
2021-09-06 10:18:14 +00:00
|
|
|
bool generateGradient) const {
|
2021-08-27 11:32:18 +00:00
|
|
|
const auto &paper = theme.paper;
|
|
|
|
const auto &media = theme.media;
|
|
|
|
const auto paperPath = media ? media->owner()->filepath() : QString();
|
|
|
|
const auto paperBytes = media ? media->bytes() : QByteArray();
|
|
|
|
const auto gzipSvg = media && media->owner()->isPatternWallPaperSVG();
|
|
|
|
const auto &colors = paper.backgroundColors();
|
|
|
|
const auto isPattern = paper.isPattern();
|
|
|
|
const auto patternOpacity = paper.patternOpacity();
|
|
|
|
const auto isBlurred = paper.isBlurred();
|
|
|
|
const auto gradientRotation = paper.gradientRotation();
|
2021-09-06 10:18:14 +00:00
|
|
|
return {
|
|
|
|
.path = paperPath,
|
|
|
|
.bytes = paperBytes,
|
|
|
|
.gzipSvg = gzipSvg,
|
|
|
|
.colors = colors,
|
|
|
|
.isPattern = isPattern,
|
|
|
|
.patternOpacity = patternOpacity,
|
|
|
|
.isBlurred = isBlurred,
|
|
|
|
.generateGradient = generateGradient,
|
|
|
|
.gradientRotation = gradientRotation,
|
2021-08-27 11:32:18 +00:00
|
|
|
};
|
2021-08-13 18:18:06 +00:00
|
|
|
}
|
|
|
|
|
2021-08-26 13:25:48 +00:00
|
|
|
HistoryView::PaintContext SessionController::preparePaintContext(
|
|
|
|
PaintContextArgs &&args) {
|
|
|
|
const auto visibleAreaTopLocal = content()->mapFromGlobal(
|
|
|
|
QPoint(0, args.visibleAreaTopGlobal)).y();
|
|
|
|
const auto viewport = QRect(
|
|
|
|
0,
|
|
|
|
args.visibleAreaTop - visibleAreaTopLocal,
|
|
|
|
args.visibleAreaWidth,
|
|
|
|
content()->height());
|
2021-08-27 20:44:47 +00:00
|
|
|
return args.theme->preparePaintContext(
|
|
|
|
_chatStyle.get(),
|
|
|
|
viewport,
|
2022-09-09 16:09:51 +00:00
|
|
|
args.clip,
|
|
|
|
isGifPausedAtLeastFor(GifPauseReason::Any));
|
2021-08-16 13:07:43 +00:00
|
|
|
}
|
|
|
|
|
2022-05-23 14:46:15 +00:00
|
|
|
void SessionController::setPremiumRef(const QString &ref) {
|
|
|
|
_premiumRef = ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString SessionController::premiumRef() const {
|
|
|
|
return _premiumRef;
|
|
|
|
}
|
|
|
|
|
2022-11-30 12:55:51 +00:00
|
|
|
bool SessionController::contentOverlapped(QWidget *w, QPaintEvent *e) {
|
|
|
|
return widget()->contentOverlapped(w, e);
|
|
|
|
}
|
|
|
|
|
2021-07-05 16:47:49 +00:00
|
|
|
SessionController::~SessionController() {
|
|
|
|
resetFakeUnreadWhileOpened();
|
|
|
|
}
|
2018-01-21 14:49:42 +00:00
|
|
|
|
2022-02-25 06:21:53 +00:00
|
|
|
Show::Show(not_null<SessionNavigation*> navigation)
|
|
|
|
: Show(&navigation->parentController()->window()) {
|
|
|
|
}
|
|
|
|
|
2022-06-20 11:39:48 +00:00
|
|
|
Show::Show(Controller *window)
|
|
|
|
: _window(base::make_weak(window)) {
|
2022-02-25 06:21:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Show::~Show() = default;
|
|
|
|
|
|
|
|
void Show::showBox(
|
|
|
|
object_ptr<Ui::BoxContent> content,
|
|
|
|
Ui::LayerOptions options) const {
|
|
|
|
if (const auto window = _window.get()) {
|
|
|
|
window->show(std::move(content), options);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Show::hideLayer() const {
|
|
|
|
if (const auto window = _window.get()) {
|
|
|
|
window->show(
|
|
|
|
object_ptr<Ui::BoxContent>{ nullptr },
|
|
|
|
Ui::LayerOption::CloseOther);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
not_null<QWidget*> Show::toastParent() const {
|
|
|
|
const auto window = _window.get();
|
|
|
|
Assert(window != nullptr);
|
|
|
|
return window->widget()->bodyWidget();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Show::valid() const {
|
|
|
|
return !_window.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
Show::operator bool() const {
|
|
|
|
return valid();
|
|
|
|
}
|
|
|
|
|
2017-04-07 18:10:49 +00:00
|
|
|
} // namespace Window
|