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">
<Trans>Private mention</Trans>
</option>
{supports('@akkoma/local-only') &&
{supports('@pleroma/local-only') &&
<option value="local">
<Trans>Local instance</Trans>
</option>

View file

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