From 1e1d6e40bc15c1f0a7c1ff508bdfd9cb991db265 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 20 Aug 2024 18:54:00 +0200 Subject: [PATCH] Add support for local instance posts A new platform feature is defined, `@akkoma/local-only`, which is marked as present only if the string `akkoma` is found in the instance version string. If this feature is supported, a new post visibility option is added to the post compose visibility selector, "Local instance", which sets the visibility to `"local"`. The post viewer is also updated accordingly; while local-only posts could already be seen previously, they didn't have anything written in the `.extra-meta` section, and didn't display a visibility icon. The `building` icon has been selected as the symbol for "Local instance" posts, as it's already used in the main menu to denote the Local timeline. --- src/components/compose.jsx | 5 +++++ src/components/status.jsx | 1 + src/utils/supports.js | 3 +++ src/utils/visibility-icons-map.js | 1 + 4 files changed, 10 insertions(+) diff --git a/src/components/compose.jsx b/src/components/compose.jsx index 17d4c43b..64470675 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -1178,6 +1178,11 @@ function Compose({ + {supports('@akkoma/local-only') && + + } {' '} diff --git a/src/components/status.jsx b/src/components/status.jsx index b7babb60..85c72c14 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -94,6 +94,7 @@ const visibilityText = { unlisted: msg`Unlisted`, private: msg`Followers only`, direct: msg`Private mention`, + local: msg`Local instance`, }; const isIOS = diff --git a/src/utils/supports.js b/src/utils/supports.js index adfd1e35..1560e718 100644 --- a/src/utils/supports.js +++ b/src/utils/supports.js @@ -7,6 +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 platformFeatures = { '@mastodon/lists': notContainPixelfed, '@mastodon/filters': notContainPixelfed, @@ -20,6 +22,7 @@ const platformFeatures = { '@pixelfed/trending': containPixelfed, '@pixelfed/home-include-reblogs': containPixelfed, '@pixelfed/global-feed': containPixelfed, + '@akkoma/local-only': containAkkoma, }; const supportsCache = {}; diff --git a/src/utils/visibility-icons-map.js b/src/utils/visibility-icons-map.js index 867c2dba..835f7406 100644 --- a/src/utils/visibility-icons-map.js +++ b/src/utils/visibility-icons-map.js @@ -3,4 +3,5 @@ export default { unlisted: 'group', private: 'lock', direct: 'message', + local: 'building', };