@@ -640,6 +651,7 @@ function Status({
};
const bookmarkStatus = async () => {
+ if (!supports('@mastodon/post-bookmark')) return;
if (!sameInstance || !authenticated) {
alert(unauthInteractionErrorMessage);
return false;
@@ -827,13 +839,15 @@ function Status({
: 'Like'}
-
+ {supports('@mastodon/post-bookmark') && (
+
+ )}
>
)}
@@ -1077,16 +1091,18 @@ function Status({
)}
{isSelf && (
-
-
-
+ {supports('@mastodon/post-bookmark') && (
+
+
+
+ )}
link.type === 'link');
- console.log('links', links);
- if (links?.length) {
- setLinks(links);
+ if (supports('@mastodon/trending-links')) {
+ try {
+ const { value } = await fetchLinks(masto, instance);
+ // 4 types available: link, photo, video, rich
+ // Only want links for now
+ const links = value?.filter?.((link) => link.type === 'link');
+ console.log('links', links);
+ if (links?.length) {
+ setLinks(links);
+ }
+ } catch (e) {
+ console.error(e);
}
- } catch (e) {
- console.error(e);
}
}
const results = await trendIterator.current.next();
diff --git a/src/utils/supports.js b/src/utils/supports.js
index 02b1a496..4733cd97 100644
--- a/src/utils/supports.js
+++ b/src/utils/supports.js
@@ -4,6 +4,20 @@ import features from '../data/features.json';
import { getCurrentInstance } from './store-utils';
+// Non-semver(?) UA string detection
+// Can't put this inside features.json due to regex
+const containPixelfed = /pixelfed/i;
+const notContainPixelfed = /^(?!.*pixelfed).*$/i;
+const platformFeatures = {
+ '@mastodon/lists': notContainPixelfed,
+ '@mastodon/filters': notContainPixelfed,
+ '@mastodon/mentions': notContainPixelfed,
+ '@mastodon/trending-hashtags': notContainPixelfed,
+ '@mastodon/trending-links': notContainPixelfed,
+ '@mastodon/post-bookmark': notContainPixelfed,
+ '@mastodon/post-edit': notContainPixelfed,
+ '@pixelfed/trending': containPixelfed,
+};
const supportsCache = {};
function supports(feature) {
@@ -11,6 +25,11 @@ function supports(feature) {
const { version, domain } = getCurrentInstance();
const key = `${domain}-${feature}`;
if (supportsCache[key]) return supportsCache[key];
+
+ if (platformFeatures[feature]) {
+ return (supportsCache[key] = platformFeatures[feature].test(version));
+ }
+
const range = features[feature];
if (!range) return false;
return (supportsCache[key] = satisfies(version, range, {