mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-08 08:04:08 +02:00
Added ability to choose to show recent group history for each new user.
Fixed #9864.
This commit is contained in:
parent
c14d9b18f7
commit
5fbbdd8a9e
6 changed files with 67 additions and 11 deletions
|
@ -1299,8 +1299,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
"lng_participant_filter" = "Search";
|
"lng_participant_filter" = "Search";
|
||||||
"lng_participant_invite" = "Invite";
|
"lng_participant_invite" = "Invite";
|
||||||
|
"lng_participant_invite_history" = "Show the last 100 messages";
|
||||||
|
"lng_participant_invite_sure" = "Are you sure you want to add **{user}** to **{group}**?";
|
||||||
|
"lng_participant_invite_sure_many#one" = "Are you sure you want to add {count} member to **{group}**?";
|
||||||
|
"lng_participant_invite_sure_many#other" = "Are you sure you want to add {count} members to **{group}**?";
|
||||||
"lng_participant_invite_sorry#one" = "Sorry, you can only add the first {count} member to a channel personally.\n\nFrom now on, people will need to join via your invite link.";
|
"lng_participant_invite_sorry#one" = "Sorry, you can only add the first {count} member to a channel personally.\n\nFrom now on, people will need to join via your invite link.";
|
||||||
"lng_participant_invite_sorry#other" = "Sorry, you can only add the first {count} members to a channel personally.\n\nFrom now on, people will need to join via your invite link.";
|
"lng_participant_invite_sorry#other" = "Sorry, you can only add the first {count} members to a channel personally.\n\nFrom now on, people will need to join via your invite link.";
|
||||||
|
|
||||||
"lng_create_group_back" = "Back";
|
"lng_create_group_back" = "Back";
|
||||||
"lng_create_group_next" = "Next";
|
"lng_create_group_next" = "Next";
|
||||||
"lng_create_group_create" = "Create";
|
"lng_create_group_create" = "Create";
|
||||||
|
|
|
@ -462,13 +462,14 @@ void ChatParticipants::requestCountDelayed(
|
||||||
void ChatParticipants::add(
|
void ChatParticipants::add(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const std::vector<not_null<UserData*>> &users,
|
const std::vector<not_null<UserData*>> &users,
|
||||||
|
bool passGroupHistory,
|
||||||
Fn<void(bool)> done) {
|
Fn<void(bool)> done) {
|
||||||
if (const auto chat = peer->asChat()) {
|
if (const auto chat = peer->asChat()) {
|
||||||
for (const auto &user : users) {
|
for (const auto &user : users) {
|
||||||
_api.request(MTPmessages_AddChatUser(
|
_api.request(MTPmessages_AddChatUser(
|
||||||
chat->inputChat,
|
chat->inputChat,
|
||||||
user->inputUser,
|
user->inputUser,
|
||||||
MTP_int(kForwardMessagesOnAdd)
|
MTP_int(passGroupHistory ? kForwardMessagesOnAdd : 0)
|
||||||
)).done([=](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
chat->session().api().applyUpdates(result);
|
chat->session().api().applyUpdates(result);
|
||||||
if (done) done(true);
|
if (done) done(true);
|
||||||
|
|
|
@ -95,6 +95,7 @@ public:
|
||||||
void add(
|
void add(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const std::vector<not_null<UserData*>> &users,
|
const std::vector<not_null<UserData*>> &users,
|
||||||
|
bool passGroupHistory = true,
|
||||||
Fn<void(bool)> done = nullptr);
|
Fn<void(bool)> done = nullptr);
|
||||||
|
|
||||||
void requestSelf(not_null<ChannelData*> channel);
|
void requestSelf(not_null<ChannelData*> channel);
|
||||||
|
|
|
@ -21,7 +21,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "dialogs/dialogs_indexed_list.h"
|
#include "dialogs/dialogs_indexed_list.h"
|
||||||
|
#include "ui/text/text_utilities.h" // Ui::Text::RichLangValue
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "ui/wrap/padding_wrap.h"
|
#include "ui/wrap/padding_wrap.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
@ -30,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "info/profile/info_profile_icon.h"
|
#include "info/profile/info_profile_icon.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
#include "styles/style_layers.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -223,8 +226,9 @@ void AddParticipantsBoxController::addInviteLinkButton() {
|
||||||
delegate()->peerListSetAboveWidget(std::move(button));
|
delegate()->peerListSetAboveWidget(std::move(button));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddParticipantsBoxController::inviteSelectedUsers(
|
void AddParticipantsBoxController::inviteSelectedUsers(
|
||||||
not_null<PeerListBox*> box) const {
|
not_null<PeerListBox*> box,
|
||||||
|
Fn<void()> done) const {
|
||||||
Expects(_peer != nullptr);
|
Expects(_peer != nullptr);
|
||||||
|
|
||||||
const auto rows = box->collectSelectedRows();
|
const auto rows = box->collectSelectedRows();
|
||||||
|
@ -237,10 +241,52 @@ bool AddParticipantsBoxController::inviteSelectedUsers(
|
||||||
return not_null<UserData*>(peer->asUser());
|
return not_null<UserData*>(peer->asUser());
|
||||||
}) | ranges::to_vector;
|
}) | ranges::to_vector;
|
||||||
if (users.empty()) {
|
if (users.empty()) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
_peer->session().api().chatParticipants().add(_peer, users);
|
const auto request = [=](bool checked) {
|
||||||
return true;
|
_peer->session().api().chatParticipants().add(_peer, users, checked);
|
||||||
|
};
|
||||||
|
if (_peer->isChannel()) {
|
||||||
|
request(false);
|
||||||
|
return done();
|
||||||
|
}
|
||||||
|
Ui::BoxShow(box).showBox(Box([=](not_null<Ui::GenericBox*> box) {
|
||||||
|
auto checkbox = object_ptr<Ui::Checkbox>(
|
||||||
|
box.get(),
|
||||||
|
tr::lng_participant_invite_history(),
|
||||||
|
true,
|
||||||
|
st::defaultBoxCheckbox);
|
||||||
|
const auto weak = Ui::MakeWeak(checkbox.data());
|
||||||
|
|
||||||
|
auto text = (users.size() == 1)
|
||||||
|
? tr::lng_participant_invite_sure(
|
||||||
|
tr::now,
|
||||||
|
lt_user,
|
||||||
|
{ users.front()->name },
|
||||||
|
lt_group,
|
||||||
|
{ _peer->name },
|
||||||
|
Ui::Text::RichLangValue)
|
||||||
|
: tr::lng_participant_invite_sure_many(
|
||||||
|
tr::now,
|
||||||
|
lt_count,
|
||||||
|
int(users.size()),
|
||||||
|
lt_group,
|
||||||
|
{ _peer->name },
|
||||||
|
Ui::Text::RichLangValue);
|
||||||
|
Ui::ConfirmBox(box, {
|
||||||
|
.text = std::move(text),
|
||||||
|
.confirmed = crl::guard(weak, [=](Fn<void()> &&close) {
|
||||||
|
request(weak->checked());
|
||||||
|
done();
|
||||||
|
close();
|
||||||
|
}),
|
||||||
|
.confirmText = tr::lng_participant_invite(),
|
||||||
|
});
|
||||||
|
|
||||||
|
auto padding = st::boxPadding;
|
||||||
|
padding.setTop(padding.bottom());
|
||||||
|
box->addRow(std::move(checkbox), std::move(padding));
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddParticipantsBoxController::Start(
|
void AddParticipantsBoxController::Start(
|
||||||
|
@ -250,12 +296,12 @@ void AddParticipantsBoxController::Start(
|
||||||
const auto weak = controller.get();
|
const auto weak = controller.get();
|
||||||
auto initBox = [=](not_null<PeerListBox*> box) {
|
auto initBox = [=](not_null<PeerListBox*> box) {
|
||||||
box->addButton(tr::lng_participant_invite(), [=] {
|
box->addButton(tr::lng_participant_invite(), [=] {
|
||||||
if (weak->inviteSelectedUsers(box)) {
|
weak->inviteSelectedUsers(box, [=] {
|
||||||
navigation->parentController()->showPeerHistory(
|
navigation->parentController()->showPeerHistory(
|
||||||
chat,
|
chat,
|
||||||
Window::SectionShow::Way::ClearStack,
|
Window::SectionShow::Way::ClearStack,
|
||||||
ShowAtTheEndMsgId);
|
ShowAtTheEndMsgId);
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||||
};
|
};
|
||||||
|
@ -275,7 +321,7 @@ void AddParticipantsBoxController::Start(
|
||||||
const auto weak = controller.get();
|
const auto weak = controller.get();
|
||||||
auto initBox = [=](not_null<PeerListBox*> box) {
|
auto initBox = [=](not_null<PeerListBox*> box) {
|
||||||
box->addButton(tr::lng_participant_invite(), [=] {
|
box->addButton(tr::lng_participant_invite(), [=] {
|
||||||
if (weak->inviteSelectedUsers(box)) {
|
weak->inviteSelectedUsers(box, [=] {
|
||||||
if (channel->isMegagroup()) {
|
if (channel->isMegagroup()) {
|
||||||
navigation->parentController()->showPeerHistory(
|
navigation->parentController()->showPeerHistory(
|
||||||
channel,
|
channel,
|
||||||
|
@ -284,7 +330,7 @@ void AddParticipantsBoxController::Start(
|
||||||
} else {
|
} else {
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
box->addButton(
|
box->addButton(
|
||||||
justCreated ? tr::lng_create_group_skip() : tr::lng_cancel(),
|
justCreated ? tr::lng_create_group_skip() : tr::lng_cancel(),
|
||||||
|
|
|
@ -59,7 +59,9 @@ private:
|
||||||
QPointer<Ui::BoxContent> showBox(object_ptr<Ui::BoxContent> box) const;
|
QPointer<Ui::BoxContent> showBox(object_ptr<Ui::BoxContent> box) const;
|
||||||
|
|
||||||
void addInviteLinkButton();
|
void addInviteLinkButton();
|
||||||
bool inviteSelectedUsers(not_null<PeerListBox*> box) const;
|
void inviteSelectedUsers(
|
||||||
|
not_null<PeerListBox*> box,
|
||||||
|
Fn<void()> done) const;
|
||||||
void subscribeToMigration();
|
void subscribeToMigration();
|
||||||
int alreadyInCount() const;
|
int alreadyInCount() const;
|
||||||
bool isAlreadyIn(not_null<UserData*> user) const;
|
bool isAlreadyIn(not_null<UserData*> user) const;
|
||||||
|
|
|
@ -225,6 +225,7 @@ object_ptr<Ui::BoxContent> PrepareInviteBox(
|
||||||
peer->session().api().chatParticipants().add(
|
peer->session().api().chatParticipants().add(
|
||||||
peer,
|
peer,
|
||||||
nonMembers,
|
nonMembers,
|
||||||
|
true,
|
||||||
[=](bool) { invite(users); finish(); });
|
[=](bool) { invite(users); finish(); });
|
||||||
};
|
};
|
||||||
const auto inviteWithConfirmation = [=](
|
const auto inviteWithConfirmation = [=](
|
||||||
|
|
Loading…
Add table
Reference in a new issue