Skip to content

Commit

Permalink
Dialog.realtimeProgress response changed
Browse files Browse the repository at this point in the history
  • Loading branch information
kjantzer committed Jan 31, 2024
1 parent 01a6fc5 commit 4272fa0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions realtime/client/progress-notif.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Dialog from '../../presenters/dialog'
import realtime from './index'

Dialog.realtimeProgress = function(syncPath, opts){
Dialog.realtimeProgress = function(syncPath, opts, notifOpts={}){

if( (opts.title || opts.body) && !opts.btns )
opts.btns = false

let d = new Dialog.alert(opts)
let resolve

function progress(resp){
function progress(resp){

if( opts.onProgress )
opts.onProgress(resp)
Expand All @@ -25,13 +25,15 @@ Dialog.realtimeProgress = function(syncPath, opts){

realtime.socket.on(syncPath, progress)

return new Promise(_resolve=>{
let promise = new Promise(_resolve=>{
resolve = _resolve

d.notif({anchor: 'top-right', autoClose: false, closeOnClick: false})
d.notif({anchor: 'top-right', autoClose: false, closeOnClick: false, ...notifOpts})

}).then(r=>{
d.close()
realtime.socket.off(syncPath, progress)
})

return {promise, resolve, dialog: d}
}

0 comments on commit 4272fa0

Please sign in to comment.