mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Inform about join request being sent.
This commit is contained in:
@@ -74,6 +74,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/item_text_options.h"
|
||||
#include "ui/emoji_config.h"
|
||||
#include "ui/chat/attach/attach_prepare.h"
|
||||
#include "ui/toasts/common_toasts.h"
|
||||
#include "support/support_helper.h"
|
||||
#include "storage/localimageloader.h"
|
||||
#include "storage/download_manager_mtproto.h"
|
||||
@@ -114,6 +115,7 @@ constexpr auto kStickersByEmojiInvalidateTimeout = crl::time(6 * 1000);
|
||||
constexpr auto kNotifySettingSaveTimeout = crl::time(1000);
|
||||
constexpr auto kDialogsFirstLoad = 20;
|
||||
constexpr auto kDialogsPerPage = 500;
|
||||
constexpr auto kJoinErrorDuration = 5 * crl::time(1000);
|
||||
|
||||
using PhotoFileLocationId = Data::PhotoFileLocationId;
|
||||
using DocumentFileLocationId = Data::DocumentFileLocationId;
|
||||
@@ -354,7 +356,7 @@ void ApiWrap::checkChatInvite(
|
||||
)).done(std::move(done)).fail(std::move(fail)).send();
|
||||
}
|
||||
|
||||
void ApiWrap::importChatInvite(const QString &hash) {
|
||||
void ApiWrap::importChatInvite(const QString &hash, bool isGroup) {
|
||||
request(MTPmessages_ImportChatInvite(
|
||||
MTP_string(hash)
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
@@ -391,13 +393,20 @@ void ApiWrap::importChatInvite(const QString &hash) {
|
||||
});
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
const auto &type = error.type();
|
||||
if (type == qstr("CHANNELS_TOO_MUCH")) {
|
||||
Ui::show(Box<Ui::InformBox>(tr::lng_join_channel_error(tr::now)));
|
||||
} else if (error.code() == 400) {
|
||||
Ui::show(Box<Ui::InformBox>((type == qstr("USERS_TOO_MUCH"))
|
||||
? tr::lng_group_invite_no_room(tr::now)
|
||||
: tr::lng_group_invite_bad_link(tr::now)));
|
||||
}
|
||||
Ui::hideLayer();
|
||||
Ui::ShowMultilineToast({ .text = { [&] {
|
||||
if (type == qstr("INVITE_REQUEST_SENT")) {
|
||||
return isGroup
|
||||
? tr::lng_group_request_sent(tr::now)
|
||||
: tr::lng_group_request_sent_channel(tr::now);
|
||||
} else if (type == qstr("CHANNELS_TOO_MUCH")) {
|
||||
return tr::lng_join_channel_error(tr::now);
|
||||
} else if (type == qstr("USERS_TOO_MUCH")) {
|
||||
return tr::lng_group_invite_no_room(tr::now);
|
||||
} else {
|
||||
return tr::lng_group_invite_bad_link(tr::now);
|
||||
}
|
||||
}() }, .duration = kJoinErrorDuration });
|
||||
}).send();
|
||||
}
|
||||
|
||||
@@ -1096,7 +1105,9 @@ void ApiWrap::gotChatFull(
|
||||
_fullPeerRequests.erase(i);
|
||||
}
|
||||
}
|
||||
fullPeerUpdated().notify(peer);
|
||||
_session->changes().peerUpdated(
|
||||
peer,
|
||||
Data::PeerUpdate::Flag::FullInfo);
|
||||
}
|
||||
|
||||
void ApiWrap::gotUserFull(
|
||||
@@ -1119,7 +1130,9 @@ void ApiWrap::gotUserFull(
|
||||
_fullPeerRequests.erase(i);
|
||||
}
|
||||
}
|
||||
fullPeerUpdated().notify(user);
|
||||
_session->changes().peerUpdated(
|
||||
user,
|
||||
Data::PeerUpdate::Flag::FullInfo);
|
||||
}
|
||||
|
||||
void ApiWrap::requestPeer(not_null<PeerData*> peer) {
|
||||
@@ -1544,7 +1557,9 @@ void ApiWrap::applyLastParticipantsList(
|
||||
(Data::PeerUpdate::Flag::Members | Data::PeerUpdate::Flag::Admins));
|
||||
|
||||
channel->mgInfo->botStatus = botStatus;
|
||||
fullPeerUpdated().notify(channel);
|
||||
_session->changes().peerUpdated(
|
||||
channel,
|
||||
Data::PeerUpdate::Flag::FullInfo);
|
||||
}
|
||||
|
||||
void ApiWrap::applyBotsList(
|
||||
@@ -1593,7 +1608,9 @@ void ApiWrap::applyBotsList(
|
||||
}
|
||||
|
||||
channel->mgInfo->botStatus = botStatus;
|
||||
fullPeerUpdated().notify(channel);
|
||||
_session->changes().peerUpdated(
|
||||
channel,
|
||||
Data::PeerUpdate::Flag::FullInfo);
|
||||
}
|
||||
|
||||
void ApiWrap::requestSelfParticipant(not_null<ChannelData*> channel) {
|
||||
@@ -2078,20 +2095,35 @@ void ApiWrap::joinChannel(not_null<ChannelData*> channel) {
|
||||
_channelAmInRequests.remove(channel);
|
||||
applyUpdates(result);
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
if (error.type() == qstr("CHANNEL_PRIVATE")
|
||||
const auto &type = error.type();
|
||||
if (type == qstr("CHANNEL_PRIVATE")
|
||||
&& channel->invitePeekExpires()) {
|
||||
channel->privateErrorReceived();
|
||||
} else if (error.type() == qstr("CHANNEL_PRIVATE")
|
||||
|| error.type() == qstr("CHANNEL_PUBLIC_GROUP_NA")
|
||||
|| error.type() == qstr("USER_BANNED_IN_CHANNEL")) {
|
||||
Ui::show(Box<Ui::InformBox>(channel->isMegagroup()
|
||||
? tr::lng_group_not_accessible(tr::now)
|
||||
: tr::lng_channel_not_accessible(tr::now)));
|
||||
} else if (error.type() == qstr("CHANNELS_TOO_MUCH")) {
|
||||
Ui::show(Box<Ui::InformBox>(
|
||||
tr::lng_join_channel_error(tr::now)));
|
||||
} else if (error.type() == qstr("USERS_TOO_MUCH")) {
|
||||
Ui::show(Box<Ui::InformBox>(tr::lng_group_full(tr::now)));
|
||||
} else {
|
||||
const auto text = [&] {
|
||||
if (type == qstr("INVITE_REQUEST_SENT")) {
|
||||
return channel->isMegagroup()
|
||||
? tr::lng_group_request_sent(tr::now)
|
||||
: tr::lng_group_request_sent_channel(tr::now);
|
||||
} else if (type == qstr("CHANNEL_PRIVATE")
|
||||
|| type == qstr("CHANNEL_PUBLIC_GROUP_NA")
|
||||
|| type == qstr("USER_BANNED_IN_CHANNEL")) {
|
||||
return channel->isMegagroup()
|
||||
? tr::lng_group_not_accessible(tr::now)
|
||||
: tr::lng_channel_not_accessible(tr::now);
|
||||
} else if (type == qstr("CHANNELS_TOO_MUCH")) {
|
||||
return tr::lng_join_channel_error(tr::now);
|
||||
} else if (type == qstr("USERS_TOO_MUCH")) {
|
||||
return tr::lng_group_full(tr::now);
|
||||
}
|
||||
return QString();
|
||||
}();
|
||||
if (!text.isEmpty()) {
|
||||
Ui::ShowMultilineToast({
|
||||
.text = { text },
|
||||
.duration = kJoinErrorDuration,
|
||||
});
|
||||
}
|
||||
}
|
||||
_channelAmInRequests.remove(channel);
|
||||
}).send();
|
||||
@@ -2194,7 +2226,7 @@ void ApiWrap::saveDraftToCloudDelayed(not_null<History*> history) {
|
||||
void ApiWrap::updatePrivacyLastSeens() {
|
||||
const auto now = base::unixtime::now();
|
||||
_session->data().enumerateUsers([&](UserData *user) {
|
||||
if (user->isSelf() || !user->isFullLoaded()) {
|
||||
if (user->isSelf() || !user->isLoaded()) {
|
||||
return;
|
||||
}
|
||||
if (user->onlineTill <= 0) {
|
||||
|
Reference in New Issue
Block a user