do not close shoutbox connections, add cat ears config

Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
Nicole Mikołajczyk
2025-04-04 10:15:30 +02:00
parent 6b6050d79e
commit 002f0355cb
9 changed files with 59 additions and 11 deletions

View File

@@ -2775,7 +2775,8 @@ class PlApiClient {
onMessages: (messages: Array<ShoutMessage>) => 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);
},
};

View File

@@ -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

View File

@@ -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;
}
/**

View File

@@ -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": {

View File

@@ -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",

View File

@@ -85,7 +85,7 @@ const ShoutboxMessageList: React.FC = () => {
>
{!isMyMessage && (
<HoverAccountWrapper accountId={shoutboxMessage.author.id} element='span'>
<Link to={`/@${shoutboxMessage.author.acct}`} title={shoutboxMessage.author.acct}>
<Link className='mb-0.5' to={`/@${shoutboxMessage.author.acct}`} title={shoutboxMessage.author.acct}>
<Avatar
src={shoutboxMessage.author.avatar}
alt={shoutboxMessage.author.avatar_description}
@@ -116,7 +116,6 @@ const ShoutboxMessageList: React.FC = () => {
// '!bg-transparent !p-0 emoji-lg': isOnlyEmoji,
})
}
// ref={setBubbleRef}
tabIndex={0}
>
<Text size='sm' theme='inherit' className='break-word-nested'>

View File

@@ -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 = () => {
/>
</ListItem>
)}
{features.accountIsCat && (
<>
<ListItem
label={<FormattedMessage id='edit_profile.fields.is_cat_label' defaultMessage='The user is a cat' />}
hint={<FormattedMessage id='edit_profile.hints.is_cat' defaultMessage='Mark this account as a cat.' />}
>
<Toggle
checked={data.is_cat}
onChange={handleCheckboxChange('is_cat')}
/>
</ListItem>
<ListItem
label={<FormattedMessage id='edit_profile.fields.speak_as_cat_label' defaultMessage='The user speaks as a cat' />}
hint={<FormattedMessage id='edit_profile.hints.speak_as_cat' defaultMessage='Your posts will get nyanified.' />}
>
<Toggle
checked={data.speak_as_cat}
onChange={handleCheckboxChange('speak_as_cat')}
/>
</ListItem>
</>
)}
</List>
{features.profileFields && (

View File

@@ -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!",

View File

@@ -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"