From 08b2de242ed0985d6ea14d456a72d261889a1176 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Mon, 1 Aug 2022 21:49:33 -0500 Subject: [PATCH] Create context.JK.isQWebEngine property instead of gon.isQWebEngine --- ruby/lib/jam_ruby/models/ars.rb | 2 +- web/Gemfile.lock | 3 +++ web/app/assets/javascripts/globals.js | 2 ++ web/app/assets/javascripts/utils.js | 2 +- web/app/helpers/client_helper.rb | 2 -- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ruby/lib/jam_ruby/models/ars.rb b/ruby/lib/jam_ruby/models/ars.rb index 148ef8b30..1d2777864 100644 --- a/ruby/lib/jam_ruby/models/ars.rb +++ b/ruby/lib/jam_ruby/models/ars.rb @@ -11,4 +11,4 @@ module JamRuby Ars.where(active: true, beta: beta).where('ip is not NULL').where("ip != ''").all end end -end \ No newline at end of file +end diff --git a/web/Gemfile.lock b/web/Gemfile.lock index 1a150ba57..35befb7fa 100644 --- a/web/Gemfile.lock +++ b/web/Gemfile.lock @@ -554,6 +554,8 @@ GEM rabl (0.13.1) activesupport (>= 2.3.14) rack (1.6.13) + rack-cors (1.0.6) + rack (>= 1.6.0) rack-oauth2 (1.12.0) activesupport attr_required @@ -873,6 +875,7 @@ DEPENDENCIES puma quiet_assets rabl (= 0.13.1) + rack-cors (~> 1.0, >= 1.0.6) rack-test rails (= 4.2.8) rails-assets-bluebird! diff --git a/web/app/assets/javascripts/globals.js b/web/app/assets/javascripts/globals.js index ca8a0765d..338b696fb 100644 --- a/web/app/assets/javascripts/globals.js +++ b/web/app/assets/javascripts/globals.js @@ -8,6 +8,8 @@ context.JK = context.JK || {}; var logger = context.JK.logger; + context.JK.isQWebEngine = !!navigator.userAgent.match("jamkazam") + context.JK.MIDI_TRACK = 100 context.JK.CLIENT_ROLE = { diff --git a/web/app/assets/javascripts/utils.js b/web/app/assets/javascripts/utils.js index 4d36bf19f..70e3b2cd1 100644 --- a/web/app/assets/javascripts/utils.js +++ b/web/app/assets/javascripts/utils.js @@ -1303,7 +1303,7 @@ var opts = options || {} - opts = $.extend({}, {nativeTouch: !gon.isQWebEngine && gon.global.env != "test", cutOff: 7}, opts) + opts = $.extend({}, {nativeTouch: !context.JK.isQWebEngine && gon.global.env != "test", cutOff: 7}, opts) $select.each(function (index) { var $item = $(this); diff --git a/web/app/helpers/client_helper.rb b/web/app/helpers/client_helper.rb index 6912ed795..18302e153 100644 --- a/web/app/helpers/client_helper.rb +++ b/web/app/helpers/client_helper.rb @@ -1,7 +1,6 @@ module ClientHelper # is this for *certain* the native client (no overrides allowed)? - # this ends up as gon.isQWebEngine def is_certified_native_client? # is this the native client or browser? user_agent = request.env["HTTP_USER_AGENT"] @@ -86,7 +85,6 @@ module ClientHelper # let javascript have access to the server's opinion if this is a native client gon.isNativeClient = @nativeClient - gon.isQWebEngine = is_certified_native_client? gon.use_cached_session_scores = Rails.application.config.use_cached_session_scores gon.allow_both_find_algos = Rails.application.config.allow_both_find_algos