pl-fe: keep list id when replying to a post

Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
Nicole Mikołajczyk
2025-05-17 16:23:34 +02:00
parent bddcbd31ae
commit 2210438c77
8 changed files with 17 additions and 13 deletions

View File

@ -89,6 +89,7 @@ const baseStatusSchema = v.object({
quote_url: v.fallback(v.optional(v.string()), undefined),
quotes_count: v.fallback(v.number(), 0),
bookmark_folder: v.fallback(v.nullable(v.string()), null),
list_id: v.fallback(v.nullable(v.number()), null),
event: v.fallback(v.nullable(statusEventSchema), null),
translation: v.fallback(v.union([v.nullable(translationSchema), v.literal(false)]), null),
@ -123,6 +124,7 @@ const preprocess = (status: any) => {
'pinned_at',
'quotes_count',
'bookmark_folder',
'list_id',
'event',
'translation',

View File

@ -1,6 +1,6 @@
{
"name": "pl-api",
"version": "1.0.0-rc.59",
"version": "1.0.0-rc.60",
"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.59",
"pl-api": "^1.0.0-rc.60",
"postcss": "^8.5.3",
"process": "^0.11.10",
"punycode": "^2.1.1",

View File

@ -167,7 +167,7 @@ const changeCompose = (composeId: string, text: string) => ({
interface ComposeReplyAction {
type: typeof COMPOSE_REPLY;
composeId: string;
status: Pick<Status, 'id' | 'account' | 'group_id' | 'mentions' | 'spoiler_text' | 'visibility'>;
status: Pick<Status, 'id' | 'account' | 'group_id' | 'list_id' | 'mentions' | 'spoiler_text' | 'visibility'>;
account: Pick<Account, 'acct'>;
explicitAddressing: boolean;
preserveSpoilers: boolean;
@ -210,7 +210,7 @@ const cancelReplyCompose = () => ({
interface ComposeQuoteAction {
type: typeof COMPOSE_QUOTE;
composeId: string;
status: Pick<Status, 'id' | 'account' | 'visibility' | 'group_id'>;
status: Pick<Status, 'id' | 'account' | 'visibility' | 'group_id' | 'list_id'>;
account: Pick<Account, 'acct'> | undefined;
explicitAddressing: boolean;
}

View File

@ -157,7 +157,7 @@ const PrivacyDropdown: React.FC<IPrivacyDropdown> = ({
const valueOption = useMemo(() => [
options,
options.filter(option => option.items).map(option => option.items).flat(),
].flat().find(item => item!.value === value), [value]);
].flat().find(item => item!.value === value), [value, lists, circles]);
if (unavailable) {
return null;

View File

@ -72,7 +72,7 @@ const messages = defineMessages({
});
interface IEventHeader {
status?: Pick<Status, 'id' | 'account' | 'bookmarked' | 'event' | 'group_id' | 'pinned' | 'reblog_id' | 'reblogged' | 'sensitive' | 'uri' | 'url' | 'visibility'>;
status?: Pick<Status, 'id' | 'account' | 'bookmarked' | 'event' | 'group_id' | 'pinned' | 'reblog_id' | 'reblogged' | 'sensitive' | 'uri' | 'url' | 'visibility' | 'list_id'>;
}
const EventHeader: React.FC<IEventHeader> = ({ status }) => {

View File

@ -260,10 +260,11 @@ const updateSuggestionTags = (compose: Compose, token: string, tags: Tag[]) => {
compose.suggestion_token = token;
};
const privacyPreference = (a: string, b: string) => {
const privacyPreference = (a: string, b: string, list_id: number | null) => {
const order = ['public', 'unlisted', 'mutuals_only', 'private', 'direct', 'local'];
if (a === 'group') return a;
if (a === 'list' && list_id !== null) return `list:${list_id}`;
return order[Math.max(order.indexOf(a), order.indexOf(b), 0)];
};
@ -391,7 +392,7 @@ const compose = (state = initialState, action: ComposeAction | EventsAction | In
compose.to = to;
compose.parent_reblogged_by = action.rebloggedBy?.id || null;
compose.text = !action.explicitAddressing ? statusToTextMentions(action.status, action.account) : '';
compose.privacy = privacyPreference(action.status.visibility, defaultCompose.privacy);
compose.privacy = privacyPreference(action.status.visibility, defaultCompose.privacy, action.status.list_id);
compose.focusDate = new Date();
compose.caretPosition = null;
compose.idempotencyKey = crypto.randomUUID();
@ -417,7 +418,7 @@ const compose = (state = initialState, action: ComposeAction | EventsAction | In
compose.to = [author];
compose.parent_reblogged_by = null;
compose.text = '';
compose.privacy = privacyPreference(action.status.visibility, defaultCompose.privacy);
compose.privacy = privacyPreference(action.status.visibility, defaultCompose.privacy, action.status.list_id);
compose.focusDate = new Date();
compose.caretPosition = null;
compose.idempotencyKey = crypto.randomUUID();

View File

@ -1,6 +1,7 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@adobe/css-tools@^4.4.0":
version "4.4.1"
resolved "https://registry.yarnpkg.com/@adobe/css-tools/-/css-tools-4.4.1.tgz#2447a230bfe072c1659e6815129c03cf170710e3"
@ -6857,10 +6858,10 @@ pkg-dir@^4.1.0:
dependencies:
find-up "^4.0.0"
pl-api@^1.0.0-rc.59:
version "1.0.0-rc.59"
resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-1.0.0-rc.59.tgz#16e95e9109aef9ba8c346cb1b0c29a5acc1a8f76"
integrity sha512-Sts8eGoNA50dG0Y80END6S7LH5xqd21pqU7zFArLNtZ/PjAzQ0hkB6Ikw5OSJAlcj8EVpf9UM6kHyqxLmvCrWQ==
pl-api@^1.0.0-rc.60:
version "1.0.0-rc.60"
resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-1.0.0-rc.60.tgz#4c92ba2cf41045a68d52d0f1ab2f264a26afd6e2"
integrity sha512-JHHrsNhf8E9KpkbqKTK/dAAsDPfYMusAiQrtemF8ZYsbVxra4AiBOChkIkclzP/JotDjUFN/q/DDGNIqoEBqjA==
dependencies:
blurhash "^2.0.5"
http-link-header "^1.1.3"