2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Play ringtones on click in select box.

This commit is contained in:
John Preston
2022-04-07 11:34:29 +04:00
parent f5164fe3e4
commit d35b8f82a3
7 changed files with 107 additions and 23 deletions

View File

@@ -510,7 +510,7 @@ void System::showNext() {
}
if (settings.soundNotify() && !_manager->skipAudio()) {
const auto track = lookupSound(
alertPeer,
&alertPeer->owner(),
alertPeer->owner().notifySettings().sound(alertPeer).id);
track->playOnce();
Media::Player::mixer()->suppressAll(track->getLengthMs());
@@ -699,7 +699,7 @@ void System::showNext() {
}
not_null<Media::Audio::Track*> System::lookupSound(
not_null<PeerData*> peer,
not_null<Data::Session*> owner,
DocumentId id) {
if (!id) {
ensureSoundCreated();
@@ -709,7 +709,7 @@ not_null<Media::Audio::Track*> System::lookupSound(
if (i != end(_customSoundTracks)) {
return i->second.get();
}
const auto &notifySettings = peer->owner().notifySettings();
const auto &notifySettings = owner->notifySettings();
const auto custom = notifySettings.lookupRingtone(id);
if (custom && !custom->bytes().isEmpty()) {
const auto j = _customSoundTracks.emplace(
@@ -747,6 +747,10 @@ void System::notifySettingsChanged(ChangeType type) {
return _settingsChanged.fire(std::move(type));
}
void System::playSound(not_null<Main::Session*> session, DocumentId id) {
lookupSound(&session->data(), id)->playOnce();
}
Manager::DisplayOptions Manager::getNotificationOptions(
HistoryItem *item,
ItemNotificationType type) const {

View File

@@ -15,6 +15,7 @@ struct ItemNotification;
enum class ItemNotificationType;
namespace Data {
class Session;
class CloudImageView;
} // namespace Data
@@ -99,6 +100,8 @@ public:
[[nodiscard]] rpl::producer<ChangeType> settingsChanged() const;
void notifySettingsChanged(ChangeType type);
void playSound(not_null<Main::Session*> session, DocumentId id);
[[nodiscard]] rpl::lifetime &lifetime() {
return _lifetime;
}
@@ -159,7 +162,7 @@ private:
void showGrouped();
void ensureSoundCreated();
[[nodiscard]] not_null<Media::Audio::Track*> lookupSound(
not_null<PeerData*> peer,
not_null<Data::Session*> owner,
DocumentId id);
base::flat_map<