Skip to content

Commit 5552179

Browse files
authored
Update smalltalk.view
1 parent ad90596 commit 5552179

File tree

1 file changed

+60
-25
lines changed

1 file changed

+60
-25
lines changed

src/themes/smalltalk.view

Lines changed: 60 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,18 @@
347347
$('#messages').append($li);
348348
$('#list').animate({scrollTop: $('#messages').height()}, 'fast');
349349
break;
350+
case 'session-timeout':
351+
$li = $("<li />");
352+
$li.html("System Notification:\t" + $data.user + " left from this conversation.");
353+
$('#messages').append($li);
354+
$('#list').animate({scrollTop: $('#messages').height()}, 'fast');
355+
break;
356+
case 'expired':
357+
$li = $("<li />");
358+
$li.html("System Notification:\tIt's an expired conversation, you have to refresh the current page or request a new meeting code.");
359+
$('#messages').append($li);
360+
$('#list').animate({scrollTop: $('#messages').height()}, 'fast');
361+
break;
350362
default:
351363
timer.setAction(function(){
352364
document.title = $_user + " is typing" + dotted;
@@ -369,26 +381,40 @@
369381
data: { cmd: cmd }
370382
}).done(function( msg ) {
371383
if(msg.error == "missing user") {
372-
if (user) {
373-
$.ajax({
374-
type: "POST",
375-
url: "[%LINK:talk/start%]/"+ user
376-
}).done(function( msg ) {});
377-
}
378-
else {
379-
$("#modal").modal();
380-
}
381-
}
382-
383-
if(msg.error == "expired") {
384-
if(confirm("The conversation is expired, Do you want to reload the conversation?")) {
385-
$.ajax({
386-
type: "POST",
387-
url: $('#link').text()
388-
}).done(function( msg ) {});
389-
}
390-
}
384+
if (user) {
385+
$.ajax({
386+
type: "POST",
387+
url: "[%LINK:talk/start%]/"+ user
388+
}).done(function( msg ) {});
389+
}
390+
else {
391+
$("#modal").modal();
392+
}
393+
}
391394
}).fail(function( msg ) {
395+
switch(msg.responseJSON.error) {
396+
case 'session-timeout':
397+
$li = $("<li />");
398+
$li.html("System Notification:\t" + $data.user + " left from this conversation.");
399+
$('#messages').append($li);
400+
$('#list').animate({scrollTop: $('#messages').height()}, 'fast');
401+
402+
if(confirm("Your session is timed out, Do you want to reload the conversation?")) {
403+
$.ajax({
404+
type: "POST",
405+
url: $('#link').text()
406+
}).done(function( msg ) {});
407+
}
408+
break;
409+
case 'expired':
410+
$li = $("<li />");
411+
$li.html("System Notification:\tIt's an expired conversation, you have to refresh the current page or request a new meeting code.");
412+
$('#messages').append($li);
413+
$('#list').animate({scrollTop: $('#messages').height()}, 'fast');
414+
break;
415+
default:break;
416+
}
417+
392418
console.log('Fail.');
393419
console.log(msg);
394420
});
@@ -413,13 +439,22 @@
413439
$.getJSON( "[%LINK:talk/update%]/{%meeting_code%}/{%session_id%}", function(data) {
414440
update(data);
415441
is_running = false;
416-
}).done(function() {
442+
}).done(function( msg ) {
417443
autoupdate();
418444
is_running = false;
419445
}).fail(function( msg ) {
420-
connection_timer.start();
421-
is_running = false;
422-
console.log(msg);
446+
msg = msg.responseJSON;
447+
if(msg.error == "expired") {
448+
command("expired");
449+
}
450+
else if(msg.error == "session-timeout") {
451+
command("session-timeout");
452+
}
453+
else {
454+
connection_timer.start();
455+
is_running = false;
456+
console.log(msg);
457+
}
423458
});
424459
}
425460
}
@@ -630,7 +665,7 @@
630665
<input id="attachment" name="attachment" type="file" class="file-loading btn-default" multiple="true" />
631666
<br />
632667
<input type="button" id="button" value="Send" class="btn btn-primary" />
633-
<!--<input type="button" id="test" value="Test" class="btn btn-secondary" />-->
668+
<input type="button" id="test" value="Test" class="btn btn-secondary" />
634669
</form>
635670
</div>
636671

@@ -673,7 +708,7 @@
673708

674709
<footer class="footer">
675710
<div class="container">
676-
<p class="text-muted"> © 2016 </p>
711+
<p class="text-muted"> © 2017 </p>
677712
</div>
678713
</footer>
679714

0 commit comments

Comments
 (0)