2018-01-04 19:54:35 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#include "dialogs/dialogs_key.h"
|
|
|
|
|
2019-04-15 11:54:03 +00:00
|
|
|
#include "data/data_folder.h"
|
2022-09-20 18:12:30 +00:00
|
|
|
#include "data/data_forum_topic.h"
|
2018-01-13 12:45:11 +00:00
|
|
|
#include "history/history.h"
|
2018-01-04 19:54:35 +00:00
|
|
|
|
|
|
|
namespace Dialogs {
|
2019-04-15 11:54:03 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
using Folder = Data::Folder;
|
2022-09-20 18:12:30 +00:00
|
|
|
using ForumTopic = Data::ForumTopic;
|
2019-04-15 11:54:03 +00:00
|
|
|
|
|
|
|
} // namespace
|
2018-01-04 19:54:35 +00:00
|
|
|
|
2020-06-12 14:09:04 +00:00
|
|
|
Key::Key(History *history) : _value(history) {
|
|
|
|
}
|
|
|
|
|
|
|
|
Key::Key(Data::Folder *folder) : _value(folder) {
|
|
|
|
}
|
|
|
|
|
2022-09-23 19:21:31 +00:00
|
|
|
Key::Key(Data::ForumTopic *topic) : _value(topic) {
|
2022-09-20 18:12:30 +00:00
|
|
|
}
|
|
|
|
|
2020-06-12 14:09:04 +00:00
|
|
|
Key::Key(not_null<History*> history) : _value(history) {
|
|
|
|
}
|
|
|
|
|
|
|
|
Key::Key(not_null<Data::Folder*> folder) : _value(folder) {
|
|
|
|
}
|
|
|
|
|
2022-09-23 19:21:31 +00:00
|
|
|
Key::Key(not_null<Data::ForumTopic*> topic) : _value(topic) {
|
2022-09-20 18:12:30 +00:00
|
|
|
}
|
|
|
|
|
2018-01-05 15:57:18 +00:00
|
|
|
not_null<Entry*> Key::entry() const {
|
2020-06-12 14:09:04 +00:00
|
|
|
Expects(_value != nullptr);
|
|
|
|
|
|
|
|
return _value;
|
2018-01-04 19:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
History *Key::history() const {
|
2020-06-12 14:09:04 +00:00
|
|
|
return _value ? _value->asHistory() : nullptr;
|
2018-01-04 19:54:35 +00:00
|
|
|
}
|
|
|
|
|
2019-04-15 11:54:03 +00:00
|
|
|
Folder *Key::folder() const {
|
2020-06-12 14:09:04 +00:00
|
|
|
return _value ? _value->asFolder() : nullptr;
|
2018-01-04 19:54:35 +00:00
|
|
|
}
|
|
|
|
|
2022-09-23 19:21:31 +00:00
|
|
|
ForumTopic *Key::topic() const {
|
|
|
|
return _value ? _value->asTopic() : nullptr;
|
2022-09-20 18:12:30 +00:00
|
|
|
}
|
|
|
|
|
2018-01-22 16:42:25 +00:00
|
|
|
PeerData *Key::peer() const {
|
2020-06-12 14:09:04 +00:00
|
|
|
if (const auto history = this->history()) {
|
|
|
|
return history->peer;
|
2018-01-22 16:42:25 +00:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-01-04 19:54:35 +00:00
|
|
|
} // namespace Dialogs
|