summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Chat/ChatManager.php14
-rw-r--r--lib/Controller/ChatController.php2
-rw-r--r--src/composables/useViewer.js69
-rw-r--r--tests/integration/features/chat-2/unread-messages.feature4
4 files changed, 70 insertions, 19 deletions
diff --git a/lib/Chat/ChatManager.php b/lib/Chat/ChatManager.php
index 1de8610ec..34f348737 100644
--- a/lib/Chat/ChatManager.php
+++ b/lib/Chat/ChatManager.php
@@ -29,6 +29,7 @@ use OC\Memcache\ArrayCache;
use OC\Memcache\NullCache;
use OCA\Talk\Events\ChatEvent;
use OCA\Talk\Events\ChatParticipantEvent;
+use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\Poll;
use OCA\Talk\Participant;
@@ -199,6 +200,17 @@ class ChatManager {
$this->notifier->notifyOtherParticipant($chat, $comment, [], false);
}
+ if (!$shouldSkipLastMessageUpdate && $sendNotifications) {
+ // Update the read-marker for the author when it is a "relevant" system message,
+ // e.g. sharing an item to the chat
+ try {
+ $participant = $this->participantService->getParticipantByActor($chat, $actorType, $actorId);
+ $this->participantService->updateLastReadMessage($participant, (int) $comment->getId());
+ } catch (ParticipantNotFoundException) {
+ // Participant not found => No read-marker update needed
+ }
+ }
+
$this->dispatcher->dispatch(self::EVENT_AFTER_SYSTEM_MESSAGE_SEND, $event);
} catch (NotFoundException $e) {
}
@@ -280,6 +292,8 @@ class ChatManager {
try {
$this->commentsManager->save($comment);
+ $this->participantService->updateLastReadMessage($participant, (int) $comment->getId());
+
// Update last_message
if ($comment->getActorType() !== 'bots' || $comment->getActorId() === 'changelog') {
$this->roomService->setLastMessage($chat, $comment);
diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php
index ea410faf8..f306d5ccd 100644
--- a/lib/Controller/ChatController.php
+++ b/lib/Controller/ChatController.php
@@ -179,8 +179,6 @@ class ChatController extends AEnvironmentAwareController {
return $response;
}
- $this->participantService->updateLastReadMessage($this->participant, (int) $comment->getId());
-
$data = $chatMessage->toArray($this->getResponseFormat());
if ($parentMessage instanceof Message) {
$data['parent'] = $parentMessage->toArray($this->getResponseFormat());
diff --git a/src/composables/useViewer.js b/src/composables/useViewer.js
index 9f786f5fe..156c41e6f 100644
--- a/src/composables/useViewer.js
+++ b/src/composables/useViewer.js
@@ -17,6 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+import { computed, nextTick, ref, watch } from 'vue'
+
import { useIsInCall } from './useIsInCall.js'
import { useStore } from './useStore.js'
@@ -30,18 +32,58 @@ import { useStore } from './useStore.js'
*/
/**
+ * FIXME Remove this hack once it is possible to set the parent
+ * element of the viewer.
+ * By default the viewer is a sibling of the fullscreen element, so
+ * it is not visible when in fullscreen mode. It is not possible to
+ * specify the parent nor to know when the viewer was actually
+ * opened, so for the time being it is reparented if needed shortly
+ * after calling it.
+ *
+ * @see https://github.com/nextcloud/viewer/issues/995
+ *
+ * @param {boolean} isFullscreen - is currently in fullscreen mode
+ */
+function reparentViewer(isFullscreen) {
+ const viewerElement = document.getElementById('viewer')
+
+ if (isFullscreen) {
+ // When changed to the fullscreen mode, Viewer should be moved to the talk app
+ document.getElementById('content-vue').appendChild(viewerElement)
+ } else {
+ // In normal mode if it was in fullscreen before, move back to body
+ // Otherwise it will be overlapped by web-page's header
+ document.body.appendChild(viewerElement)
+ }
+}
+
+/**
+ * Is Viewer currently opened
+ *
+ * @type {import('vue').Ref<boolean>}
+ */
+const isViewerOpen = ref(false)
+
+/**
* Composable with OCA.Viewer helpers
*
- * @return {{ openViewer: OpenViewer }}
+ * @return {{ openViewer: OpenViewer, isViewerOpen: import('vue').Ref<boolean> }}
*/
export function useViewer() {
const store = useStore()
const isInCall = useIsInCall()
+ const isFullscreen = computed(() => store.getters.isFullscreen())
+
+ watch(isFullscreen, () => {
+ if (isViewerOpen.value) {
+ reparentViewer(isFullscreen.value)
+ }
+ })
/**
* @type {OpenViewer}
*/
- const openViewer = (path, list) => {
+ const openViewer = async (path, list) => {
if (!OCA.Viewer) {
return false
}
@@ -59,26 +101,23 @@ export function useViewer() {
path,
list,
onClose: () => {
+ isViewerOpen.value = false
store.dispatch('setCallViewMode', { isViewerOverlay: false })
},
})
- // FIXME Remove this hack once it is possible to set the parent
- // element of the viewer.
- // By default the viewer is a sibling of the fullscreen element, so
- // it is not visible when in fullscreen mode. It is not possible to
- // specify the parent nor to know when the viewer was actually
- // opened, so for the time being it is reparented if needed shortly
- // after calling it.
- // @see https://github.com/nextcloud/viewer/issues/995
- setTimeout(() => {
- if (store.getters.isFullscreen()) {
- document.getElementById('content-vue').appendChild(document.getElementById('viewer'))
- }
- }, 1000)
+ // Wait Viewer to be mounted
+ await nextTick()
+
+ isViewerOpen.value = true
+
+ if (isFullscreen.value) {
+ reparentViewer(true)
+ }
}
return {
+ isViewerOpen,
openViewer,
}
}
diff --git a/tests/integration/features/chat-2/unread-messages.feature b/tests/integration/features/chat-2/unread-messages.feature
index 42ee02ac3..a15014189 100644
--- a/tests/integration/features/chat-2/unread-messages.feature
+++ b/tests/integration/features/chat-2/unread-messages.feature
@@ -109,12 +109,12 @@ Feature: chat-2/unread-messages
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200 (v4)
When user "participant1" shares "welcome.txt" with room "group room"
- # Unread counter for sender is not cleared in this case, as it is not
+ # Unread counter for sender is cleared in this case, as it is not
# possible to know whether the file was shared from Talk, which could clear
# the counter, or from the Files app, which should not clear it.
Then user "participant1" is participant of room "group room" (v4)
| unreadMessages |
- | 1 |
+ | 0 |
And user "participant2" is participant of room "group room" (v4)
| unreadMessages |
| 1 |