diff --git a/packages/pl-api/lib/client.ts b/packages/pl-api/lib/client.ts index 7002788f9..522afdedc 100644 --- a/packages/pl-api/lib/client.ts +++ b/packages/pl-api/lib/client.ts @@ -2775,7 +2775,8 @@ class PlApiClient { onMessages: (messages: Array) => void; onMessage: (message: ShoutMessage) => void; }) => { - let counter = 0; + let counter = 2; + let intervalId: NodeJS.Timeout; if (this.#shoutSocket) return this.#shoutSocket; const path = buildFullPath('/socket/websocket', this.baseURL, { token, vsn: '2.0.0' }); @@ -2794,7 +2795,15 @@ class PlApiClient { }; ws.onopen = () => { - ws.send(JSON.stringify(['3', '3', 'chat:public', 'phx_join', {}])); + ws.send(JSON.stringify(['3', `${++counter}`, 'chat:public', 'phx_join', {}])); + + intervalId = setInterval(() => { + ws.send(JSON.stringify([null, `${++counter}`, 'phoenix', 'heartbeat', {}])); + }, 5000); + }; + + ws.onclose = () => { + clearInterval(intervalId); }; this.#shoutSocket = { @@ -2805,6 +2814,7 @@ class PlApiClient { close: () => { ws.close(); this.#shoutSocket = undefined; + clearInterval(intervalId); }, }; diff --git a/packages/pl-api/lib/features.ts b/packages/pl-api/lib/features.ts index 7830f5784..86d90cb18 100644 --- a/packages/pl-api/lib/features.ts +++ b/packages/pl-api/lib/features.ts @@ -220,6 +220,8 @@ const getFeatures = (instance: Instance) => { v.software === PLEROMA && gte(v.version, '2.5.0'), ]), + accountIsCat: instance.api_versions['cats.pleroma.pl-api'] >= 1, + /** * Ability to set one's location on their profile. * @see PATCH /api/v1/accounts/update_credentials diff --git a/packages/pl-api/lib/params/settings.ts b/packages/pl-api/lib/params/settings.ts index 01e3f2a53..fd4047725 100644 --- a/packages/pl-api/lib/params/settings.ts +++ b/packages/pl-api/lib/params/settings.ts @@ -120,6 +120,11 @@ interface UpdateCredentialsParams { * Requires features{@link Features['accountEnableRss']}. */ enable_rss?: boolean; + + /** Whether the user is a cat */ + is_cat?: boolean; + /** Whether the user speaks as a cat */ + speak_as_cat?: boolean; } /** diff --git a/packages/pl-api/package.json b/packages/pl-api/package.json index 3b2608216..546e5a47e 100644 --- a/packages/pl-api/package.json +++ b/packages/pl-api/package.json @@ -1,6 +1,6 @@ { "name": "pl-api", - "version": "1.0.0-rc.38", + "version": "1.0.0-rc.39", "type": "module", "homepage": "https://github.com/mkljczk/pl-fe/tree/develop/packages/pl-api", "repository": { diff --git a/packages/pl-fe/package.json b/packages/pl-fe/package.json index 54e1bf872..210058955 100644 --- a/packages/pl-fe/package.json +++ b/packages/pl-fe/package.json @@ -104,7 +104,7 @@ "multiselect-react-dropdown": "^2.0.25", "mutative": "^1.1.0", "path-browserify": "^1.0.1", - "pl-api": "^1.0.0-rc.38", + "pl-api": "^1.0.0-rc.39", "postcss": "^8.4.49", "process": "^0.11.10", "punycode": "^2.1.1", diff --git a/packages/pl-fe/src/features/chats/components/shoutbox-message-list.tsx b/packages/pl-fe/src/features/chats/components/shoutbox-message-list.tsx index d3daea98e..22a59aea8 100644 --- a/packages/pl-fe/src/features/chats/components/shoutbox-message-list.tsx +++ b/packages/pl-fe/src/features/chats/components/shoutbox-message-list.tsx @@ -85,7 +85,7 @@ const ShoutboxMessageList: React.FC = () => { > {!isMyMessage && ( - + { // '!bg-transparent !p-0 emoji-lg': isOnlyEmoji, }) } - // ref={setBubbleRef} tabIndex={0} > diff --git a/packages/pl-fe/src/features/edit-profile/index.tsx b/packages/pl-fe/src/features/edit-profile/index.tsx index cc068e5df..038fa00cb 100644 --- a/packages/pl-fe/src/features/edit-profile/index.tsx +++ b/packages/pl-fe/src/features/edit-profile/index.tsx @@ -123,6 +123,10 @@ interface AccountCredentials { enable_rss?: boolean; /** GoToSocial: whether to publicly display followers/follows. */ hide_collections?: boolean; + /** Whether the user is a cat. */ + is_cat?: boolean; + /** Whether the user speaks as a cat. */ + speak_as_cat?: boolean; } /** Convert an account into an update_credentials request object. */ @@ -130,7 +134,7 @@ const accountToCredentials = (account: Account): AccountCredentials => { const hideNetwork = hidesNetwork(account); return { - ...(pick(account, ['discoverable', 'bot', 'display_name', 'locked', 'location', 'avatar_description', 'header_description', 'enable_rss', 'hide_collections'])), + ...(pick(account, ['discoverable', 'bot', 'display_name', 'locked', 'location', 'avatar_description', 'header_description', 'enable_rss', 'hide_collections', 'is_cat', 'speak_as_cat'])), note: account.__meta.source?.note ?? '', fields_attributes: [...account.__meta.source?.fields ?? []], stranger_notifications: account.__meta.pleroma?.notification_settings?.block_from_strangers === true, @@ -427,6 +431,30 @@ const EditProfile: React.FC = () => { /> )} + + {features.accountIsCat && ( + <> + } + hint={} + > + + + + } + hint={} + > + + + + )} {features.profileFields && ( diff --git a/packages/pl-fe/src/locales/en.json b/packages/pl-fe/src/locales/en.json index 8d81ba48c..2d78e31c5 100644 --- a/packages/pl-fe/src/locales/en.json +++ b/packages/pl-fe/src/locales/en.json @@ -651,6 +651,7 @@ "edit_profile.fields.display_name_label": "Display name", "edit_profile.fields.display_name_placeholder": "Name", "edit_profile.fields.hide_network_label": "Hide network", + "edit_profile.fields.is_cat_label": "The user is a cat", "edit_profile.fields.location_label": "Location", "edit_profile.fields.location_placeholder": "Location", "edit_profile.fields.locked_label": "Lock account", @@ -659,13 +660,16 @@ "edit_profile.fields.meta_fields.label_placeholder.first": "Label (e.g. pronouns)", "edit_profile.fields.meta_fields_label": "Profile fields", "edit_profile.fields.rss_label": "Enable RSS feed for public posts", + "edit_profile.fields.speak_as_cat_label": "The user speaks as a cat", "edit_profile.fields.stranger_notifications_label": "Block notifications from strangers", "edit_profile.header": "Edit profile", "edit_profile.hints.bot": "This account mainly performs automated actions and might not be monitored", "edit_profile.hints.discoverable": "Display account in profile directory and allow indexing by external services", "edit_profile.hints.hide_network": "Who you follow and who follows you will not be shown on your profile", + "edit_profile.hints.is_cat": "Mark this account as a cat.", "edit_profile.hints.locked": "Requires you to manually approve followers", "edit_profile.hints.meta_fields": "You can have up to {count, plural, one {# custom field} other {# custom fields}} displayed on your profile.", + "edit_profile.hints.speak_as_cat": "Your posts will get nyanified.", "edit_profile.hints.stranger_notifications": "Only show notifications from people you follow", "edit_profile.save": "Save", "edit_profile.success": "Your profile has been successfully saved!", diff --git a/packages/pl-fe/yarn.lock b/packages/pl-fe/yarn.lock index f642b4ba6..0f895d499 100644 --- a/packages/pl-fe/yarn.lock +++ b/packages/pl-fe/yarn.lock @@ -6833,10 +6833,10 @@ pkg-dir@^4.1.0: dependencies: find-up "^4.0.0" -pl-api@^1.0.0-rc.38: - version "1.0.0-rc.38" - resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-1.0.0-rc.38.tgz#bc2127ff85447f1c3ca6fb3db95a79ab880905e9" - integrity sha512-g7d16KcVDw9OT0s7pN8XQBgdvOREsdA/UlAHZgpqJEiqJdrhuwwQcEvrhWVOEG4yNyryDVk979xsjQQoV37iHQ== +pl-api@^1.0.0-rc.39: + version "1.0.0-rc.39" + resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-1.0.0-rc.39.tgz#47ed57e0ea0602c45b7105d1727b3ff52e09dbba" + integrity sha512-5U1ni9+HQrG9xVcNdlw4VSUJoxcqdgLXUttAH7gxo9jdMMqPLK/c4WLKbyERTM0jn1HubrTPSnDCFZpyvO68hA== dependencies: blurhash "^2.0.5" http-link-header "^1.1.3"