generated from t/malachite
add: message replies
This commit is contained in:
parent
dfa1abe2d9
commit
ca1eca967c
13 changed files with 113 additions and 22 deletions
|
@ -5,6 +5,7 @@ const STATE = {
|
|||
is_loading: false,
|
||||
stream_element: null,
|
||||
last_message_time: 0,
|
||||
replying_to: undefined,
|
||||
last_read_receipt_load: 0,
|
||||
};
|
||||
|
||||
|
@ -144,6 +145,7 @@ function create_message(e) {
|
|||
"body",
|
||||
JSON.stringify({
|
||||
content: e.target.content.value,
|
||||
replying_to: STATE.replying_to,
|
||||
}),
|
||||
);
|
||||
|
||||
|
@ -154,6 +156,7 @@ function create_message(e) {
|
|||
if (res.ok) {
|
||||
e.target.reset();
|
||||
document.getElementById("images_zone").classList.add("hidden");
|
||||
clear_replying_to();
|
||||
} else {
|
||||
show_message(res.message, res.ok);
|
||||
}
|
||||
|
@ -395,3 +398,25 @@ function remove_file_from_picker(input_id, idx) {
|
|||
// render
|
||||
display_pending_images({ target: input });
|
||||
}
|
||||
|
||||
function reply_to_message(id) {
|
||||
STATE.replying_to = id;
|
||||
document.getElementById("replying_to_zone").classList.remove("hidden");
|
||||
document.getElementById(`message_${id}`).classList.add("card");
|
||||
document.getElementById(`message_${id}`).classList.add("surface");
|
||||
scroll_bottom();
|
||||
}
|
||||
|
||||
function clear_replying_to() {
|
||||
if (STATE.replying_to) {
|
||||
document
|
||||
.getElementById(`message_${STATE.replying_to}`)
|
||||
.classList.remove("card");
|
||||
document
|
||||
.getElementById(`message_${STATE.replying_to}`)
|
||||
.classList.remove("surface");
|
||||
}
|
||||
|
||||
STATE.replying_to = undefined;
|
||||
document.getElementById("replying_to_zone").classList.add("hidden");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue