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"
|
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;
|
|
|
|
|
|
|
|
} // namespace
|
2018-01-04 19:54:35 +00:00
|
|
|
|
2018-01-05 15:57:18 +00:00
|
|
|
not_null<Entry*> Key::entry() const {
|
|
|
|
if (const auto p = base::get_if<not_null<History*>>(&_value)) {
|
|
|
|
return *p;
|
2019-04-15 11:54:03 +00:00
|
|
|
} else if (const auto p = base::get_if<not_null<Folder*>>(&_value)) {
|
2018-01-05 15:57:18 +00:00
|
|
|
return *p;
|
2018-01-04 19:54:35 +00:00
|
|
|
}
|
2018-01-22 09:33:09 +00:00
|
|
|
Unexpected("Empty Dialogs::Key in Key::entry().");
|
2018-01-04 19:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
History *Key::history() const {
|
|
|
|
if (const auto p = base::get_if<not_null<History*>>(&_value)) {
|
|
|
|
return *p;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-04-15 11:54:03 +00:00
|
|
|
Folder *Key::folder() const {
|
|
|
|
if (const auto p = base::get_if<not_null<Folder*>>(&_value)) {
|
2018-01-04 19:54:35 +00:00
|
|
|
return *p;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-01-22 16:42:25 +00:00
|
|
|
PeerData *Key::peer() const {
|
|
|
|
if (const auto p = base::get_if<not_null<History*>>(&_value)) {
|
|
|
|
return (*p)->peer;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-01-04 19:54:35 +00:00
|
|
|
} // namespace Dialogs
|