2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-02 15:45:12 +00:00

Move poll results to a Info-like layer.

This commit is contained in:
John Preston
2020-01-15 14:53:42 +03:00
parent d0597407d8
commit 8c11e1724a
18 changed files with 458 additions and 108 deletions

View File

@@ -19,6 +19,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_channel.h"
#include "data/data_chat.h"
#include "data/data_session.h"
#include "data/data_media_types.h"
#include "history/history_item.h"
#include "main/main_session.h"
#include "window/window_session_controller.h"
@@ -46,6 +48,10 @@ Key::Key(not_null<PeerData*> peer) : _value(peer) {
Key::Key(Settings::Tag settings) : _value(settings) {
}
Key::Key(not_null<PollData*> poll, FullMsgId contextId)
: _value(PollKey{ poll, contextId }) {
}
PeerData *Key::peer() const {
if (const auto peer = base::get_if<not_null<PeerData*>>(&_value)) {
return *peer;
@@ -67,6 +73,20 @@ UserData *Key::settingsSelf() const {
return nullptr;
}
PollData *Key::poll() const {
if (const auto data = base::get_if<PollKey>(&_value)) {
return data->poll;
}
return nullptr;
}
FullMsgId Key::pollContextId() const {
if (const auto data = base::get_if<PollKey>(&_value)) {
return data->contextId;
}
return FullMsgId();
}
rpl::producer<SparseIdsMergedSlice> AbstractController::mediaSource(
SparseIdsMergedSlice::UniversalMsgId aroundId,
int limitBefore,
@@ -106,6 +126,15 @@ PeerId AbstractController::migratedPeerId() const {
return PeerId(0);
}
PollData *AbstractController::poll() const {
if (const auto item = session().data().message(pollContextId())) {
if (const auto media = item->media()) {
return media->poll();
}
}
return nullptr;
}
void AbstractController::showSection(
Window::SectionMemento &&memento,
const Window::SectionShow &params) {