jam-cloud/web/app/assets/javascripts/client_init.js.coffee

47 lines
1.3 KiB
CoffeeScript
Raw Normal View History

# one time init stuff for the /client view
$ = jQuery
context = window
context.JK ||= {};
logger = context.JK.logger
context.JK.ClientInit = class ClientInit
constructor: () ->
@gearUtils = context.JK.GearUtils
@ALERT_NAMES = context.JK.ALERT_NAMES;
@lastCheckedBroadcast = null
init: () =>
if context.gon.isNativeClient
this.nativeClientInit()
context.JK.onBackendEvent(@ALERT_NAMES.WINDOW_OPEN_FOREGROUND_MODE, 'client_init', @watchBroadcast);
this.watchBroadcast()
if context.jamClient.RegisterSessionJoinLeaveRequestCallBack?
context.jamClient.RegisterSessionJoinLeaveRequestCallBack("SessionStore.handleJoinLeaveRequestCallback")
checkBroadcast: () =>
2016-03-10 22:09:46 +00:00
promise = window.BroadcastActions.load.trigger()
if promise
promise.catch(() ->
false
)
watchBroadcast: () =>
if context.JK.currentUserId
# create a 15 second buffer to not check too fast for some reason (like the client firing multiple foreground events)
if !@lastCheckedBroadcast? || @lastCheckedBroadcast.getTime() < new Date().getTime() - 15000
@lastCheckedBroadcast = new Date()
setTimeout(@checkBroadcast, 3000)
nativeClientInit: () =>
@gearUtils.bootstrapDefaultPlaybackProfile();
context.VideoActions.checkPromptConfigureVideo()