mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2025-01-09 00:20:08 +00:00
Add reload button to error messages
This commit is contained in:
parent
c1f8eb15f1
commit
bf55534b9f
@ -32,6 +32,7 @@ exposed by a function if necessary.
|
|||||||
isActive = true
|
isActive = true
|
||||||
newMessageCount = 0
|
newMessageCount = 0
|
||||||
chatSession = Date.now()
|
chatSession = Date.now()
|
||||||
|
errorVisible = false
|
||||||
|
|
||||||
remainingFailures = 3
|
remainingFailures = 3
|
||||||
|
|
||||||
@ -281,15 +282,8 @@ Enable duplicate tab detection.
|
|||||||
$(window).on 'storage', (event) ->
|
$(window).on 'storage', (event) ->
|
||||||
if event.originalEvent.key is 'be.bastelstu.chat.session'
|
if event.originalEvent.key is 'be.bastelstu.chat.session'
|
||||||
if event.originalEvent.newValue isnt chatSession
|
if event.originalEvent.newValue isnt chatSession
|
||||||
loading = true
|
showError WCF.Language.get 'chat.general.error.duplicateTab'
|
||||||
pe.refreshRoomList.stop()
|
|
||||||
pe.getMessages.stop()
|
|
||||||
|
|
||||||
$("""<div id="timsChatLoadingErrorDialog">#{WCF.Language.get('chat.general.error.duplicateTab')}</div>""").appendTo('body') unless $.wcfIsset('timsChatLoadingErrorDialog')
|
|
||||||
$('#timsChatLoadingErrorDialog').wcfDialog
|
|
||||||
closable: false
|
|
||||||
title: WCF.Language.get('wcf.global.error.title')
|
|
||||||
|
|
||||||
Ask for permissions to use Desktop notifications when notifications are activated.
|
Ask for permissions to use Desktop notifications when notifications are activated.
|
||||||
|
|
||||||
if window.Notification?
|
if window.Notification?
|
||||||
@ -384,17 +378,10 @@ Fetch new messages from the server and pass them to `handleMessages`. The userli
|
|||||||
error: ->
|
error: ->
|
||||||
console.error "Message loading failed, #{--remainingFailures} remaining"
|
console.error "Message loading failed, #{--remainingFailures} remaining"
|
||||||
if remainingFailures <= 0
|
if remainingFailures <= 0
|
||||||
loading = true
|
|
||||||
|
|
||||||
pe.refreshRoomList.stop()
|
|
||||||
pe.getMessages.stop()
|
|
||||||
freeTheFish()
|
freeTheFish()
|
||||||
console.error 'To many failues, aborting'
|
console.error 'To many failures, aborting'
|
||||||
|
|
||||||
$("""<div id="timsChatLoadingErrorDialog">#{WCF.Language.get('chat.general.error.onMessageLoad')}</div>""").appendTo('body') unless $.wcfIsset('timsChatLoadingErrorDialog')
|
showError WCF.Language.get 'chat.general.error.onMessageLoad'
|
||||||
$('#timsChatLoadingErrorDialog').wcfDialog
|
|
||||||
closable: false
|
|
||||||
title: WCF.Language.get('wcf.global.error.title')
|
|
||||||
|
|
||||||
complete: ->
|
complete: ->
|
||||||
loading = false
|
loading = false
|
||||||
@ -614,11 +601,37 @@ Show loading icon and prevent switching the room in parallel.
|
|||||||
|
|
||||||
console.log "Found #{data.returnValues.length} rooms"
|
console.log "Found #{data.returnValues.length} rooms"
|
||||||
|
|
||||||
|
Shows an unrecoverable error with the given text.
|
||||||
|
|
||||||
|
showError = (text) ->
|
||||||
|
return if errorVisible
|
||||||
|
errorVisible = true
|
||||||
|
|
||||||
|
loading = true
|
||||||
|
|
||||||
|
pe.refreshRoomList.stop()
|
||||||
|
pe.getMessages.stop()
|
||||||
|
|
||||||
|
errorDialog = $("""
|
||||||
|
<div id="timsChatLoadingErrorDialog">
|
||||||
|
<p>#{text}</p>
|
||||||
|
</div>
|
||||||
|
""").appendTo 'body'
|
||||||
|
|
||||||
|
formSubmit = $("""<div class="formSubmit"></div>""").appendTo errorDialog
|
||||||
|
reloadButton = $("""<button class="buttonPrimary">#{WCF.Language.get 'chat.general.error.reload'}</button>""").appendTo formSubmit
|
||||||
|
reloadButton.on 'click', ->
|
||||||
|
window.location.reload()
|
||||||
|
|
||||||
|
$('#timsChatLoadingErrorDialog').wcfDialog
|
||||||
|
closable: false
|
||||||
|
title: WCF.Language.get('wcf.global.error.title')
|
||||||
|
|
||||||
Bind the given callback to the given event.
|
Bind the given callback to the given event.
|
||||||
|
|
||||||
addListener = (event, callback) ->
|
addListener = (event, callback) ->
|
||||||
return false unless events[event]?
|
return false unless events[event]?
|
||||||
|
|
||||||
events[event].add callback
|
events[event].add callback
|
||||||
|
|
||||||
Remove the given callback from the given event.
|
Remove the given callback from the given event.
|
||||||
|
Loading…
Reference in New Issue
Block a user