Replace usage of getDeviceInfo with isMobile
We were using getDeviceInfo to check whether we were on a desktop or a mobile device. This can be done more simply with isMobile, which means we can stop exporting getDeviceInfo.
This commit is contained in:
parent
0f42bd4a95
commit
fbdfa05f81
|
@ -169,7 +169,6 @@ import {
|
||||||
import { EventEmitter } from './lib/eventemitter.js';
|
import { EventEmitter } from './lib/eventemitter.js';
|
||||||
import { markdownExclusionExt } from './scripts/showdown-exclusion.js';
|
import { markdownExclusionExt } from './scripts/showdown-exclusion.js';
|
||||||
import { NOTE_MODULE_NAME, initAuthorsNote, metadata_keys, setFloatingPrompt, shouldWIAddPrompt } from './scripts/authors-note.js';
|
import { NOTE_MODULE_NAME, initAuthorsNote, metadata_keys, setFloatingPrompt, shouldWIAddPrompt } from './scripts/authors-note.js';
|
||||||
import { getDeviceInfo } from './scripts/RossAscends-mods.js';
|
|
||||||
import { registerPromptManagerMigration } from './scripts/PromptManager.js';
|
import { registerPromptManagerMigration } from './scripts/PromptManager.js';
|
||||||
import { getRegexedString, regex_placement } from './scripts/extensions/regex/engine.js';
|
import { getRegexedString, regex_placement } from './scripts/extensions/regex/engine.js';
|
||||||
import { FILTER_TYPES, FilterHelper } from './scripts/filters.js';
|
import { FILTER_TYPES, FilterHelper } from './scripts/filters.js';
|
||||||
|
@ -6834,8 +6833,7 @@ function openCharacterWorldPopup() {
|
||||||
template.find('.character_name').text(name);
|
template.find('.character_name').text(name);
|
||||||
|
|
||||||
// Not needed on mobile
|
// Not needed on mobile
|
||||||
const deviceInfo = getDeviceInfo();
|
if (!isMobile()) {
|
||||||
if (deviceInfo && deviceInfo.device.type === 'desktop') {
|
|
||||||
$(extraSelect).select2({
|
$(extraSelect).select2({
|
||||||
width: '100%',
|
width: '100%',
|
||||||
placeholder: 'No auxillary Lorebooks set. Click here to select.',
|
placeholder: 'No auxillary Lorebooks set. Click here to select.',
|
||||||
|
@ -7812,7 +7810,7 @@ function addDebugFunctions() {
|
||||||
|
|
||||||
jQuery(async function () {
|
jQuery(async function () {
|
||||||
|
|
||||||
if (isMobile() === true) {
|
if (isMobile()) {
|
||||||
console.debug('hiding movingUI and sheldWidth toggles for mobile');
|
console.debug('hiding movingUI and sheldWidth toggles for mobile');
|
||||||
$('#sheldWidthToggleBlock').hide();
|
$('#sheldWidthToggleBlock').hide();
|
||||||
$('#movingUIModeCheckBlock').hide();
|
$('#movingUIModeCheckBlock').hide();
|
||||||
|
|
|
@ -113,7 +113,7 @@ export function isMobile() {
|
||||||
* Loads device info from the server. Caches the result in sessionStorage.
|
* Loads device info from the server. Caches the result in sessionStorage.
|
||||||
* @returns {object} - The device info object.
|
* @returns {object} - The device info object.
|
||||||
*/
|
*/
|
||||||
export function getDeviceInfo() {
|
function getDeviceInfo() {
|
||||||
let deviceInfo = null;
|
let deviceInfo = null;
|
||||||
|
|
||||||
if (sessionStorage.getItem('deviceInfo')) {
|
if (sessionStorage.getItem('deviceInfo')) {
|
||||||
|
@ -431,8 +431,7 @@ function RA_autoconnect(PrevApi) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function OpenNavPanels() {
|
function OpenNavPanels() {
|
||||||
const deviceInfo = getDeviceInfo();
|
if (!isMobile()) {
|
||||||
if (deviceInfo && deviceInfo.device.type === 'desktop') {
|
|
||||||
//auto-open R nav if locked and previously open
|
//auto-open R nav if locked and previously open
|
||||||
if (LoadLocalBool('NavLockOn') == true && LoadLocalBool('NavOpened') == true) {
|
if (LoadLocalBool('NavLockOn') == true && LoadLocalBool('NavOpened') == true) {
|
||||||
//console.log("RA -- clicking right nav to open");
|
//console.log("RA -- clicking right nav to open");
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
} from '../script.js';
|
} from '../script.js';
|
||||||
import { SECRET_KEYS, writeSecret } from './secrets.js';
|
import { SECRET_KEYS, writeSecret } from './secrets.js';
|
||||||
import { delay } from './utils.js';
|
import { delay } from './utils.js';
|
||||||
import { getDeviceInfo } from './RossAscends-mods.js';
|
import { isMobile } from './RossAscends-mods.js';
|
||||||
import { autoSelectInstructPreset } from './instruct-mode.js';
|
import { autoSelectInstructPreset } from './instruct-mode.js';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
@ -303,8 +303,7 @@ jQuery(function () {
|
||||||
$('#horde_kudos').on('click', showKudos);
|
$('#horde_kudos').on('click', showKudos);
|
||||||
|
|
||||||
// Not needed on mobile
|
// Not needed on mobile
|
||||||
const deviceInfo = getDeviceInfo();
|
if (!isMobile()) {
|
||||||
if (deviceInfo && deviceInfo.device.type === 'desktop') {
|
|
||||||
$('#horde_model').select2({
|
$('#horde_model').select2({
|
||||||
width: '100%',
|
width: '100%',
|
||||||
placeholder: 'Select Horde models',
|
placeholder: 'Select Horde models',
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { setGenerationParamsFromPreset } from '../script.js';
|
import { setGenerationParamsFromPreset } from '../script.js';
|
||||||
import { getDeviceInfo } from './RossAscends-mods.js';
|
import { isMobile } from './RossAscends-mods.js';
|
||||||
import { textgenerationwebui_settings as textgen_settings } from './textgen-settings.js';
|
import { textgenerationwebui_settings as textgen_settings } from './textgen-settings.js';
|
||||||
|
|
||||||
let models = [];
|
let models = [];
|
||||||
|
@ -52,8 +52,7 @@ function getMancerModelTemplate(option) {
|
||||||
jQuery(function () {
|
jQuery(function () {
|
||||||
$('#mancer_model').on('change', onMancerModelSelect);
|
$('#mancer_model').on('change', onMancerModelSelect);
|
||||||
|
|
||||||
const deviceInfo = getDeviceInfo();
|
if (!isMobile()) {
|
||||||
if (deviceInfo && deviceInfo.device.type === 'desktop') {
|
|
||||||
$('#mancer_model').select2({
|
$('#mancer_model').select2({
|
||||||
placeholder: 'Select a model',
|
placeholder: 'Select a model',
|
||||||
searchInputPlaceholder: 'Search models...',
|
searchInputPlaceholder: 'Search models...',
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile,
|
||||||
import { extension_settings, getContext } from './extensions.js';
|
import { extension_settings, getContext } from './extensions.js';
|
||||||
import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from './authors-note.js';
|
import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from './authors-note.js';
|
||||||
import { registerSlashCommand } from './slash-commands.js';
|
import { registerSlashCommand } from './slash-commands.js';
|
||||||
import { getDeviceInfo } from './RossAscends-mods.js';
|
import { isMobile } from './RossAscends-mods.js';
|
||||||
import { FILTER_TYPES, FilterHelper } from './filters.js';
|
import { FILTER_TYPES, FilterHelper } from './filters.js';
|
||||||
import { getTokenCount } from './tokenizers.js';
|
import { getTokenCount } from './tokenizers.js';
|
||||||
import { power_user } from './power-user.js';
|
import { power_user } from './power-user.js';
|
||||||
|
@ -896,8 +896,8 @@ function getWorldEntry(name, data, entry) {
|
||||||
|
|
||||||
const characterFilter = template.find('select[name="characterFilter"]');
|
const characterFilter = template.find('select[name="characterFilter"]');
|
||||||
characterFilter.data('uid', entry.uid);
|
characterFilter.data('uid', entry.uid);
|
||||||
const deviceInfo = getDeviceInfo();
|
|
||||||
if (deviceInfo && deviceInfo.device.type === 'desktop') {
|
if (!isMobile()) {
|
||||||
$(characterFilter).select2({
|
$(characterFilter).select2({
|
||||||
width: '100%',
|
width: '100%',
|
||||||
placeholder: 'All characters will pull from this entry.',
|
placeholder: 'All characters will pull from this entry.',
|
||||||
|
@ -2551,8 +2551,7 @@ jQuery(() => {
|
||||||
$(document).on('click', '.chat_lorebook_button', assignLorebookToChat);
|
$(document).on('click', '.chat_lorebook_button', assignLorebookToChat);
|
||||||
|
|
||||||
// Not needed on mobile
|
// Not needed on mobile
|
||||||
const deviceInfo = getDeviceInfo();
|
if (!isMobile()) {
|
||||||
if (deviceInfo && deviceInfo.device.type === 'desktop') {
|
|
||||||
$('#world_info').select2({
|
$('#world_info').select2({
|
||||||
width: '100%',
|
width: '100%',
|
||||||
placeholder: 'No Worlds active. Click here to select.',
|
placeholder: 'No Worlds active. Click here to select.',
|
||||||
|
|
Loading…
Reference in New Issue