tdesktop/Telegram/SourceFiles/dialogs/dialogs_key.cpp

51 lines
1.1 KiB
C++
Raw Normal View History

/*
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"
#include "history/history.h"
namespace Dialogs {
2019-04-15 11:54:03 +00:00
namespace {
using Folder = Data::Folder;
} // namespace
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)) {
return *p;
}
Unexpected("Empty Dialogs::Key in Key::entry().");
}
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)) {
return *p;
}
return nullptr;
}
PeerData *Key::peer() const {
if (const auto p = base::get_if<not_null<History*>>(&_value)) {
return (*p)->peer;
}
return nullptr;
}
} // namespace Dialogs