add: circle stacks

This commit is contained in:
trisua 2025-06-15 16:09:02 -04:00
parent 50704d27a9
commit 56cea83933
27 changed files with 419 additions and 107 deletions

View file

@ -97,6 +97,13 @@
("value" "{{ community.id }}")
("selected" "{% if selected_community == community.id -%}true{% else %}false{%- endif %}")
(text "{% if community.context.display_name -%} {{ community.context.display_name }} {% else %} {{ community.title }} {%- endif %}"))
(text "{% endfor %}")
(text "{% for stack in stacks %}")
(option
("value" "{{ stack.id }}")
("selected" "{% if selected_stack == stack.id -%}true{% else %}false{%- endif %}")
("is_stack" "true")
(text "{{ stack.name }} (circle)"))
(text "{% endfor %}")))
(form
("class" "card flex flex-col gap-2")
@ -184,13 +191,19 @@
}
}
const is_selected_stack = document.getElementById(
\"community_to_post_to\",
).selectedOptions[0].getAttribute(\"is_stack\") === \"true\";
const selected_community = document.getElementById(
\"community_to_post_to\",
).selectedOptions[0].value;
body.append(
\"body\",
JSON.stringify({
content: e.target.content.value,
community: document.getElementById(
\"community_to_post_to\",
).selectedOptions[0].value,
community: !is_selected_stack ? selected_community : \"0\",
stack: is_selected_stack ? selected_community : \"0\",
poll: poll_data[1],
title: e.target.title.value,
}),
@ -316,12 +329,15 @@
(text "{% else %}")
(script
(text "async function create_post_from_form(e) {
e.preventDefault();
const id = await trigger(\"me::repost\", [
\"{{ quoting[1].id }}\",
e.target.content.value,
document.getElementById(\"community_to_post_to\")
.selectedOptions[0].value,
false,
document.getElementById(\"community_to_post_to\")
.selectedOptions[0].getAttribute(\"is_stack\") === \"true\",
]);
// update settings
@ -394,27 +410,34 @@
(text "{%- endif %}"))
(script
(text "const town_square = \"{{ config.town_square }}\";
(text "(() => {const town_square = \"{{ config.town_square }}\";
const user_id = \"{{ user.id }}\";
function update_community_avatar(e) {
window.update_community_avatar = (e) => {
const element = e.target.parentElement.querySelector(\".avatar\");
const is_stack = e.target.selectedOptions[0].getAttribute(\"is_stack\") === \"true\";
const id = e.target.selectedOptions[0].value;
element.setAttribute(\"title\", id);
element.setAttribute(\"alt\", `${id}'s avatar`);
if (id === town_square) {
if (id === town_square || is_stack) {
element.src = `/api/v1/auth/user/${user_id}/avatar?selector_type=id`;
} else {
element.src = `/api/v1/communities/${id}/avatar`;
}
}
function check_community_supports_title(e) {
window.check_community_supports_title = async (e) => {
const element = document.getElementById(\"title_field\");
const is_stack = e.target.selectedOptions[0].getAttribute(\"is_stack\") === \"true\";
const id = e.target.selectedOptions[0].value;
if (is_stack) {
element.classList.add(\"hidden\");
return;
}
fetch(`/api/v1/communities/${id}/supports_titles`)
.then((res) => res.json())
.then((res) => {
@ -436,7 +459,7 @@
});
}, 150);
async function cancel_create_post() {
window.cancel_create_post = async () => {
if (
!(await trigger(\"atto::confirm\", [
\"Are you sure you would like to do this? Your post content will be lost.\",
@ -446,6 +469,6 @@
}
window.history.back();
}"))
}})();"))
(text "{% endblock %}")