Merge with browser fixes from RossMods
This commit is contained in:
parent
34ff8e239f
commit
f897a4ab1a
|
@ -1,4 +1,4 @@
|
|||
import { humanizedDateTime, favsToHotswap, getMessageTimeStamp, dragElement, isMobile, initRossMods, shouldSendOnEnter, addSafariPatch } from './scripts/RossAscends-mods.js';
|
||||
import { humanizedDateTime, favsToHotswap, getMessageTimeStamp, dragElement, isMobile, initRossMods, shouldSendOnEnter } from './scripts/RossAscends-mods.js';
|
||||
import { userStatsHandler, statMesProcess, initStats } from './scripts/stats.js';
|
||||
import {
|
||||
generateKoboldWithStreaming,
|
||||
|
@ -273,7 +273,6 @@ await new Promise((resolve) => {
|
|||
});
|
||||
|
||||
showLoader();
|
||||
applyBrowserFixes();
|
||||
|
||||
// Configure toast library:
|
||||
toastr.options.escapeHtml = true; // Prevent raw HTML inserts
|
||||
|
@ -940,7 +939,7 @@ async function firstLoadInit() {
|
|||
throw new Error('Initialization failed');
|
||||
}
|
||||
|
||||
addSafariPatch();
|
||||
applyBrowserFixes();
|
||||
await getClientVersion();
|
||||
await readSecretState();
|
||||
await initLocales();
|
||||
|
|
|
@ -121,7 +121,7 @@ export function humanizeGenTime(total_gen_time) {
|
|||
*/
|
||||
var parsedUA = null;
|
||||
|
||||
function getParsedUA() {
|
||||
export function getParsedUA() {
|
||||
if (!parsedUA) {
|
||||
try {
|
||||
parsedUA = Bowser.parse(navigator.userAgent);
|
||||
|
@ -717,18 +717,6 @@ export const autoFitSendTextAreaDebounced = debounce(autoFitSendTextArea, deboun
|
|||
|
||||
// ---------------------------------------------------
|
||||
|
||||
export function addSafariPatch() {
|
||||
const userAgent = getParsedUA();
|
||||
console.debug('User Agent', userAgent);
|
||||
const isMobileSafari = /iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
|
||||
const isDesktopSafari = userAgent?.browser?.name === 'Safari' && userAgent?.platform?.type === 'desktop';
|
||||
const isIOS = userAgent?.os?.name === 'iOS';
|
||||
|
||||
if (isIOS || isMobileSafari || isDesktopSafari) {
|
||||
document.body.classList.add('safari');
|
||||
}
|
||||
}
|
||||
|
||||
export function initRossMods() {
|
||||
// initial status check
|
||||
checkStatusDebounced();
|
||||
|
@ -741,16 +729,6 @@ export function initRossMods() {
|
|||
RA_autoconnect();
|
||||
}
|
||||
|
||||
if (isMobile()) {
|
||||
const fixFunkyPositioning = () => {
|
||||
console.debug('[Mobile] Device viewport change detected.');
|
||||
document.documentElement.style.position = 'fixed';
|
||||
requestAnimationFrame(() => document.documentElement.style.position = '');
|
||||
};
|
||||
window.addEventListener('resize', fixFunkyPositioning);
|
||||
window.addEventListener('orientationchange', fixFunkyPositioning);
|
||||
}
|
||||
|
||||
$('#main_api').change(function () {
|
||||
var PrevAPI = main_api;
|
||||
setTimeout(() => RA_autoconnect(PrevAPI), 100);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { getParsedUA, isMobile } from './RossAscends-mods.js';
|
||||
|
||||
const isFirefox = () => /firefox/i.test(navigator.userAgent);
|
||||
|
||||
function sanitizeInlineQuotationOnCopy() {
|
||||
|
@ -43,10 +45,34 @@ function sanitizeInlineQuotationOnCopy() {
|
|||
});
|
||||
}
|
||||
|
||||
function addSafariPatch() {
|
||||
const userAgent = getParsedUA();
|
||||
console.debug('User Agent', userAgent);
|
||||
const isMobileSafari = /iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
|
||||
const isDesktopSafari = userAgent?.browser?.name === 'Safari' && userAgent?.platform?.type === 'desktop';
|
||||
const isIOS = userAgent?.os?.name === 'iOS';
|
||||
|
||||
if (isIOS || isMobileSafari || isDesktopSafari) {
|
||||
document.body.classList.add('safari');
|
||||
}
|
||||
}
|
||||
|
||||
function applyBrowserFixes() {
|
||||
if (isFirefox()) {
|
||||
sanitizeInlineQuotationOnCopy();
|
||||
}
|
||||
|
||||
if (isMobile()) {
|
||||
const fixFunkyPositioning = () => {
|
||||
console.debug('[Mobile] Device viewport change detected.');
|
||||
document.documentElement.style.position = 'fixed';
|
||||
requestAnimationFrame(() => document.documentElement.style.position = '');
|
||||
};
|
||||
window.addEventListener('resize', fixFunkyPositioning);
|
||||
window.addEventListener('orientationchange', fixFunkyPositioning);
|
||||
}
|
||||
|
||||
addSafariPatch();
|
||||
}
|
||||
|
||||
export { isFirefox, applyBrowserFixes };
|
||||
|
|
Loading…
Reference in New Issue