commit 944394e
grunfink
·
2025-08-12 08:51:54 +0000 UTC
parent 4d68330
Editing a post keeps the original language.
1 files changed,
+28,
-9
M
html.c
M
html.c
+28,
-9
1@@ -368,7 +368,8 @@ xs_html *html_note(snac *user, const char *summary,
2 const xs_val *mnt_only, const char *redir,
3 const char *in_reply_to, int poll,
4 const xs_list *att_files, const xs_list *att_alt_texts,
5- int is_draft, const char *published)
6+ int is_draft, const char *published,
7+ const char *note_lang)
8 /* Yes, this is a FUCKTON of arguments and I'm a bit embarrased */
9 {
10 xs *action = xs_fmt("%s/admin/note", user->actor);
11@@ -469,10 +470,19 @@ xs_html *html_note(snac *user, const char *summary,
12
13 xs_list_foreach(ll, lang) {
14 if (*lang) {
15- xs_html_add(post_lang,
16- xs_html_tag("option",
17- xs_html_text(lang),
18- xs_html_attr("value", lang)));
19+ if (xs_is_string(note_lang) && strcmp(lang, note_lang) == 0) {
20+ xs_html_add(post_lang,
21+ xs_html_tag("option",
22+ xs_html_text(lang),
23+ xs_html_attr("selected", NULL),
24+ xs_html_attr("value", lang)));
25+ }
26+ else {
27+ xs_html_add(post_lang,
28+ xs_html_tag("option",
29+ xs_html_text(lang),
30+ xs_html_attr("value", lang)));
31+ }
32 }
33 }
34
35@@ -1227,7 +1237,7 @@ xs_html *html_top_controls(snac *user)
36 NULL, NULL,
37 xs_stock(XSTYPE_FALSE), "",
38 xs_stock(XSTYPE_FALSE), NULL,
39- NULL, 1, NULL, NULL, 0, NULL),
40+ NULL, 1, NULL, NULL, 0, NULL, NULL),
41
42 /** operations **/
43 xs_html_tag("details",
44@@ -1913,6 +1923,15 @@ xs_html *html_entry_controls(snac *user, const char *actor,
45 }
46 }
47
48+ const char *note_lang = NULL;
49+ const xs_dict *cmap = xs_dict_get(msg, "contentMap");
50+ if (xs_is_dict(cmap)) {
51+ const char *dummy;
52+ int c = 0;
53+
54+ xs_dict_next(cmap, ¬e_lang, &dummy, &c);
55+ }
56+
57 xs_html_add(controls, xs_html_tag("div",
58 xs_html_tag("p", NULL),
59 html_note(user, L("Edit..."),
60@@ -1922,7 +1941,7 @@ xs_html *html_entry_controls(snac *user, const char *actor,
61 xs_dict_get(msg, "sensitive"), xs_dict_get(msg, "summary"),
62 xs_stock(is_msg_public(msg) ? XSTYPE_FALSE : XSTYPE_TRUE), redir,
63 NULL, 0, att_files, att_alt_texts, is_draft(user, id),
64- xs_dict_get(msg, "published"))),
65+ xs_dict_get(msg, "published"), note_lang)),
66 xs_html_tag("p", NULL));
67 }
68
69@@ -1941,7 +1960,7 @@ xs_html *html_entry_controls(snac *user, const char *actor,
70 NULL, NULL,
71 xs_dict_get(msg, "sensitive"), xs_dict_get(msg, "summary"),
72 xs_stock(is_msg_public(msg) ? XSTYPE_FALSE : XSTYPE_TRUE), redir,
73- id, 0, NULL, NULL, 0, NULL)),
74+ id, 0, NULL, NULL, 0, NULL, NULL)),
75 xs_html_tag("p", NULL));
76 }
77
78@@ -3329,7 +3348,7 @@ xs_html *html_people_list(snac *user, xs_list *list, const char *header, const c
79 NULL, actor_id,
80 xs_stock(XSTYPE_FALSE), "",
81 xs_stock(XSTYPE_FALSE), NULL,
82- NULL, 0, NULL, NULL, 0, NULL),
83+ NULL, 0, NULL, NULL, 0, NULL, NULL),
84 xs_html_tag("p", NULL));
85
86 xs_html_add(snac_post, snac_controls);