Add support for Pleroma instances

This commit is contained in:
Stefano Pigozzi 2024-08-28 13:17:46 +02:00
parent 67cce5b9cc
commit 8f6d1da008
No known key found for this signature in database
GPG key ID: 5ADA3868646C3FC0
2 changed files with 5 additions and 4 deletions

View file

@ -1178,7 +1178,7 @@ function Compose({
<option value="direct"> <option value="direct">
<Trans>Private mention</Trans> <Trans>Private mention</Trans>
</option> </option>
{supports('@akkoma/local-only') && {supports('@pleroma/local-only') &&
<option value="local"> <option value="local">
<Trans>Local instance</Trans> <Trans>Local instance</Trans>
</option> </option>

View file

@ -7,8 +7,8 @@ import { getCurrentInstance } from './store-utils';
// Non-semver(?) UA string detection // Non-semver(?) UA string detection
const containPixelfed = /pixelfed/i; const containPixelfed = /pixelfed/i;
const notContainPixelfed = /^(?!.*pixelfed).*$/i; const notContainPixelfed = /^(?!.*pixelfed).*$/i;
const containAkkoma = /akkoma/i const containAnyOma = /(?:pler|akk)oma/i
const notContainAkkoma = /^(?! *akkoma) *$/i const notContainAnyOma = /^(?! *(?:pler|akk)oma) *$/i
const platformFeatures = { const platformFeatures = {
'@mastodon/lists': notContainPixelfed, '@mastodon/lists': notContainPixelfed,
'@mastodon/filters': notContainPixelfed, '@mastodon/filters': notContainPixelfed,
@ -22,13 +22,14 @@ const platformFeatures = {
'@pixelfed/trending': containPixelfed, '@pixelfed/trending': containPixelfed,
'@pixelfed/home-include-reblogs': containPixelfed, '@pixelfed/home-include-reblogs': containPixelfed,
'@pixelfed/global-feed': containPixelfed, '@pixelfed/global-feed': containPixelfed,
'@akkoma/local-only': containAkkoma, '@pleroma/local-only': containAnyOma,
}; };
const supportsCache = {}; const supportsCache = {};
function supports(feature) { function supports(feature) {
try { try {
const { version, domain } = getCurrentInstance(); const { version, domain } = getCurrentInstance();
console.debug(version)
const key = `${domain}-${feature}`; const key = `${domain}-${feature}`;
if (supportsCache[key]) return supportsCache[key]; if (supportsCache[key]) return supportsCache[key];