Fix for DMs being broken
This commit is contained in:
parent
6c9f5f12fe
commit
8bbc6c75d5
5 changed files with 89 additions and 60 deletions
|
@ -76,6 +76,11 @@ th, td {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Navigation */
|
/* Navigation */
|
||||||
|
#view footer {
|
||||||
|
position: sticky;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: var(--zHeader);
|
||||||
|
}
|
||||||
.nav.full {
|
.nav.full {
|
||||||
border-right: 1px solid var(--clrBorder);
|
border-right: 1px solid var(--clrBorder);
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
@ -94,15 +99,13 @@ th, td {
|
||||||
.nav.mobile {
|
.nav.mobile {
|
||||||
display: none;
|
display: none;
|
||||||
background: var(--clrBg);
|
background: var(--clrBg);
|
||||||
position: sticky;
|
|
||||||
bottom: 0;
|
|
||||||
z-index: var(--zHeader);
|
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
border-top: var(--clrBorder) 1px solid;
|
border-top: var(--clrBorder) 1px solid;
|
||||||
}
|
}
|
||||||
.nav.mobile button {
|
.nav.mobile button {
|
||||||
padding: 18px;
|
padding: 18px;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
.nav [data-view].active img.inactive,
|
.nav [data-view].active img.inactive,
|
||||||
.nav [data-view] img.active {
|
.nav [data-view] img.active {
|
||||||
|
@ -415,6 +418,13 @@ textarea.post-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 25px;
|
min-height: 25px;
|
||||||
}
|
}
|
||||||
|
textarea.post-input.dm {
|
||||||
|
background: var(--clrBtn);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 10px;
|
||||||
|
min-height: 45px;
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.post-tools {
|
.post-tools {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
@ -509,11 +519,10 @@ code {
|
||||||
|
|
||||||
/* Messaging */
|
/* Messaging */
|
||||||
|
|
||||||
#dms-not-available {
|
#dm-post {
|
||||||
background: #ffd559;
|
padding: 15px;
|
||||||
display: inline-block;
|
background: var(--clrBg);
|
||||||
color: #090909;
|
border-top: 1px solid var(--clrBorder);
|
||||||
padding: 15px;
|
|
||||||
}
|
}
|
||||||
.dm-group {
|
.dm-group {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -546,7 +555,7 @@ code {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
.event.dm {
|
.event.dm {
|
||||||
padding-bottom: 0;
|
padding-top: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
.event.dm:hover {
|
.event.dm:hover {
|
||||||
|
|
63
index.html
63
index.html
|
@ -179,33 +179,42 @@
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
<nav class="nav mobile">
|
<footer>
|
||||||
<button action="open-view" data-view="friends" class="icon"
|
<div id="dm-post" class="hide">
|
||||||
title="Home">
|
<textarea class="post-input dm" name="message"></textarea>
|
||||||
<img class="icon svg inactive" src="/icon/home.svg"/>
|
<div class="post-tools">
|
||||||
<img class="icon svg active" src="/icon/home-active.svg"/>
|
<button name="send-dm" class="action">Send</button>
|
||||||
</button>
|
</div>
|
||||||
<button action="open-view" data-view="dm" class="icon"
|
</div>
|
||||||
title="Direct Messages">
|
<nav class="nav mobile">
|
||||||
<img class="icon svg inactive" src="/icon/messages.svg"/>
|
<button action="open-view" data-view="friends" class="icon"
|
||||||
<img class="icon svg active" src="/icon/messages-active.svg"/>
|
title="Home">
|
||||||
<div class="new-notifications hide" role="dm"></div>
|
<img class="icon svg inactive" src="/icon/home.svg"/>
|
||||||
</button>
|
<img class="icon svg active" src="/icon/home-active.svg"/>
|
||||||
<button action="open-view" data-view="notifications"
|
</button>
|
||||||
class="icon" title="Notifications">
|
<button action="open-view" data-view="dm" class="icon"
|
||||||
<img class="icon svg inactive" src="/icon/notifications.svg"/>
|
title="Direct Messages">
|
||||||
<img class="icon svg active" src="/icon/notifications-active.svg"/>
|
<img class="icon svg inactive" src="/icon/messages.svg"/>
|
||||||
<div class="new-notifications hide" role="activity"></div>
|
<img class="icon svg active" src="/icon/messages-active.svg"/>
|
||||||
</button>
|
<div class="new-notifications hide" role="dm"></div>
|
||||||
<button action="open-view" data-view="settings"
|
</button>
|
||||||
title="Settings" class="icon">
|
<button action="open-view" data-view="notifications"
|
||||||
<img class="icon svg inactive" src="/icon/settings.svg"/>
|
class="icon" title="Notifications">
|
||||||
<img class="icon svg active" src="/icon/settings-active.svg"/>
|
<img class="icon svg inactive" src="/icon/notifications.svg"/>
|
||||||
</button>
|
<img class="icon svg active" src="/icon/notifications-active.svg"/>
|
||||||
<button action="new-note" title="New Note" class="nav icon new-note">
|
<div class="new-notifications hide" role="activity"></div>
|
||||||
<img class="icon svg invert" src="/icon/new-note.svg"/>
|
</button>
|
||||||
</button>
|
<button action="open-view" data-view="settings"
|
||||||
</nav>
|
title="Settings" class="icon">
|
||||||
|
<img class="icon svg inactive" src="/icon/settings.svg"/>
|
||||||
|
<img class="icon svg active" src="/icon/settings-active.svg"/>
|
||||||
|
</button>
|
||||||
|
<button id="new-note-mobile" action="new-note"
|
||||||
|
title="New Note" class="nav icon new-note">
|
||||||
|
<img class="icon svg invert" src="/icon/new-note.svg"/>
|
||||||
|
</button>
|
||||||
|
</nav>
|
||||||
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-fill vertical-hide"></div>
|
<div class="flex-fill vertical-hide"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
15
js/main.js
15
js/main.js
|
@ -184,7 +184,7 @@ function on_pool_open(relay) {
|
||||||
const { pubkey } = model;
|
const { pubkey } = model;
|
||||||
|
|
||||||
// Get all our info & history, well close this after we get it
|
// Get all our info & history, well close this after we get it
|
||||||
fetch_profile(pubkey, model.pool, relay);
|
fetch_profile_info(pubkey, model.pool, relay);
|
||||||
|
|
||||||
// Get our notifications
|
// Get our notifications
|
||||||
relay.subscribe(SID_NOTIFICATIONS, [{
|
relay.subscribe(SID_NOTIFICATIONS, [{
|
||||||
|
@ -225,23 +225,20 @@ async function on_pool_eose(relay, sub_id) {
|
||||||
break
|
break
|
||||||
case SID_FRIENDS:
|
case SID_FRIENDS:
|
||||||
view_timeline_refresh(model);
|
view_timeline_refresh(model);
|
||||||
//pool.unsubscribe(sub_id, relay);
|
|
||||||
break
|
break
|
||||||
case SID_META:
|
case SID_META:
|
||||||
// if sid is ours and we did not init properly (must be login) then
|
|
||||||
// we will fetch our friends history now
|
|
||||||
//if (model.pubkey == identifier &&
|
|
||||||
// !model_get_relay_que(model, relay).contacts_init) {
|
|
||||||
if (model.pubkey == identifier) {
|
if (model.pubkey == identifier) {
|
||||||
fetch_friends_history(Array.from(model.contacts.friends),
|
friends = Array.from(model.contacts.friends);
|
||||||
pool, relay);
|
friends.push(identifier);
|
||||||
|
fetch_friends_history(friends, pool, relay);
|
||||||
log_debug("Got our friends after no init & fetching our friends");
|
log_debug("Got our friends after no init & fetching our friends");
|
||||||
}
|
}
|
||||||
case SID_NOTIFICATIONS:
|
case SID_NOTIFICATIONS:
|
||||||
case SID_PROFILES:
|
case SID_PROFILES:
|
||||||
|
pool.unsubscribe(sub_id, relay);
|
||||||
|
break;
|
||||||
case SID_DMS_OUT:
|
case SID_DMS_OUT:
|
||||||
case SID_DMS_IN:
|
case SID_DMS_IN:
|
||||||
pool.unsubscribe(sub_id, relay);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ function model_process_event(model, relay, ev) {
|
||||||
fn = model_process_event_reaction;
|
fn = model_process_event_reaction;
|
||||||
break;
|
break;
|
||||||
case KIND_DM:
|
case KIND_DM:
|
||||||
|
fetch_profile = true;
|
||||||
fn = model_process_event_dm;
|
fn = model_process_event_dm;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,10 +119,12 @@ function view_timeline_apply_mode(model, mode, opts={}, push_state=true) {
|
||||||
view_update_navs(mode);
|
view_update_navs(mode);
|
||||||
find_node("#view [role='profile-info']").classList.toggle("hide", mode != VM_USER);
|
find_node("#view [role='profile-info']").classList.toggle("hide", mode != VM_USER);
|
||||||
const timeline_el = find_node("#timeline");
|
const timeline_el = find_node("#timeline");
|
||||||
timeline_el.classList.toggle("reverse", mode == VM_THREAD);
|
timeline_el.classList.toggle("reverse", mode == VM_THREAD || mode == VM_DM_THREAD);
|
||||||
timeline_el.classList.toggle("hide", mode == VM_SETTINGS || mode == VM_DM);
|
timeline_el.classList.toggle("hide", mode == VM_SETTINGS || mode == VM_DM);
|
||||||
find_node("#settings").classList.toggle("hide", mode != VM_SETTINGS);
|
find_node("#settings").classList.toggle("hide", mode != VM_SETTINGS);
|
||||||
find_node("#dms").classList.toggle("hide", mode != VM_DM);
|
find_node("#dms").classList.toggle("hide", mode != VM_DM);
|
||||||
|
find_node("#dm-post").classList.toggle("hide", mode != VM_DM_THREAD);
|
||||||
|
find_node("#new-note-mobile").classList.toggle("hide", mode == VM_DM_THREAD);
|
||||||
find_node("#header-tools button[action='mark-all-read']")
|
find_node("#header-tools button[action='mark-all-read']")
|
||||||
.classList.toggle("hide", mode != VM_DM);
|
.classList.toggle("hide", mode != VM_DM);
|
||||||
|
|
||||||
|
@ -595,12 +597,15 @@ function init_my_pfp(model) {
|
||||||
|
|
||||||
function init_postbox(model) {
|
function init_postbox(model) {
|
||||||
find_node("#reply-content").addEventListener("input", oninput_post);
|
find_node("#reply-content").addEventListener("input", oninput_post);
|
||||||
|
find_node("#dm-post textarea").addEventListener("input", oninput_post);
|
||||||
find_node("button[name='reply']")
|
find_node("button[name='reply']")
|
||||||
.addEventListener("click", onclick_reply);
|
.addEventListener("click", onclick_reply);
|
||||||
find_node("button[name='reply-all']")
|
find_node("button[name='reply-all']")
|
||||||
.addEventListener("click", onclick_reply);
|
.addEventListener("click", onclick_reply);
|
||||||
find_node("button[name='send']")
|
find_node("button[name='send']")
|
||||||
.addEventListener("click", onclick_send);
|
.addEventListener("click", onclick_send);
|
||||||
|
find_node("button[name='send-dm']")
|
||||||
|
.addEventListener("click", onclick_send_dm);
|
||||||
}
|
}
|
||||||
async function onclick_reply(ev) {
|
async function onclick_reply(ev) {
|
||||||
do_send_reply(ev.target.dataset.all == "1");
|
do_send_reply(ev.target.dataset.all == "1");
|
||||||
|
@ -622,26 +627,33 @@ async function onclick_send(ev) {
|
||||||
|
|
||||||
// Reset UI
|
// Reset UI
|
||||||
el_input.value = "";
|
el_input.value = "";
|
||||||
trigger_postbox_assess(el_input);
|
trigger_postbox_assess(el_input);
|
||||||
|
close_modal(el);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
const el_cw = document.querySelector("#content-warning-input");
|
const el_cw = document.querySelector("#content-warning-input");
|
||||||
//tags: el_cw.value ? [["content-warning", el_cw.value]] : [],
|
//tags: el_cw.value ? [["content-warning", el_cw.value]] : [],
|
||||||
|
|
||||||
// Handle DM type post
|
|
||||||
if (mode == VM_DM_THREAD) {
|
|
||||||
if (!dms_available()) {
|
|
||||||
window.alert("DMing not available.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
post.kind = KIND_DM;
|
|
||||||
const target = el.dataset.pubkey;
|
|
||||||
post.tags.splice(0, 0, ["p", target]);
|
|
||||||
post.content = await window.nostr.nip04.encrypt(target, post.content);
|
|
||||||
}
|
|
||||||
|
|
||||||
el_cw.value = "";*/
|
el_cw.value = "";*/
|
||||||
}
|
}
|
||||||
|
async function onclick_send_dm(ev) {
|
||||||
|
const pubkey = await get_pubkey();
|
||||||
|
const el = find_node("#dm-post");
|
||||||
|
const el_input = el.querySelector("textarea");
|
||||||
|
const target = view_get_timeline_el().dataset.pubkey;
|
||||||
|
let post = {
|
||||||
|
pubkey,
|
||||||
|
kind: KIND_DM,
|
||||||
|
created_at: new_creation_time(),
|
||||||
|
content: await window.nostr.nip04.encrypt(target, el_input.value),
|
||||||
|
tags: [["p", target]],
|
||||||
|
};
|
||||||
|
post.id = await nostrjs.calculate_id(post);
|
||||||
|
post = await sign_event(post);
|
||||||
|
broadcast_event(post);
|
||||||
|
|
||||||
|
el_input.value = "";
|
||||||
|
trigger_postbox_assess(el_input);
|
||||||
|
}
|
||||||
/* oninput_post checks the content of the textarea and updates the size
|
/* oninput_post checks the content of the textarea and updates the size
|
||||||
* of it's element. Additionally I will toggle the enabled state of the sending
|
* of it's element. Additionally I will toggle the enabled state of the sending
|
||||||
* button.
|
* button.
|
||||||
|
@ -738,6 +750,7 @@ function onclick_any(ev) {
|
||||||
break;
|
break;
|
||||||
case "new-note":
|
case "new-note":
|
||||||
new_note();
|
new_note();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue