Disable rich presence option in MAS and Snap, and add docs link

If it won't work let's not waste the user's time.
https://github.com/TurboWarp/desktop/issues/1006
https://github.com/TurboWarp/desktop/issues/1005
This commit is contained in:
Muffin 2024-05-31 02:08:31 -05:00
parent 9cbcf2ee0a
commit 5f53a75f85
4 changed files with 37 additions and 7 deletions

View File

@ -265,7 +265,15 @@
},
"desktop-settings.rich-presence": {
"string": "Enable Rich Presence",
"developer_comment": "Option to enable Discord rich presence support, which shows the name of the project someone is editing on their Discord profile. For compliance with Scratch policies don't use the word \"Discord\" in the translation."
"developer_comment": "Option to enable Discord Rich Presence support, which shows the name of the project someone is editing on their Discord profile. For compliance with Scratch policies don't use the word \"Discord\" in the translation."
},
"desktop-settings.rich-presence-unavailable": {
"string": "Rich Presence is not available in this version of the app",
"developer_comment": "Appears in desktop settings after a disabled checkbox (grayed out and unchangeable) if Discord Rich Presence can't be enabled."
},
"desktop-settings.more-information": {
"string": "(more information)",
"developer_comment": "Appears in desktop settings after options as a link to a webpage with more information about the option."
},
"desktop-settings.open-user-data": {
"string": "Open User Data",

View File

@ -28,6 +28,7 @@ const pathUtil = require('path');
const nodeCrypto = require('crypto');
const {APP_NAME} = require('./brand');
const {translate} = require('./l10n');
const {getPlatform} = require('./platform');
const settings = require('./settings');
// Ask GarboMuffin for changes
@ -185,12 +186,21 @@ class RichPresence {
this.handleSocketError = this.handleSocketError.bind(this);
}
isAvailable () {
// In the Mac App Store, our tmpdir is ~/Library/Containers/org.turbowarp.desktop/Data/tmp/
// while the IPC file is /var/folders/.../.../T/discord-ipc-#
// In the Linux Snap Store, our tmpdir is /run/user/.../snap.turbowarp-desktop/
// while the IPC file is /run/user/.../snap.discord/discord-ipc-#
// In both cases the platform sandbox should stop us from accessing the IPC file.
return !(process.mas || getPlatform() === 'linux-snap');
}
checkAutomaticEnable () {
if (this.checkedAutomaticEnable) {
return;
}
this.checkedAutomaticEnable = true;
if (settings.richPresence) {
if (settings.richPresence && this.isAvailable()) {
this.enable();
}
}

View File

@ -34,6 +34,7 @@ class DesktopSettingsWindow extends AbstractWindow {
bypassCORS: settings.bypassCORS,
spellchecker: settings.spellchecker,
exitFullscreenOnEscape: settings.exitFullscreenOnEscape,
richPresenceAvailable: RichPresence.isAvailable(),
richPresence: settings.richPresence
};
});

View File

@ -299,14 +299,25 @@
<label>
<input type="checkbox" class="rich-presence-checkbox" autocomplete="off">
<span class="rich-presence-label"></span>
<a class="rich-presence-more-information" href="https://docs.turbowarp.org/desktop/rich-presence" target="_blank" rel="noreferrer"></a>
</label>
<script>
const richPresence = document.querySelector('.rich-presence-checkbox');
richPresence.onchange = () => {
DesktopSettingsPreload.setRichPresence(richPresence.checked);
};
richPresence.checked = settings.richPresence;
document.querySelector('.rich-presence-label').textContent = strings['desktop-settings.rich-presence'];
const richPresenceLabel = document.querySelector('.rich-presence-label');
const richPresenceMoreInformation = document.querySelector('.rich-presence-more-information');
if (settings.richPresenceAvailable) {
richPresence.onchange = () => {
DesktopSettingsPreload.setRichPresence(richPresence.checked);
};
richPresence.checked = settings.richPresence;
richPresenceLabel.textContent = strings['desktop-settings.rich-presence'];
} else {
richPresence.disabled = true;
richPresence.checked = false;
richPresenceLabel.textContent = strings['desktop-settings.rich-presence-unavailable'];
richPresenceMoreInformation.href += '#supported-platforms';
}
richPresenceMoreInformation.textContent = strings['desktop-settings.more-information'];
</script>
<button class="open-user-data"></button>