mirror of https://github.com/procxx/kepka.git
Added restriction info of posting stickers to touchbar.
This commit is contained in:
parent
99aa1fc556
commit
ee4501810c
|
@ -173,17 +173,31 @@ inline int UnreadCount(not_null<PeerData*> peer) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CanWriteToActiveChat() {
|
inline auto GetActiveChat() {
|
||||||
if (const auto window = App::wnd()) {
|
if (const auto window = App::wnd()) {
|
||||||
if (const auto controller = window->sessionController()) {
|
if (const auto controller = window->sessionController()) {
|
||||||
if (const auto chat = controller->activeChatCurrent()) {
|
return controller->activeChatCurrent();
|
||||||
return chat.history()->peer->canWrite();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return Dialogs::Key();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool CanWriteToActiveChat() {
|
||||||
|
if (const auto history = GetActiveChat().history()) {
|
||||||
|
return history->peer->canWrite();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::optional<QString> RestrictionToSendStickers() {
|
||||||
|
if (const auto peer = GetActiveChat().peer()) {
|
||||||
|
return Data::RestrictionError(
|
||||||
|
peer,
|
||||||
|
ChatRestriction::f_send_stickers);
|
||||||
|
}
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
QString TitleRecentlyUsed() {
|
QString TitleRecentlyUsed() {
|
||||||
const auto &sets = Auth().data().stickerSets();
|
const auto &sets = Auth().data().stickerSets();
|
||||||
const auto it = sets.constFind(Stickers::CloudRecentSetId);
|
const auto it = sets.constFind(Stickers::CloudRecentSetId);
|
||||||
|
@ -692,15 +706,12 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
if (!CanWriteToActiveChat()) {
|
if (!CanWriteToActiveChat()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto chat = App::wnd()->sessionController()->activeChatCurrent();
|
const auto chat = GetActiveChat();
|
||||||
|
|
||||||
const auto callback = [&]() -> bool {
|
const auto callback = [&]() -> bool {
|
||||||
if (const auto document = _stickers[index].document) {
|
if (const auto document = _stickers[index].document) {
|
||||||
if (const auto error = Data::RestrictionError(
|
if (const auto error = RestrictionToSendStickers()) {
|
||||||
chat.peer(),
|
|
||||||
ChatRestriction::f_send_stickers)) {
|
|
||||||
Ui::show(Box<InformBox>(*error));
|
Ui::show(Box<InformBox>(*error));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
Auth().api().sendExistingDocument(
|
Auth().api().sendExistingDocument(
|
||||||
document,
|
document,
|
||||||
|
@ -731,6 +742,12 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
|
|
||||||
- (void)updateStickers {
|
- (void)updateStickers {
|
||||||
std::vector<PickerScrubberItem> temp;
|
std::vector<PickerScrubberItem> temp;
|
||||||
|
if (const auto error = RestrictionToSendStickers()) {
|
||||||
|
temp.emplace_back(PickerScrubberItem(
|
||||||
|
tr::lng_restricted_send_stickers_all(tr::now)));
|
||||||
|
_stickers = std::move(temp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
AppendFavedStickers(temp);
|
AppendFavedStickers(temp);
|
||||||
AppendRecentStickers(temp);
|
AppendRecentStickers(temp);
|
||||||
auto count = 0;
|
auto count = 0;
|
||||||
|
|
Loading…
Reference in New Issue