damus.io

damus.io website
git clone git://jb55.com/damus.io
Log | Files | Refs | README | LICENSE

commit 418619bf0fe82a00364e114a83b3346135991b6f
parent 62579db3a3258dab6c55060e6a2a900f5aa5db68
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 11 Nov 2022 18:53:30 -0800

web: stop images from screwing up mobile

Diffstat:
Mweb/damus.js | 40+++++++++++++++++++++++++++++++++++++---
Mweb/index.html | 4++--
Mweb/styles.css | 5+++++
3 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/web/damus.js b/web/damus.js @@ -106,6 +106,7 @@ async function damus_web_init() const ids = { comments: "comments",//uuidv4(), profiles: "profiles",//uuidv4(), + refevents: "refevents",//uuidv4(), account: "account",//uuidv4(), home: "home",//uuidv4(), contacts: "contacts",//uuidv4(), @@ -486,6 +487,29 @@ function load_our_contacts(contacts, our_pubkey, ev) { } } +function get_referenced_events(model) +{ + let evset = new Set() + for (const ev of model.events) { + for (const tag of ev.tags) { + if (tag.count >= 2 && tag[0] === "e") { + const e = tag[1] + if (!model.all_events[e]) { + evset.add(e) + } + } + } + } + return Array.from(evset) +} + + +function fetch_referenced_events(refevents_id, model, relay) { + + const ref = df + model.pool.subscribe(refevents_id, [filter], relay) +} + function handle_profiles_loaded(profiles_id, model, relay) { // stop asking for profiles model.pool.unsubscribe(profiles_id, relay) @@ -527,11 +551,21 @@ function handle_comments_loaded(profiles_id, model, relay) }, new Set()) const authors = Array.from(pubkeys) + const ref_evids = get_referenced_events(model) + // load profiles and noticed chatrooms const chatroom_ids = get_unknown_chatroom_ids(model) const profile_filter = {kinds: [0], authors: authors} const chatroom_filter = {kinds: [40], ids: chatroom_ids} - const filters = [profile_filter, chatroom_filter] + const ref_evs_1 = {ids: ref_evids} + const ref_evs_2 = {"#e": ref_evids} + let filters = [profile_filter, chatroom_filter] + + if (ref_evids.length > 0) { + log_debug("got %d new referenced events to pull after initial load", ref_evids.length) + filters.push(ref_evs_1) + filters.push(ref_evs_2) + } //console.log("subscribe", profiles_id, filter, relay) model.pool.subscribe(profiles_id, filters, relay) @@ -1352,11 +1386,11 @@ function format_content(ev, show_media) let cw = get_content_warning(ev.tags) if (cw !== null) { - let cwHTML = "This content has been marked as sensitive" + let cwHTML = "Content Warning" if (cw === "") { cwHTML += "." } else { - cwHTML += ` due to: "<span>${cw}</span>".` + cwHTML += `: "<span>${cw}</span>".` } const open = !!DSTATE.cw_open[ev.id]? "open" : "" return ` diff --git a/web/index.html b/web/index.html @@ -4,7 +4,7 @@ <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Damus</title> - <link rel="stylesheet" href="styles.css?v=108"> + <link rel="stylesheet" href="styles.css?v=109"> <link rel="stylesheet" href="damus.css?v=211"> <link rel="stylesheet" href="fontawesome.css?v=2"> </head> @@ -63,7 +63,7 @@ <script src="noble-secp256k1.js?v=1"></script> <script src="bech32.js?v=1"></script> <script src="nostr.js?v=6"></script> - <script src="damus.js?v=64"></script> + <script src="damus.js?v=65"></script> <script> // I have to delay loading to wait for nos2x const relay = setTimeout(damus_web_init, 100) diff --git a/web/styles.css b/web/styles.css @@ -173,6 +173,11 @@ button.nav { .comment { word-break: break-word; } + +.inline-img { + width: 100%; +} + .action-bar { } .action-bar > button {