2019-08-23 13:52:59 +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
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "data/data_auto_download.h"
|
2019-09-13 12:22:54 +00:00
|
|
|
#include "ui/rect_part.h"
|
2019-08-23 13:52:59 +00:00
|
|
|
|
|
|
|
namespace Support {
|
|
|
|
enum class SwitchSettings;
|
|
|
|
} // namespace Support
|
|
|
|
|
|
|
|
namespace ChatHelpers {
|
|
|
|
enum class SelectorTab;
|
|
|
|
} // namespace ChatHelpers
|
|
|
|
|
|
|
|
namespace Main {
|
|
|
|
|
2020-06-18 12:47:09 +00:00
|
|
|
class SessionSettings final {
|
2019-08-23 13:52:59 +00:00
|
|
|
public:
|
2020-06-18 18:04:16 +00:00
|
|
|
SessionSettings();
|
2019-08-23 13:52:59 +00:00
|
|
|
|
2020-06-18 18:04:16 +00:00
|
|
|
[[nodiscard]] QByteArray serialize() const;
|
2020-06-19 17:13:43 +00:00
|
|
|
void addFromSerialized(const QByteArray &serialized);
|
2019-08-23 13:52:59 +00:00
|
|
|
|
|
|
|
void setSupportSwitch(Support::SwitchSettings value) {
|
2020-06-18 18:04:16 +00:00
|
|
|
_supportSwitch = value;
|
2019-08-23 13:52:59 +00:00
|
|
|
}
|
|
|
|
[[nodiscard]] Support::SwitchSettings supportSwitch() const {
|
2020-06-18 18:04:16 +00:00
|
|
|
return _supportSwitch;
|
2019-08-23 13:52:59 +00:00
|
|
|
}
|
|
|
|
void setSupportFixChatsOrder(bool fix) {
|
2020-06-18 18:04:16 +00:00
|
|
|
_supportFixChatsOrder = fix;
|
2019-08-23 13:52:59 +00:00
|
|
|
}
|
|
|
|
[[nodiscard]] bool supportFixChatsOrder() const {
|
2020-06-18 18:04:16 +00:00
|
|
|
return _supportFixChatsOrder;
|
2019-08-23 13:52:59 +00:00
|
|
|
}
|
|
|
|
void setSupportTemplatesAutocomplete(bool enabled) {
|
2020-06-18 18:04:16 +00:00
|
|
|
_supportTemplatesAutocomplete = enabled;
|
2019-08-23 13:52:59 +00:00
|
|
|
}
|
|
|
|
[[nodiscard]] bool supportTemplatesAutocomplete() const {
|
2020-06-18 18:04:16 +00:00
|
|
|
return _supportTemplatesAutocomplete;
|
2019-08-23 13:52:59 +00:00
|
|
|
}
|
|
|
|
void setSupportChatsTimeSlice(int slice);
|
|
|
|
[[nodiscard]] int supportChatsTimeSlice() const;
|
|
|
|
[[nodiscard]] rpl::producer<int> supportChatsTimeSliceValue() const;
|
|
|
|
void setSupportAllSearchResults(bool all);
|
|
|
|
[[nodiscard]] bool supportAllSearchResults() const;
|
|
|
|
[[nodiscard]] rpl::producer<bool> supportAllSearchResultsValue() const;
|
2020-11-19 13:23:51 +00:00
|
|
|
void setSupportAllSilent(bool enabled) {
|
|
|
|
_supportAllSilent = enabled;
|
|
|
|
}
|
|
|
|
[[nodiscard]] bool supportAllSilent() const {
|
|
|
|
return _supportAllSilent;
|
|
|
|
}
|
2019-08-23 13:52:59 +00:00
|
|
|
|
|
|
|
[[nodiscard]] ChatHelpers::SelectorTab selectorTab() const {
|
2020-06-18 18:04:16 +00:00
|
|
|
return _selectorTab;
|
2019-08-23 13:52:59 +00:00
|
|
|
}
|
|
|
|
void setSelectorTab(ChatHelpers::SelectorTab tab) {
|
2020-06-18 18:04:16 +00:00
|
|
|
_selectorTab = tab;
|
2019-08-23 13:52:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setGroupStickersSectionHidden(PeerId peerId) {
|
2020-06-18 18:04:16 +00:00
|
|
|
_groupStickersSectionHidden.insert(peerId);
|
2019-08-23 13:52:59 +00:00
|
|
|
}
|
|
|
|
[[nodiscard]] bool isGroupStickersSectionHidden(PeerId peerId) const {
|
2020-06-18 18:04:16 +00:00
|
|
|
return _groupStickersSectionHidden.contains(peerId);
|
2019-08-23 13:52:59 +00:00
|
|
|
}
|
|
|
|
void removeGroupStickersSectionHidden(PeerId peerId) {
|
2020-06-18 18:04:16 +00:00
|
|
|
_groupStickersSectionHidden.remove(peerId);
|
2019-08-23 13:52:59 +00:00
|
|
|
}
|
|
|
|
|
2019-12-25 15:19:52 +00:00
|
|
|
void setMediaLastPlaybackPosition(DocumentId id, crl::time time);
|
|
|
|
[[nodiscard]] crl::time mediaLastPlaybackPosition(DocumentId id) const;
|
|
|
|
|
2019-08-23 13:52:59 +00:00
|
|
|
[[nodiscard]] Data::AutoDownload::Full &autoDownload() {
|
2020-06-18 18:04:16 +00:00
|
|
|
return _autoDownload;
|
2019-08-23 13:52:59 +00:00
|
|
|
}
|
|
|
|
[[nodiscard]] const Data::AutoDownload::Full &autoDownload() const {
|
2020-06-18 18:04:16 +00:00
|
|
|
return _autoDownload;
|
2019-08-23 13:52:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setArchiveCollapsed(bool collapsed);
|
|
|
|
[[nodiscard]] bool archiveCollapsed() const;
|
|
|
|
[[nodiscard]] rpl::producer<bool> archiveCollapsedChanges() const;
|
|
|
|
|
|
|
|
void setArchiveInMainMenu(bool inMainMenu);
|
|
|
|
[[nodiscard]] bool archiveInMainMenu() const;
|
|
|
|
[[nodiscard]] rpl::producer<bool> archiveInMainMenuChanges() const;
|
|
|
|
|
|
|
|
void setSkipArchiveInSearch(bool skip);
|
|
|
|
[[nodiscard]] bool skipArchiveInSearch() const;
|
|
|
|
[[nodiscard]] rpl::producer<bool> skipArchiveInSearchChanges() const;
|
|
|
|
|
|
|
|
[[nodiscard]] bool hadLegacyCallsPeerToPeerNobody() const {
|
2020-06-18 18:04:16 +00:00
|
|
|
return _hadLegacyCallsPeerToPeerNobody;
|
2020-01-29 08:58:07 +00:00
|
|
|
}
|
2020-01-28 12:41:08 +00:00
|
|
|
|
2020-06-18 11:17:58 +00:00
|
|
|
[[nodiscard]] MsgId hiddenPinnedMessageId(PeerId peerId) const {
|
2020-06-18 18:04:16 +00:00
|
|
|
const auto i = _hiddenPinnedMessages.find(peerId);
|
|
|
|
return (i != end(_hiddenPinnedMessages)) ? i->second : 0;
|
2020-06-18 11:17:58 +00:00
|
|
|
}
|
|
|
|
void setHiddenPinnedMessageId(PeerId peerId, MsgId msgId) {
|
|
|
|
if (msgId) {
|
2020-06-18 18:04:16 +00:00
|
|
|
_hiddenPinnedMessages[peerId] = msgId;
|
2020-06-18 11:17:58 +00:00
|
|
|
} else {
|
2020-06-18 18:04:16 +00:00
|
|
|
_hiddenPinnedMessages.remove(peerId);
|
2020-06-18 11:17:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-18 18:04:16 +00:00
|
|
|
[[nodiscard]] bool dialogsFiltersEnabled() const {
|
|
|
|
return _dialogsFiltersEnabled;
|
|
|
|
}
|
|
|
|
void setDialogsFiltersEnabled(bool value) {
|
|
|
|
_dialogsFiltersEnabled = value;
|
|
|
|
}
|
|
|
|
|
2021-04-23 16:31:21 +00:00
|
|
|
[[nodiscard]] bool photoEditorHintShown() const;
|
|
|
|
void incrementPhotoEditorHintShown();
|
|
|
|
|
2019-08-23 13:52:59 +00:00
|
|
|
private:
|
2020-06-18 18:04:16 +00:00
|
|
|
static constexpr auto kDefaultSupportChatsLimitSlice = 7 * 24 * 60 * 60;
|
2021-09-05 09:37:30 +00:00
|
|
|
static constexpr auto kPhotoEditorHintMaxShowsCount = 5;
|
2020-06-18 18:04:16 +00:00
|
|
|
|
|
|
|
ChatHelpers::SelectorTab _selectorTab; // per-window
|
|
|
|
base::flat_set<PeerId> _groupStickersSectionHidden;
|
|
|
|
bool _hadLegacyCallsPeerToPeerNobody = false;
|
|
|
|
Data::AutoDownload::Full _autoDownload;
|
|
|
|
rpl::variable<bool> _archiveCollapsed = false;
|
|
|
|
rpl::variable<bool> _archiveInMainMenu = false;
|
|
|
|
rpl::variable<bool> _skipArchiveInSearch = false;
|
|
|
|
std::vector<std::pair<DocumentId, crl::time>> _mediaLastPlaybackPosition;
|
|
|
|
base::flat_map<PeerId, MsgId> _hiddenPinnedMessages;
|
|
|
|
bool _dialogsFiltersEnabled = false;
|
2021-04-23 16:31:21 +00:00
|
|
|
int _photoEditorHintShowsCount = 0;
|
2020-06-18 18:04:16 +00:00
|
|
|
|
|
|
|
Support::SwitchSettings _supportSwitch;
|
|
|
|
bool _supportFixChatsOrder = true;
|
|
|
|
bool _supportTemplatesAutocomplete = true;
|
2020-11-19 13:23:51 +00:00
|
|
|
bool _supportAllSilent = false;
|
2020-06-18 18:04:16 +00:00
|
|
|
rpl::variable<int> _supportChatsTimeSlice
|
|
|
|
= kDefaultSupportChatsLimitSlice;
|
|
|
|
rpl::variable<bool> _supportAllSearchResults = false;
|
2019-08-23 13:52:59 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Main
|