You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2018/11/26 14:31:14 UTC
[openmeetings] branch master updated: [OPENMEETINGS-1966] chat
notifiactions will play on open chat
This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/master by this push:
new ef0676a [OPENMEETINGS-1966] chat notifiactions will play on open chat
ef0676a is described below
commit ef0676a15f46751353101d01e45e42ed8c33e001
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Mon Nov 26 21:30:56 2018 +0700
[OPENMEETINGS-1966] chat notifiactions will play on open chat
---
.../apache/openmeetings/web/user/chat/Chat.java | 1 +
.../apache/openmeetings/web/user/chat/raw-chat.js | 43 ++++++++++++----------
pom.xml | 11 ------
3 files changed, 25 insertions(+), 30 deletions(-)
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/Chat.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/Chat.java
index 1bb2d04..f3c7209 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/Chat.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/Chat.java
@@ -141,6 +141,7 @@ public class Chat extends Panel {
public CharSequence getReinit() {
StringBuilder sb = new StringBuilder("Chat.reinit(")
.append(new JSONObject()
+ .put("userId", getUserId())
.put("all", getString("1494"))
.put("room", getString("406"))
.put("sendOnEnter", OpenmeetingsVariables.getChatSenndOnEnter()).toString())
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/raw-chat.js b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/raw-chat.js
index 4f887f0..f15537c 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/raw-chat.js
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/raw-chat.js
@@ -15,7 +15,8 @@ var Chat = function() {
;
let p, pp, ctrl, icon, tabs, openedHeight = "345px", openedWidth = "300px", allPrefix = "All"
, roomPrefix = "Room ", typingTimer, audio, roomMode = false, globalWidth = 600
- , editor = $('#chatMessage .wysiwyg-editor'), muted = false, sendOn, DEF_SEND;
+ , editor = $('#chatMessage .wysiwyg-editor'), muted = false, sendOn, DEF_SEND
+ , userId;
;
try {
@@ -116,6 +117,7 @@ var Chat = function() {
return !!$("#chatTabs").data("ui-tabs");
}
function _reinit(opts) {
+ userId = opts.userId;
allPrefix = opts.all;
roomPrefix = opts.room;
DEF_SEND = opts.sendOnEnter === true ? SEND_ENTER : SEND_CTRL;
@@ -211,25 +213,12 @@ var Chat = function() {
}
function _addMessage(m) {
if ($('#chat').length > 0 && m && m.type === "chat") {
- if (isClosed()) {
- ctrl.addClass('ui-state-highlight');
- if (p.is(':visible') && !muted) {
- const playPromise = audio.play();
-
- // In browsers that don’t yet support this functionality,
- // playPromise won’t be defined.
- if (playPromise !== undefined) {
- playPromise.then(function() {
- // Automatic playback started!
- }).catch(function() {
- // Automatic playback failed.
- });
- }
- }
- }
- let msg, cm;
+ let msg, cm, notify = false;
while (!!(cm = m.msg.pop())) {
let area = $('#' + cm.scope);
+ if (cm.from.id !== userId) {
+ notify = true;
+ }
msg = OmUtil.tmpl('#chat-msg-template', msgIdPrefix + cm.id)
msg.find('.user-row').css('background-image', 'url(' + (!!cm.from.img ? cm.from.img : './profile/' + cm.from.id + '?anticache=' + Date.now()) + ')');
msg.find('.from').addClass(align).data('user-id', cm.from.id).html(cm.from.name || cm.from.displayName);
@@ -263,6 +252,22 @@ var Chat = function() {
_scrollDown(area);
}
}
+ if (notify) {
+ ctrl.addClass('ui-state-highlight');
+ if (p.is(':visible') && !muted) {
+ const playPromise = audio.play();
+
+ // In browsers that don’t yet support this functionality,
+ // playPromise won’t be defined.
+ if (playPromise !== undefined) {
+ playPromise.then(function() {
+ // Automatic playback started!
+ }).catch(function() {
+ // Automatic playback failed.
+ });
+ }
+ }
+ }
emoticon.animate();
}
}
@@ -353,7 +358,7 @@ var Chat = function() {
}
function _setRoomMode(_mode) {
roomMode = _mode;
- _reinit({all: allPrefix, room: roomPrefix, sendOnEnter: sendOn === SEND_ENTER});
+ _reinit({userId: userId, all: allPrefix, room: roomPrefix, sendOnEnter: sendOn === SEND_ENTER});
}
function _scrollDown(area) {
area.animate({
diff --git a/pom.xml b/pom.xml
index b96e0de..a5906d2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -393,20 +393,9 @@
<pluginRepository>
<id>apache-snapshots</id>
<url>https://repository.apache.org/content/groups/snapshots</url>
- </pluginRepository>
- <pluginRepository>
- <id>sonatype-snapshots</id>
- <name>Sonatype Snapshots Repository</name>
- <url>http://oss.sonatype.org/content/repositories/snapshots/</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
- <pluginRepository>
- <id>openmeetings-bintray</id>
- <url>https://dl.bintray.com/openmeetings/maven</url>
- <releases><enabled>true</enabled></releases>
- <snapshots><enabled>false</enabled></snapshots>
- </pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>