Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show MediaSettings if coming from notification "Join call" #10724

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ protected function parseInvitation(INotification $notification, Room $room, IL10
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
$subject = $l->t('{user} invited you to a private conversation');
if ($this->participantService->hasActiveSessionsInCall($room)) {
$notification = $this->addActionButton($notification, $l->t('Join call'));
$notification = $this->addActionButton($notification, $l->t('Join call'), true, true);
} else {
$notification = $this->addActionButton($notification, $l->t('View chat'), false);
}
Expand All @@ -918,7 +918,7 @@ protected function parseInvitation(INotification $notification, Room $room, IL10
} elseif (\in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) {
$subject = $l->t('{user} invited you to a group conversation: {call}');
if ($this->participantService->hasActiveSessionsInCall($room)) {
$notification = $this->addActionButton($notification, $l->t('Join call'));
$notification = $this->addActionButton($notification, $l->t('Join call'), true, true);
} else {
$notification = $this->addActionButton($notification, $l->t('View chat'), false);
}
Expand Down Expand Up @@ -968,7 +968,7 @@ protected function parseCall(INotification $notification, Room $room, IL10N $l):
$userDisplayName = $this->userManager->getDisplayName($calleeId);
if ($userDisplayName !== null) {
if ($this->notificationManager->isPreparingPushNotification() || $this->participantService->hasActiveSessionsInCall($room)) {
$notification = $this->addActionButton($notification, $l->t('Answer call'));
$notification = $this->addActionButton($notification, $l->t('Answer call'), true, true);
$subject = $l->t('{user} would like to talk with you');
} else {
$notification = $this->addActionButton($notification, $l->t('Call back'));
Expand Down Expand Up @@ -998,7 +998,7 @@ protected function parseCall(INotification $notification, Room $room, IL10N $l):
}
} elseif (\in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) {
if ($this->notificationManager->isPreparingPushNotification() || $this->participantService->hasActiveSessionsInCall($room)) {
$notification = $this->addActionButton($notification, $l->t('Join call'));
$notification = $this->addActionButton($notification, $l->t('Join call'), true, true);
$subject = $l->t('A group call has started in {call}');
} else {
$notification = $this->addActionButton($notification, $l->t('View chat'), false);
Expand Down Expand Up @@ -1056,7 +1056,7 @@ protected function parsePasswordRequest(INotification $notification, Room $room,

$callIsActive = $this->notificationManager->isPreparingPushNotification() || $this->participantService->hasActiveSessionsInCall($room);
if ($callIsActive) {
$notification = $this->addActionButton($notification, $l->t('Answer call'));
$notification = $this->addActionButton($notification, $l->t('Answer call'), true, true);
} else {
$notification = $this->addActionButton($notification, $l->t('Call back'));
}
Expand Down Expand Up @@ -1095,11 +1095,16 @@ protected function parsePasswordRequest(INotification $notification, Room $room,
return $notification;
}

protected function addActionButton(INotification $notification, string $label, bool $primary = true): INotification {
protected function addActionButton(INotification $notification, string $label, bool $primary = true, bool $directCallLink = false): INotification {
$link = $notification->getLink();
if ($directCallLink) {
$link .= '#direct-call';
}

$action = $notification->createAction();
$action->setLabel($label)
->setParsedLabel($label)
->setLink($notification->getLink(), IAction::TYPE_WEB)
->setLink($link, IAction::TYPE_WEB)
->setPrimary($primary);

$notification->addParsedAction($action);
Expand Down
12 changes: 10 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,10 @@ export default {
} else if (to.name === 'notfound') {
this.setPageTitle('')
}

if (to.hash === '#direct-call') {
emit('talk:media-settings:show')
}
})

if (getCurrentUser()) {
Expand Down Expand Up @@ -481,6 +485,10 @@ export default {
})
}

if (this.$route.hash === '#direct-call') {
emit('talk:media-settings:show')
}

subscribe('notifications:action:execute', this.interceptNotificationActions)
subscribe('notifications:notification:received', this.interceptNotificationReceived)
},
Expand All @@ -507,12 +515,12 @@ export default {
return
}

const [token, messageId] = load.split('#message_')
const [token, hash] = load.split('#')
this.$router.push({
name: 'conversation',
hash: hash ? `#${hash}` : '',
params: {
token,
hash: messageId ? `#message_${messageId}` : '',
},
})

Expand Down
Loading