New Feature: Direct Messages
This feature involved a lot of refactoring in order to get working correctly. I wanted to continue using the timeline view for chats thus I used alternative styling & structure for DM event kinds. This worked create since the elements map does not care. There is some queing that has to be done to decrypt message content thus I allow viewing messages even if they haven't been decrypted yet. I think this is good for transparency since you understand what is and is not decrypted. I do think that the UX could improve, because even tho it is fast, it's flashes on new messages. I did not implement saving of latest messages. I will do this later, but this feature is big enough to merge as is: an alpha state that works. I further abstracted profile & name updating to work in a more global manner. Additionally I rewrote code that had attribute scripts to use addEventListener instead. This is needed to happen anyways for security and made the codebase easier to manage.
This commit is contained in:
parent
9badc35bf3
commit
077bf49fdb
17 changed files with 798 additions and 292 deletions
21
js/core.js
21
js/core.js
|
@ -15,6 +15,7 @@ const R_HEART = "❤️";
|
|||
|
||||
const STANDARD_KINDS = [
|
||||
KIND_NOTE,
|
||||
KIND_DM,
|
||||
KIND_DELETE,
|
||||
KIND_REACTION,
|
||||
KIND_SHARE,
|
||||
|
@ -126,26 +127,6 @@ async function sign_event(ev) {
|
|||
return ev
|
||||
}
|
||||
|
||||
async function send_post() {
|
||||
const input_el = document.querySelector("#post-input")
|
||||
const cw_el = document.querySelector("#content-warning-input")
|
||||
const cw = cw_el.value
|
||||
const content = input_el.value
|
||||
const created_at = new_creation_time()
|
||||
const kind = 1
|
||||
const tags = cw ? [["content-warning", cw]] : []
|
||||
const pubkey = await get_pubkey()
|
||||
|
||||
let post = { pubkey, tags, content, created_at, kind }
|
||||
post.id = await nostrjs.calculate_id(post)
|
||||
post = await sign_event(post)
|
||||
broadcast_event(post)
|
||||
|
||||
input_el.value = ""
|
||||
cw_el.value = ""
|
||||
post_input_changed(input_el)
|
||||
}
|
||||
|
||||
function new_reply_tags(ev) {
|
||||
const tags = [["e", ev.id, "", "reply"]];
|
||||
if (ev.refs.root) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue