###############################################################
### A spike is something that you build to prove something. ###
### It's not meant to be used in the actual product.        ###
###############################################################

class SpikesController < ApplicationController

  include ClientHelper

  def facebook_invite

  end

  def listen_in

    if !current_user.admin
      raise JamPermissionError "must be administrator"
    end

    #as_musician = false is the critical search criteria for sessions to list correctly
    @music_sessions = ActiveMusicSession.index(current_user, as_musician: false)

    render :layout => 'web'
  end

  def launch_app
    render :layout => 'web'
  end

  def websocket
    render :layout => false
  end

  def responsive
    render :layout => false
  end

  def subscription

    #Notification.send_reload(MessageFactory::ALL_NATIVE_CLIENTS)

    Notification.send_subscription_message('test', '1', '{"msg": "oh hai 1"}')
    Notification.send_subscription_message('test', '2', '{"msg": "oh hai 2"}')
    render text: 'oh hai'
  end

  def download_jam_track

    jamTrack = JamTrack.find(params[:jam_track_id])
    jamTrackRight = jamTrack.right_for_user(current_user)

    gon.jamTrackId = jamTrack.id
    gon.jamTrackRightId = jamTrackRight.id
    gon.size = params[:size] ? params[:size] : 'large'
    gon.switchState = params[:state]

    render :layout => 'web'
  end

  def jam_track_preview
    gon.jamTrackPlanCode = params[:plan_code]


    render :layout => 'web'
  end

  def site_validate
    render :layout => 'web'
  end

  def recording_source
    render :layout => 'web'
  end

  def musician_search_filter
    # gon.musician_search_meta = MusicianSearch.search_filter_meta
    render :layout => 'web'
  end

  def band_search_filter
    gon.band_search_meta = BandSearch.search_filter_meta
    render :layout => 'web'
  end

end
