diff --git a/src/mami.js/conman.js b/src/mami.js/conman.js index b448fd9..0e520df 100644 --- a/src/mami.js/conman.js +++ b/src/mami.js/conman.js @@ -56,7 +56,7 @@ const MamiConnectionManager = function(client, settings, urls, eventTarget) { resetTimeout(); (async () => { - if(settings.get('onlyConnectWhenVisible')) + if(settings.get('onlyConnectWhenVisible2')) await MamiWaitVisible(); eventTarget.dispatch('attempt', { diff --git a/src/mami.js/main.js b/src/mami.js/main.js index b978a81..ab04659 100644 --- a/src/mami.js/main.js +++ b/src/mami.js/main.js @@ -7,6 +7,7 @@ window.Umi = { UI: {} }; #include context.js #include emotes.js #include events.js +#include mobile.js #include mszauth.js #include txtrigs.js #include utility.js @@ -109,7 +110,7 @@ window.Umi = { UI: {} }; settings.define('windowsLiveMessenger').default(false).create(); settings.define('seinfeld').default(false).create(); settings.define('flashTitle').default(true).create(); - settings.define('onlyConnectWhenVisible').default(true).create(); + settings.define('onlyConnectWhenVisible2').default(MamiIsMobileDevice()).create(); settings.define('playJokeSounds').default(true).create(); settings.define('weeaboo').default(false).create(); settings.define('motivationalImages').default(false).create(); diff --git a/src/mami.js/mobile.js b/src/mami.js/mobile.js new file mode 100644 index 0000000..40311df --- /dev/null +++ b/src/mami.js/mobile.js @@ -0,0 +1,12 @@ +const MamiIsMobileDevice = () => { + if('userAgentData' in navigator) + return navigator.userAgentData.mobile; + + if('matchMedia' in window) + return !window.matchMedia("(any-pointer:fine)").matches; + + if('maxTouchPoints' in navigator) + return navigator.maxTouchPoints > 1; + + return false; +}; diff --git a/src/mami.js/ui/settings.jsx b/src/mami.js/ui/settings.jsx index 4230d31..fc5d643 100644 --- a/src/mami.js/ui/settings.jsx +++ b/src/mami.js/ui/settings.jsx @@ -204,7 +204,7 @@ Umi.UI.Settings = (function() { title: 'Misc', items: [ { - name: 'onlyConnectWhenVisible', + name: 'onlyConnectWhenVisible2', title: 'Only connect when the tab is in the foreground', type: 'checkbox', confirm: ['Please only disable this setting if you are using a desktop or laptop computer, this should always remain on on a phone, tablet or other device of that sort.', 'Are you sure you want to change this setting? Ignoring this warning may carry consequences.'],