revamp GlobalUI.notifyUser
This commit is contained in:
parent
e7b021aa0a
commit
e2a60be417
3 changed files with 39 additions and 15 deletions
|
@ -12,9 +12,11 @@ import NotificationIcon from './NotificationIcon'
|
||||||
|
|
||||||
const GlobalUI = {
|
const GlobalUI = {
|
||||||
notifyTimeout: null,
|
notifyTimeout: null,
|
||||||
|
notifyQueue: [],
|
||||||
|
notifying: false,
|
||||||
lightbox: null,
|
lightbox: null,
|
||||||
init: function(serverData) {
|
init: function(serverData) {
|
||||||
var self = GlobalUI
|
const self = GlobalUI
|
||||||
|
|
||||||
self.Search.init(serverData)
|
self.Search.init(serverData)
|
||||||
self.CreateMap.init(serverData)
|
self.CreateMap.init(serverData)
|
||||||
|
@ -45,7 +47,7 @@ const GlobalUI = {
|
||||||
}, 200, 'easeInCubic', function() { $(this).hide() })
|
}, 200, 'easeInCubic', function() { $(this).hide() })
|
||||||
},
|
},
|
||||||
openLightbox: function(which) {
|
openLightbox: function(which) {
|
||||||
var self = GlobalUI
|
const self = GlobalUI
|
||||||
|
|
||||||
$('.lightboxContent').hide()
|
$('.lightboxContent').hide()
|
||||||
$('#' + which).show()
|
$('#' + which).show()
|
||||||
|
@ -72,7 +74,7 @@ const GlobalUI = {
|
||||||
},
|
},
|
||||||
|
|
||||||
closeLightbox: function(event) {
|
closeLightbox: function(event) {
|
||||||
var self = GlobalUI
|
const self = GlobalUI
|
||||||
|
|
||||||
if (event) event.preventDefault()
|
if (event) event.preventDefault()
|
||||||
|
|
||||||
|
@ -96,23 +98,45 @@ const GlobalUI = {
|
||||||
}
|
}
|
||||||
self.lightbox = null
|
self.lightbox = null
|
||||||
},
|
},
|
||||||
notifyUser: function(message, leaveOpen) {
|
notifyUser: function(message, opts = {}) {
|
||||||
var self = GlobalUI
|
const self = GlobalUI
|
||||||
|
|
||||||
|
if (self.notifying) {
|
||||||
|
self.notifyQueue.push({ message, opts })
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
self._notifyUser(message, opts)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// note: use the wrapper function notifyUser instead of this one
|
||||||
|
_notifyUser: function(message, opts = {}) {
|
||||||
|
const self = GlobalUI
|
||||||
|
|
||||||
|
const { leaveOpen: false, timeOut: 8000 } = opts
|
||||||
|
|
||||||
$('#toast').html(message)
|
$('#toast').html(message)
|
||||||
self.showDiv('#toast')
|
self.showDiv('#toast')
|
||||||
clearTimeout(self.notifyTimeOut)
|
clearTimeout(self.notifyTimeOut)
|
||||||
|
|
||||||
if (!leaveOpen) {
|
if (!leaveOpen) {
|
||||||
self.notifyTimeOut = setTimeout(function() {
|
self.notifyTimeOut = setTimeout(function() {
|
||||||
self.hideDiv('#toast')
|
GlobalUI.clearNotify()
|
||||||
}, 8000)
|
}, timeOut)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.notifying = true
|
||||||
},
|
},
|
||||||
clearNotify: function() {
|
clearNotify: function() {
|
||||||
var self = GlobalUI
|
const self = GlobalUI
|
||||||
|
|
||||||
clearTimeout(self.notifyTimeOut)
|
// if there are messages remaining, display them
|
||||||
self.hideDiv('#toast')
|
if (self.notifyQueue.length > 0) {
|
||||||
|
const { message, opts } = self.notifyQueue.shift()
|
||||||
|
self._notifyUser(message, opts)
|
||||||
|
} else {
|
||||||
|
self.hideDiv('#toast')
|
||||||
|
self.notifying = false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
shareInvite: function(inviteLink) {
|
shareInvite: function(inviteLink) {
|
||||||
clipboard.copy({
|
clipboard.copy({
|
||||||
|
|
|
@ -271,7 +271,7 @@ const Map = {
|
||||||
DOWNLOAD
|
DOWNLOAD
|
||||||
</a>`
|
</a>`
|
||||||
GlobalUI.notifyUser(downloadMessage)
|
GlobalUI.notifyUser(downloadMessage)
|
||||||
$('#map-screenshot-download-link').click()
|
//$('#map-screenshot-download-link').click()
|
||||||
},
|
},
|
||||||
uploadMapScreenshot: () => {
|
uploadMapScreenshot: () => {
|
||||||
const canvas = Map.getMapCanvasForScreenshots()
|
const canvas = Map.getMapCanvasForScreenshots()
|
||||||
|
|
|
@ -149,7 +149,7 @@ export const invitedToCall = self => inviter => {
|
||||||
notifyText += username + ' is inviting you to a conversation. Join live?'
|
notifyText += username + ' is inviting you to a conversation. Join live?'
|
||||||
notifyText += ' <button type="button" class="toast-button button yes">Yes</button>'
|
notifyText += ' <button type="button" class="toast-button button yes">Yes</button>'
|
||||||
notifyText += ' <button type="button" class="toast-button button btn-no no">No</button>'
|
notifyText += ' <button type="button" class="toast-button button btn-no no">No</button>'
|
||||||
GlobalUI.notifyUser(notifyText, true)
|
GlobalUI.notifyUser(notifyText, { leaveOpen: true })
|
||||||
$('#toast button.yes').click(e => self.acceptCall(inviter))
|
$('#toast button.yes').click(e => self.acceptCall(inviter))
|
||||||
$('#toast button.no').click(e => self.denyCall(inviter))
|
$('#toast button.no').click(e => self.denyCall(inviter))
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ export const invitedToJoin = self => inviter => {
|
||||||
var notifyText = username + ' is inviting you to the conversation. Join?'
|
var notifyText = username + ' is inviting you to the conversation. Join?'
|
||||||
notifyText += ' <button type="button" class="toast-button button yes">Yes</button>'
|
notifyText += ' <button type="button" class="toast-button button yes">Yes</button>'
|
||||||
notifyText += ' <button type="button" class="toast-button button btn-no no">No</button>'
|
notifyText += ' <button type="button" class="toast-button button btn-no no">No</button>'
|
||||||
GlobalUI.notifyUser(notifyText, true)
|
GlobalUI.notifyUser(notifyText, { leaveOpen: true })
|
||||||
$('#toast button.yes').click(e => self.joinCall())
|
$('#toast button.yes').click(e => self.joinCall())
|
||||||
$('#toast button.no').click(e => self.denyInvite(inviter))
|
$('#toast button.no').click(e => self.denyInvite(inviter))
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ export const callInProgress = self => () => {
|
||||||
var notifyText = "There's a conversation happening, want to join?"
|
var notifyText = "There's a conversation happening, want to join?"
|
||||||
notifyText += ' <button type="button" class="toast-button button yes">Yes</button>'
|
notifyText += ' <button type="button" class="toast-button button yes">Yes</button>'
|
||||||
notifyText += ' <button type="button" class="toast-button button btn-no no">No</button>'
|
notifyText += ' <button type="button" class="toast-button button btn-no no">No</button>'
|
||||||
GlobalUI.notifyUser(notifyText, true)
|
GlobalUI.notifyUser(notifyText, { leaveOpen: true })
|
||||||
$('#toast button.yes').click(e => self.joinCall())
|
$('#toast button.yes').click(e => self.joinCall())
|
||||||
$('#toast button.no').click(e => GlobalUI.clearNotify())
|
$('#toast button.no').click(e => GlobalUI.clearNotify())
|
||||||
ChatView.conversationInProgress()
|
ChatView.conversationInProgress()
|
||||||
|
@ -212,7 +212,7 @@ export const callStarted = self => () => {
|
||||||
var notifyText = "There's a conversation starting, want to join?"
|
var notifyText = "There's a conversation starting, want to join?"
|
||||||
notifyText += ' <button type="button" class="toast-button button">Yes</button>'
|
notifyText += ' <button type="button" class="toast-button button">Yes</button>'
|
||||||
notifyText += ' <button type="button" class="toast-button button btn-no">No</button>'
|
notifyText += ' <button type="button" class="toast-button button btn-no">No</button>'
|
||||||
GlobalUI.notifyUser(notifyText, true)
|
GlobalUI.notifyUser(notifyText, { leaveOpen: true })
|
||||||
$('#toast button.yes').click(e => self.joinCall())
|
$('#toast button.yes').click(e => self.joinCall())
|
||||||
$('#toast button.no').click(e => GlobalUI.clearNotify())
|
$('#toast button.no').click(e => GlobalUI.clearNotify())
|
||||||
ChatView.conversationInProgress()
|
ChatView.conversationInProgress()
|
||||||
|
|
Loading…
Add table
Reference in a new issue