38 lines
1.0 KiB
CoffeeScript
38 lines
1.0 KiB
CoffeeScript
# one time init stuff for the /client view
|
|
|
|
$ = jQuery
|
|
context = window
|
|
context.JK ||= {};
|
|
broadcastActions = @BroadcastActions
|
|
|
|
context.JK.ClientInit = class ClientInit
|
|
constructor: () ->
|
|
@logger = context.JK.logger
|
|
@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()
|
|
|
|
checkBroadcast: () =>
|
|
broadcastActions.load.triggerPromise()
|
|
|
|
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();
|
|
|
|
|