@@ -49,7 +49,7 @@ function IASChatProvider(config) {
49
49
50
50
function printInterface ( container ) {
51
51
// Compressed version of html/chat.html turned to string
52
- var ias = '<div id=\"iasProvider\"><div id=\"iasProvider_unassigned-chat\"><h3>Unassigned Users:</h3><ul class=\"iasProvider_users-chat\"></ul></div><div id=\"iasProvider_assigned-chat\"><h3>Your Users:</h3><ul class=\"iasProvider_users-chat\"></ul></div></div><style>#iasProvider {font-family: \"Roboto\",\"Helvetica\",\"Arial\",sans-serif!important;}.iasProvider_users-chat {list-style: none;margin: 0;padding: 0;}.iasProvider_users-chat li div {display: inline-block;vertical-align: middle;}.iasProvider_users-chat li div.iasProvider_users-chat-pic {box-sizing: border-box;padding: 8px 16px;width: 72px;}.iasProvider_users-chat li div.iasProvider_users-chat-pic img {border-radius: 50%;height: 40px;width: 40px;}.iasProvider_users-chat li div.iasProvider_users-chat-name {font-size: 16px;}</style>'
52
+ var ias = '<div id=\"iasProvider\"><div id=\"iasProvider_unassigned-chat\"><h3>Unassigned Users:</h3><ul class=\"iasProvider_users-chat\"></ul></div><div id=\"iasProvider_assigned-chat\"><h3>Your Users:</h3><ul class=\"iasProvider_users-chat\"></ul></div></div><style>#iasProvider {font-family: \"Roboto\",\"Helvetica\",\"Arial\",sans-serif!important;}.iasProvider_users-chat {list-style: none;margin: 0;padding: 0;}.iasProvider_users-chat-unread {font-weight: bold;}.iasProvider_users-chat-message {font-weight: lighter;font-family: .8em;}.iasProvider_users-chat li div {display: inline-block;vertical-align: middle;}.iasProvider_users-chat li div.iasProvider_users-chat-pic {box-sizing: border-box;padding: 8px 16px;width: 72px;}.iasProvider_users-chat li div.iasProvider_users-chat-pic img {border-radius: 50%;height: 40px;width: 40px;}.iasProvider_users-chat li div.iasProvider_users-chat-name {font-size: 16px;}</style>'
53
53
54
54
// Also add the provider styles from css/provider-style.css
55
55
// ias += '';
@@ -101,10 +101,25 @@ function IASChatProvider(config) {
101
101
102
102
var supporter = data . supporter . uid || data . supporter ;
103
103
104
+ var read = true ;
105
+
106
+ if ( typeof data . lastMessage !== 'undefined' && typeof data . lastMessage . read !== 'undefined' && ! data . lastMessage . read ) {
107
+ read = false ;
108
+ }
109
+
104
110
var user = document . createElement ( 'li' ) ;
105
111
user . setAttribute ( "data-cid" , data . uid ) ;
106
112
user . setAttribute ( "data-supporter" , supporter ) ;
113
+
114
+ if ( read ) {
107
115
user . innerHTML = '<div class="iasProvider_users-chat-pic"><img src="' + data . pic + '"></div><div class="iasProvider_users-chat-name">' + data . name + '</div>' ;
116
+ } else {
117
+ var message = data . lastMessage . text ;
118
+ if ( data . lastMessage . text . length > 20 )
119
+ message = data . lastMessage . text . slice ( 0 , 20 ) + '...' ;
120
+
121
+ user . innerHTML = '<div class="iasProvider_users-chat-pic"><img src="' + data . pic + '"></div><div class="iasProvider_users-chat-name iasProvider_users-chat-unread">' + data . name + '<br><span class="iasProvider_users-chat-message">' + message + '</span></div>' ;
122
+ }
108
123
109
124
user . addEventListener ( 'click' , usersChatManagement , false ) ;
110
125
0 commit comments