Skip to content

Commit f04b1ea

Browse files
committed
Only change notification language if needed.
1 parent 1ec4435 commit f04b1ea

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

notification/method/webpush.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,12 @@ public function notify()
154154
{
155155
$data = $notification->get_insert_array();
156156

157-
// Choose receiving user's language
157+
// Change notification language if needed only
158158
$recipient_data = $this->user_loader->get_user($notification->user_id);
159-
$this->language->set_user_language($recipient_data['user_lang'], $this->language->get_used_language() !== $recipient_data['user_lang']);
159+
if ($this->language->get_used_language() !== $recipient_data['user_lang'])
160+
{
161+
$this->language->set_user_language($recipient_data['user_lang'], true);
162+
}
160163

161164
$data += [
162165
'push_data' => json_encode([
@@ -176,8 +179,11 @@ public function notify()
176179

177180
$insert_buffer->flush();
178181

179-
// Restore current user's language
180-
$this->language->set_user_language($this->user->data['user_lang'], $this->language->get_used_language() !== $this->user->data['user_lang']);
182+
// Restore current user's language if needed only
183+
if ($this->language->get_used_language() !== $this->user->data['user_lang'])
184+
{
185+
$this->language->set_user_language($this->user->data['user_lang'], true);
186+
}
181187

182188
$this->notify_using_webpush($notify_users);
183189

0 commit comments

Comments
 (0)