mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add 'rejoin as' and 'change title' toast notifications.
This commit is contained in:
parent
33ae4c2802
commit
61d0d240aa
7 changed files with 66 additions and 9 deletions
|
@ -2013,6 +2013,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_group_call_is_recorded" = "Voice chat is being recorded.";
|
"lng_group_call_is_recorded" = "Voice chat is being recorded.";
|
||||||
"lng_group_call_can_speak_here" = "You can now speak.";
|
"lng_group_call_can_speak_here" = "You can now speak.";
|
||||||
"lng_group_call_can_speak" = "You can now speak in {chat}.";
|
"lng_group_call_can_speak" = "You can now speak in {chat}.";
|
||||||
|
"lng_group_call_title_changed" = "Voice chat title changed to {title}";
|
||||||
|
"lng_group_call_join_as_changed" = "Members of this voice chat will now see you as {name}";
|
||||||
|
|
||||||
"lng_no_mic_permission" = "Telegram needs access to your microphone so that you can make calls and record voice messages.";
|
"lng_no_mic_permission" = "Telegram needs access to your microphone so that you can make calls and record voice messages.";
|
||||||
|
|
||||||
|
|
|
@ -930,12 +930,12 @@ void GroupCall::changeTitle(const QString &title) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
real->setTitle(title);
|
|
||||||
_api.request(MTPphone_EditGroupCallTitle(
|
_api.request(MTPphone_EditGroupCallTitle(
|
||||||
inputCall(),
|
inputCall(),
|
||||||
MTP_string(title)
|
MTP_string(title)
|
||||||
)).done([=](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
_peer->session().api().applyUpdates(result);
|
_peer->session().api().applyUpdates(result);
|
||||||
|
_titleChanged.fire({});
|
||||||
}).fail([=](const MTP::Error &error) {
|
}).fail([=](const MTP::Error &error) {
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
|
@ -1374,11 +1374,6 @@ void GroupCall::sendSelfUpdate(SendUpdateType type) {
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto GroupCall::instanceStateValue() const -> rpl::producer<InstanceState> {
|
|
||||||
using namespace rpl::mappers;
|
|
||||||
return _instanceState.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GroupCall::setCurrentAudioDevice(bool input, const QString &deviceId) {
|
void GroupCall::setCurrentAudioDevice(bool input, const QString &deviceId) {
|
||||||
if (input) {
|
if (input) {
|
||||||
_mediaDevices->switchToAudioInput(deviceId);
|
_mediaDevices->switchToAudioInput(deviceId);
|
||||||
|
|
|
@ -158,7 +158,12 @@ public:
|
||||||
TransitionToRtc,
|
TransitionToRtc,
|
||||||
Connected,
|
Connected,
|
||||||
};
|
};
|
||||||
[[nodiscard]] rpl::producer<InstanceState> instanceStateValue() const;
|
[[nodiscard]] InstanceState instanceState() const {
|
||||||
|
return _instanceState.current();
|
||||||
|
}
|
||||||
|
[[nodiscard]] rpl::producer<InstanceState> instanceStateValue() const {
|
||||||
|
return _instanceState.value();
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<LevelUpdate> levelUpdates() const {
|
[[nodiscard]] rpl::producer<LevelUpdate> levelUpdates() const {
|
||||||
return _levelUpdates.events();
|
return _levelUpdates.events();
|
||||||
|
@ -169,6 +174,9 @@ public:
|
||||||
[[nodiscard]] rpl::producer<> allowedToSpeakNotifications() const {
|
[[nodiscard]] rpl::producer<> allowedToSpeakNotifications() const {
|
||||||
return _allowedToSpeakNotifications.events();
|
return _allowedToSpeakNotifications.events();
|
||||||
}
|
}
|
||||||
|
[[nodiscard]] rpl::producer<> titleChanged() const {
|
||||||
|
return _titleChanged.events();
|
||||||
|
}
|
||||||
static constexpr auto kSpeakLevelThreshold = 0.2;
|
static constexpr auto kSpeakLevelThreshold = 0.2;
|
||||||
|
|
||||||
void setCurrentAudioDevice(bool input, const QString &deviceId);
|
void setCurrentAudioDevice(bool input, const QString &deviceId);
|
||||||
|
@ -304,6 +312,7 @@ private:
|
||||||
base::flat_map<uint32, Data::LastSpokeTimes> _lastSpoke;
|
base::flat_map<uint32, Data::LastSpokeTimes> _lastSpoke;
|
||||||
rpl::event_stream<Group::RejoinEvent> _rejoinEvents;
|
rpl::event_stream<Group::RejoinEvent> _rejoinEvents;
|
||||||
rpl::event_stream<> _allowedToSpeakNotifications;
|
rpl::event_stream<> _allowedToSpeakNotifications;
|
||||||
|
rpl::event_stream<> _titleChanged;
|
||||||
base::Timer _lastSpokeCheckTimer;
|
base::Timer _lastSpokeCheckTimer;
|
||||||
base::Timer _checkJoinedTimer;
|
base::Timer _checkJoinedTimer;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
|
#include "ui/toasts/common_toasts.h"
|
||||||
#include "ui/special_buttons.h"
|
#include "ui/special_buttons.h"
|
||||||
#include "info/profile/info_profile_values.h" // Info::Profile::Value.
|
#include "info/profile/info_profile_values.h" // Info::Profile::Value.
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
@ -284,6 +285,8 @@ Panel::Panel(not_null<GroupCall*> call)
|
||||||
initControls();
|
initControls();
|
||||||
initLayout();
|
initLayout();
|
||||||
showAndActivate();
|
showAndActivate();
|
||||||
|
setupJoinAsChangedToasts();
|
||||||
|
setupTitleChangedToasts();
|
||||||
|
|
||||||
call->allowedToSpeakNotifications(
|
call->allowedToSpeakNotifications(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
|
@ -597,6 +600,46 @@ void Panel::initWithCall(GroupCall *call) {
|
||||||
}, _callLifetime);
|
}, _callLifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Panel::setupJoinAsChangedToasts() {
|
||||||
|
_call->rejoinEvents(
|
||||||
|
) | rpl::filter([](RejoinEvent event) {
|
||||||
|
return (event.wasJoinAs != event.nowJoinAs);
|
||||||
|
}) | rpl::map([=] {
|
||||||
|
return _call->stateValue() | rpl::filter([](State state) {
|
||||||
|
return (state == State::Joined);
|
||||||
|
}) | rpl::take(1);
|
||||||
|
}) | rpl::flatten_latest() | rpl::start_with_next([=] {
|
||||||
|
Ui::ShowMultilineToast({
|
||||||
|
.parentOverride = widget(),
|
||||||
|
.text = tr::lng_group_call_join_as_changed(
|
||||||
|
tr::now,
|
||||||
|
lt_name,
|
||||||
|
Ui::Text::Bold(_call->joinAs()->name),
|
||||||
|
Ui::Text::WithEntities),
|
||||||
|
});
|
||||||
|
}, widget()->lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Panel::setupTitleChangedToasts() {
|
||||||
|
_call->titleChanged(
|
||||||
|
) | rpl::filter([=] {
|
||||||
|
return _peer->groupCall() && _peer->groupCall()->id() == _call->id();
|
||||||
|
}) | rpl::map([=] {
|
||||||
|
return _peer->groupCall()->title().isEmpty()
|
||||||
|
? _peer->name
|
||||||
|
: _peer->groupCall()->title();
|
||||||
|
}) | rpl::start_with_next([=](const QString &title) {
|
||||||
|
Ui::ShowMultilineToast({
|
||||||
|
.parentOverride = widget(),
|
||||||
|
.text = tr::lng_group_call_title_changed(
|
||||||
|
tr::now,
|
||||||
|
lt_title,
|
||||||
|
Ui::Text::Bold(title),
|
||||||
|
Ui::Text::WithEntities),
|
||||||
|
});
|
||||||
|
}, widget()->lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
void Panel::subscribeToChanges(not_null<Data::GroupCall*> real) {
|
void Panel::subscribeToChanges(not_null<Data::GroupCall*> real) {
|
||||||
_titleText = real->titleValue();
|
_titleText = real->titleValue();
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,8 @@ private:
|
||||||
void initWithCall(GroupCall *call);
|
void initWithCall(GroupCall *call);
|
||||||
void initLayout();
|
void initLayout();
|
||||||
void initGeometry();
|
void initGeometry();
|
||||||
|
void setupJoinAsChangedToasts();
|
||||||
|
void setupTitleChangedToasts();
|
||||||
|
|
||||||
bool handleClose();
|
bool handleClose();
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
void ShowMultilineToast(MultilineToastArgs &&args) {
|
void ShowMultilineToast(MultilineToastArgs &&args) {
|
||||||
Ui::Toast::Show(Ui::Toast::Config{
|
auto config = Ui::Toast::Config{
|
||||||
.text = std::move(args.text),
|
.text = std::move(args.text),
|
||||||
.st = &st::defaultMultilineToast,
|
.st = &st::defaultMultilineToast,
|
||||||
.durationMs = (args.duration
|
.durationMs = (args.duration
|
||||||
? args.duration
|
? args.duration
|
||||||
: Ui::Toast::kDefaultDuration),
|
: Ui::Toast::kDefaultDuration),
|
||||||
.multiline = true,
|
.multiline = true,
|
||||||
});
|
};
|
||||||
|
if (args.parentOverride) {
|
||||||
|
Ui::Toast::Show(args.parentOverride, std::move(config));
|
||||||
|
} else {
|
||||||
|
Ui::Toast::Show(std::move(config));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
struct MultilineToastArgs {
|
struct MultilineToastArgs {
|
||||||
|
QWidget *parentOverride = nullptr;
|
||||||
TextWithEntities text;
|
TextWithEntities text;
|
||||||
crl::time duration = 0;
|
crl::time duration = 0;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue