working notes + notes&replies
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
1 parent
232ba0e3aa
commit
6fc5eb27fc
6 files changed
+161
-62
No files matched your search
@@ -1 +1 @@
|
||||
[{"limit": 100, "kinds":[1], "#p": ["32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245"]}]
|
||||
[{"limit": 500, "kinds":[1], "#p": ["32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245"]}]
|
||||
@@ -1 +1 @@
|
||||
[{"limit": 100, "kinds": [1], "authors":["2ef93f01cd2493e04235a6b87b10d3c4a74e2a7eb7c3caf168268f6af73314b5","9ec7a778167afb1d30c4833de9322da0c08ba71a69e1911d5578d3144bb56437","b2d670de53b27691c0c3400225b65c35a26d06093bcc41f48ffc71e0907f9d4a","8c0da4862130283ff9e67d889df264177a508974e2feb96de139804ea66d6168","4570d7a0b49b5524797120810116a2a5c18281423b173a557056f08f15c5382d","04c915daefee38317fa734444acee390a8269fe5810b2241e5e6dd343dfbecc9","b7c66ce6f7bbe034e96be54c2ffc0adf631a889abc0834ba1431171b67c489aa","3efdaebb1d8923ebd99c9e7ace3b4194ab45512e2be79c1b7d68d9243e0d2681","35d26e4690cbe1a898af61cc3515661eb5fa763b57bd0b42e45099c8b32fd50f","51fc7209201b1414f721c3d2d2b3430699b1e6317716c5182cc1d7945072e358","e6a92d8b6c20426f78bba8510ccdc73df5122814a3bac1d553adebac67a92b27","3878d95db7b854c3a0d3b2d6b7bf9bf28b36162be64326f5521ba71cf3b45a69","ac9ec020170155f0feb347f0d777ee5fc38dd1f36353093046323646cff5169f","d91191e30e00444b942c0e82cad470b32af171764c2275bee0bd99377efd4075","146bda4ec6932830503ee4f8e8b626bd7b3a5784232b8240ba15c8cbff9a07cd","ea75802dd1c86933c1e20c582541bb283d44c88e3445ed90d4375fc3d973f3a0","80482e60178c2ce996da6d67577f56a2b2c47ccb1c84c81f2b7960637cb71b78","b10c0000079a83cf26815dc7538818d8d56a2983e374e30a4143e50060978457","547fcc5c7e655fe7c83da5a812e6332f0a4779c87bf540d8e75a4edbbf36fe4a","dd81a8bacbab0b5c3007d1672fb8301383b4e9583d431835985057223eb298a5","bb1cf5250435ff475cd8b32acb23e3ee7bbe8fc38f6951704b4798513947672c","1fa91680ebfc68069ec13423fc8b9b0a746e9265584e16cf7d80be7ad721de6e","52b4a076bcbbbdc3a1aefa3735816cf74993b1b8db202b01c883c58be7fad8bd","46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d","08b80da85ba68ac031885ea555ab42bb42231fde9b690bbd0f48c128dfbf8009","104749bc9151a0e54b9845ee50fc4b559439dd1ada006e36a6c49ad3ea16a55c","c47daa0cd21a70797fe9404f8fe0c3f679c2b46148788d1295e6424232064f1d","e1ff3bfdd4e40315959b08b4fcc8245eaa514637e1d4ec2ae166b743341be1af","bae77874946ec111f94be59aef282de092dc4baf213f8ecb8c9e15cb7ed7304e","c7eda660a6bc8270530e82b4a7712acdea2e31dc0a56f8dc955ac009efd97c86","2590201e2919a8aa6568c88900192aa54ef00e6c0974a5b0432f52614a841ec8","38b07a31f3b23dbeb9f59deb7bec5b993173fb4022206980f3809d0b68abf959","23a2cf63ec81e65561acafc655898d2fd0ef190084653fa452413f75e5a3d5bc","0d6c8388dcb049b8dd4fc8d3d8c3bb93de3da90ba828e4f09c8ad0f346488a33","11b9a89404dbf3034e7e1886ba9dc4c6d376f239a118271bd2ec567a889850ce","4d5ce768123563bc583697db5e84841fb528f7b708d966f2e546286ce3c72077","57225e0adcbad1fddf8d9ba1f5f36d657f134b7e0ea7aed6c0eb7013e4ef45f1","234d39919c1bd120766c4d874e8f34df4c80981236d76cdd95e246b1d01ae10b","a4cb51f4618cfcd16b2d3171c466179bed8e197c43b8598823b04de266cef110","472f440f29ef996e92a186b8d320ff180c855903882e59d50de1b8bd5669301e","11674b2d321fc24239b02afdf966c32e36594a6282bd7f3d4bcd12438558ab51","76c71aae3a491f1d9eec47cba17e229cda4113a0bbb6e6ae1776d7643e29cafa","4c96d763eb2fe01910f7e7220b7c7ecdbe1a70057f344b9f79c28af080c3ee30","645681b9d067b1a362c4bee8ddff987d2466d49905c26cb8fec5e6fb73af5c84","00000000827ffaa94bfea288c3dfce4422c794fbb96625b6b31e9049f729d700","88a2c3b420b4a027706a98600d1fd744ac6cfd12e201b74189be5ef4b2b3aa45","65594f279a789982b55c02a38c92a99b986f891d2814c5f553d1bbfe3e23853d","8c5ec8b33956dac9aa616d81cb755c0efe3fc02f6fd58d593313ae1069acb490","77b504e58f206c2aa1b2ae6acc1eb11321f4061eafc8e5b531015dbca536b4e4","c4f5e7a75a8ce3683d529cff06368439c529e5243c6b125ba68789198856cac7","566c166f3adab0c8fba5da015b0b3bcc8eb3696b455f2a1d43bfbd97059646a8","e25a8b2051022a08f97d267d4b99ddfc500a0bfe149a5f671e46f72e9ea36ec9","44189afbf0d25716de6af793dc61c113ecf56166481912ce14c2052db62f396c","af30bf9b7c8843a1f323699a8320a879dfee4b17512696fec39969db284af14a","e6a9a4f853e4b1d426eb44d0c5db09fdc415ce513e664118f46f5ffbea304cbc","cedab81be42ef47dbde653f4ba7ab25ac3aa32cfc2b672ee0f89c0faf882f13e","50d94fc2d8580c682b071a542f8b1e31a200b0508bab95a33bef0855df281d63","e22f6c280855623bbf4f720eed52213c9c298968344dcfd22d15173d46ce767b","a67e98faf32f2520ae574d84262534e7b94625ce0d4e14a50c97e362c06b770e","93a90fae706f1463658c6bb5030c633c707c7e2e8fa17919499d97240925e367","bc52210b20d3fb89326463a3518674c7edde65794a7765c7f3a9119b20bfc6de","c5cfda98d01f152b3493d995eed4cdb4d9e55a973925f6f9ea24769a5a21e778","3946adbb2fc7c95f75356d8f3952c8e2705ee2431f8bd33f5cae0f9ede0298e2","0000007039d4f19ab07896d8790fb43b50c9ffbc455079518f90f8626de780d1","79edc0ac14a1866060eb5a64073af6bf87ce0fcd8b47b510813f3e559f4e2a1f","000000000652e452ee68a01187fb08c899496cb46cb51d1aa0803d063acedba7","c1e9ab3a56a2ab6ca4bebf44ea64b2fda40ac6311e886ba86b4652169cb56b43","a8e76c3ace7829f9ee44cf9293309e21a1824bf1e57631d00685a1ed0b0bd8a2","fd0bcf8cd1aee83fe75e6c0fdfc543845e5bc3f50d26d2d5e5c6d3fa521f98c0","68d81165918100b7da43fc28f7d1fc12554466e1115886b9e7bb326f65ec4272","28463e26e8d36de7599b1d1d9c4c1cc9d69b33d8628e443455eed8b02929be4f","cf7ad05f8e99de8eadbbfbd5ca1c0f9b75499bce07074966b277688ca5e1d726","b2dd40097e4d04b1a56fb3b65fc1d1aaf2929ad30fd842c74d68b9908744495b","884704bd421721e292edbff42eb77547fe115c6ff9825b08fc366be4cd69e9f6",Line truncated
|
||||
[{"limit": 1000, "kinds": [1], "authors":["2ef93f01cd2493e04235a6b87b10d3c4a74e2a7eb7c3caf168268f6af73314b5","9ec7a778167afb1d30c4833de9322da0c08ba71a69e1911d5578d3144bb56437","b2d670de53b27691c0c3400225b65c35a26d06093bcc41f48ffc71e0907f9d4a","8c0da4862130283ff9e67d889df264177a508974e2feb96de139804ea66d6168","4570d7a0b49b5524797120810116a2a5c18281423b173a557056f08f15c5382d","04c915daefee38317fa734444acee390a8269fe5810b2241e5e6dd343dfbecc9","b7c66ce6f7bbe034e96be54c2ffc0adf631a889abc0834ba1431171b67c489aa","3efdaebb1d8923ebd99c9e7ace3b4194ab45512e2be79c1b7d68d9243e0d2681","35d26e4690cbe1a898af61cc3515661eb5fa763b57bd0b42e45099c8b32fd50f","51fc7209201b1414f721c3d2d2b3430699b1e6317716c5182cc1d7945072e358","e6a92d8b6c20426f78bba8510ccdc73df5122814a3bac1d553adebac67a92b27","3878d95db7b854c3a0d3b2d6b7bf9bf28b36162be64326f5521ba71cf3b45a69","ac9ec020170155f0feb347f0d777ee5fc38dd1f36353093046323646cff5169f","d91191e30e00444b942c0e82cad470b32af171764c2275bee0bd99377efd4075","146bda4ec6932830503ee4f8e8b626bd7b3a5784232b8240ba15c8cbff9a07cd","ea75802dd1c86933c1e20c582541bb283d44c88e3445ed90d4375fc3d973f3a0","80482e60178c2ce996da6d67577f56a2b2c47ccb1c84c81f2b7960637cb71b78","b10c0000079a83cf26815dc7538818d8d56a2983e374e30a4143e50060978457","547fcc5c7e655fe7c83da5a812e6332f0a4779c87bf540d8e75a4edbbf36fe4a","dd81a8bacbab0b5c3007d1672fb8301383b4e9583d431835985057223eb298a5","bb1cf5250435ff475cd8b32acb23e3ee7bbe8fc38f6951704b4798513947672c","1fa91680ebfc68069ec13423fc8b9b0a746e9265584e16cf7d80be7ad721de6e","52b4a076bcbbbdc3a1aefa3735816cf74993b1b8db202b01c883c58be7fad8bd","46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d","08b80da85ba68ac031885ea555ab42bb42231fde9b690bbd0f48c128dfbf8009","104749bc9151a0e54b9845ee50fc4b559439dd1ada006e36a6c49ad3ea16a55c","c47daa0cd21a70797fe9404f8fe0c3f679c2b46148788d1295e6424232064f1d","e1ff3bfdd4e40315959b08b4fcc8245eaa514637e1d4ec2ae166b743341be1af","bae77874946ec111f94be59aef282de092dc4baf213f8ecb8c9e15cb7ed7304e","c7eda660a6bc8270530e82b4a7712acdea2e31dc0a56f8dc955ac009efd97c86","2590201e2919a8aa6568c88900192aa54ef00e6c0974a5b0432f52614a841ec8","38b07a31f3b23dbeb9f59deb7bec5b993173fb4022206980f3809d0b68abf959","23a2cf63ec81e65561acafc655898d2fd0ef190084653fa452413f75e5a3d5bc","0d6c8388dcb049b8dd4fc8d3d8c3bb93de3da90ba828e4f09c8ad0f346488a33","11b9a89404dbf3034e7e1886ba9dc4c6d376f239a118271bd2ec567a889850ce","4d5ce768123563bc583697db5e84841fb528f7b708d966f2e546286ce3c72077","57225e0adcbad1fddf8d9ba1f5f36d657f134b7e0ea7aed6c0eb7013e4ef45f1","234d39919c1bd120766c4d874e8f34df4c80981236d76cdd95e246b1d01ae10b","a4cb51f4618cfcd16b2d3171c466179bed8e197c43b8598823b04de266cef110","472f440f29ef996e92a186b8d320ff180c855903882e59d50de1b8bd5669301e","11674b2d321fc24239b02afdf966c32e36594a6282bd7f3d4bcd12438558ab51","76c71aae3a491f1d9eec47cba17e229cda4113a0bbb6e6ae1776d7643e29cafa","4c96d763eb2fe01910f7e7220b7c7ecdbe1a70057f344b9f79c28af080c3ee30","645681b9d067b1a362c4bee8ddff987d2466d49905c26cb8fec5e6fb73af5c84","00000000827ffaa94bfea288c3dfce4422c794fbb96625b6b31e9049f729d700","88a2c3b420b4a027706a98600d1fd744ac6cfd12e201b74189be5ef4b2b3aa45","65594f279a789982b55c02a38c92a99b986f891d2814c5f553d1bbfe3e23853d","8c5ec8b33956dac9aa616d81cb755c0efe3fc02f6fd58d593313ae1069acb490","77b504e58f206c2aa1b2ae6acc1eb11321f4061eafc8e5b531015dbca536b4e4","c4f5e7a75a8ce3683d529cff06368439c529e5243c6b125ba68789198856cac7","566c166f3adab0c8fba5da015b0b3bcc8eb3696b455f2a1d43bfbd97059646a8","e25a8b2051022a08f97d267d4b99ddfc500a0bfe149a5f671e46f72e9ea36ec9","44189afbf0d25716de6af793dc61c113ecf56166481912ce14c2052db62f396c","af30bf9b7c8843a1f323699a8320a879dfee4b17512696fec39969db284af14a","e6a9a4f853e4b1d426eb44d0c5db09fdc415ce513e664118f46f5ffbea304cbc","cedab81be42ef47dbde653f4ba7ab25ac3aa32cfc2b672ee0f89c0faf882f13e","50d94fc2d8580c682b071a542f8b1e31a200b0508bab95a33bef0855df281d63","e22f6c280855623bbf4f720eed52213c9c298968344dcfd22d15173d46ce767b","a67e98faf32f2520ae574d84262534e7b94625ce0d4e14a50c97e362c06b770e","93a90fae706f1463658c6bb5030c633c707c7e2e8fa17919499d97240925e367","bc52210b20d3fb89326463a3518674c7edde65794a7765c7f3a9119b20bfc6de","c5cfda98d01f152b3493d995eed4cdb4d9e55a973925f6f9ea24769a5a21e778","3946adbb2fc7c95f75356d8f3952c8e2705ee2431f8bd33f5cae0f9ede0298e2","0000007039d4f19ab07896d8790fb43b50c9ffbc455079518f90f8626de780d1","79edc0ac14a1866060eb5a64073af6bf87ce0fcd8b47b510813f3e559f4e2a1f","000000000652e452ee68a01187fb08c899496cb46cb51d1aa0803d063acedba7","c1e9ab3a56a2ab6ca4bebf44ea64b2fda40ac6311e886ba86b4652169cb56b43","a8e76c3ace7829f9ee44cf9293309e21a1824bf1e57631d00685a1ed0b0bd8a2","fd0bcf8cd1aee83fe75e6c0fdfc543845e5bc3f50d26d2d5e5c6d3fa521f98c0","68d81165918100b7da43fc28f7d1fc12554466e1115886b9e7bb326f65ec4272","28463e26e8d36de7599b1d1d9c4c1cc9d69b33d8628e443455eed8b02929be4f","cf7ad05f8e99de8eadbbfbd5ca1c0f9b75499bce07074966b277688ca5e1d726","b2dd40097e4d04b1a56fb3b65fc1d1aaf2929ad30fd842c74d68b9908744495b","884704bd421721e292edbff42eb77547fe115c6ff9825b08fc366be4cd69e9f6"Line truncated
|
||||
+104
-43
@@ -5,7 +5,7 @@ use crate::frame_history::FrameHistory;
|
||||
use crate::imgcache::ImageCache;
|
||||
use crate::notecache::{CachedNote, NoteCache};
|
||||
use crate::timeline;
|
||||
use crate::timeline::{NoteRef, Timeline};
|
||||
use crate::timeline::{NoteRef, Timeline, ViewFilter};
|
||||
use crate::ui::is_mobile;
|
||||
use crate::Result;
|
||||
|
||||
@@ -96,7 +96,7 @@ fn send_initial_filters(damus: &mut Damus, relay_url: &str) {
|
||||
for timeline in &damus.timelines {
|
||||
let mut filter = timeline.filter.clone();
|
||||
for f in &mut filter {
|
||||
since_optimize_filter(f, timeline.notes());
|
||||
since_optimize_filter(f, timeline.notes(ViewFilter::NotesAndReplies));
|
||||
}
|
||||
relay.subscribe(format!("initial{}", c), filter);
|
||||
c += 1;
|
||||
@@ -165,7 +165,7 @@ fn try_process_event(damus: &mut Damus, ctx: &egui::Context) -> Result<()> {
|
||||
let txn = Transaction::new(&damus.ndb)?;
|
||||
let mut unknown_ids: HashSet<UnknownId> = HashSet::new();
|
||||
for timeline in 0..damus.timelines.len() {
|
||||
if let Err(err) = poll_notes_for_timeline(ctx, damus, &txn, timeline, &mut unknown_ids) {
|
||||
if let Err(err) = poll_notes_for_timeline(damus, &txn, timeline, &mut unknown_ids) {
|
||||
error!("{}", err);
|
||||
}
|
||||
}
|
||||
@@ -268,13 +268,12 @@ fn get_unknown_note_ids<'a>(
|
||||
}
|
||||
|
||||
fn poll_notes_for_timeline<'a>(
|
||||
ctx: &egui::Context,
|
||||
damus: &mut Damus,
|
||||
txn: &'a Transaction,
|
||||
timeline: usize,
|
||||
timeline_ind: usize,
|
||||
ids: &mut HashSet<UnknownId<'a>>,
|
||||
) -> Result<()> {
|
||||
let sub = if let Some(sub) = &damus.timelines[timeline].subscription {
|
||||
let sub = if let Some(sub) = &damus.timelines[timeline_ind].subscription {
|
||||
sub
|
||||
} else {
|
||||
return Err(Error::NoActiveSubscription);
|
||||
@@ -285,32 +284,78 @@ fn poll_notes_for_timeline<'a>(
|
||||
debug!("{} new notes! {:?}", new_note_ids.len(), new_note_ids);
|
||||
}
|
||||
|
||||
let new_refs: Vec<NoteRef> = new_note_ids
|
||||
let new_refs: Vec<(Note, NoteRef)> = new_note_ids
|
||||
.iter()
|
||||
.map(|key| {
|
||||
let note = damus.ndb.get_note_by_key(txn, *key).expect("no note??");
|
||||
|
||||
let _ = get_unknown_note_ids(&damus.ndb, txn, ¬e, *key, ids);
|
||||
|
||||
NoteRef {
|
||||
key: *key,
|
||||
created_at: note.created_at(),
|
||||
}
|
||||
let created_at = note.created_at();
|
||||
(
|
||||
note,
|
||||
NoteRef {
|
||||
key: *key,
|
||||
created_at,
|
||||
},
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
let timeline = &mut damus.timelines[timeline];
|
||||
let prev_items = timeline.notes().len();
|
||||
timeline.current_view_mut().notes = timeline::merge_sorted_vecs(&timeline.notes(), &new_refs);
|
||||
let new_items = timeline.notes().len() - prev_items;
|
||||
// ViewFilter::NotesAndReplies
|
||||
{
|
||||
let timeline = &mut damus.timelines[timeline_ind];
|
||||
|
||||
// TODO: technically items could have been added inbetween
|
||||
if new_items > 0 {
|
||||
timeline
|
||||
.current_view()
|
||||
.list
|
||||
.borrow_mut()
|
||||
.items_inserted_at_start(new_items);
|
||||
let prev_items = timeline.notes(ViewFilter::NotesAndReplies).len();
|
||||
|
||||
let refs: Vec<NoteRef> = new_refs.iter().map(|(_note, nr)| *nr).collect();
|
||||
timeline.view_mut(ViewFilter::NotesAndReplies).notes =
|
||||
timeline::merge_sorted_vecs(timeline.notes(ViewFilter::NotesAndReplies), &refs);
|
||||
|
||||
let new_items = timeline.notes(ViewFilter::NotesAndReplies).len() - prev_items;
|
||||
|
||||
// TODO: technically items could have been added inbetween
|
||||
if new_items > 0 {
|
||||
damus.timelines[timeline_ind]
|
||||
.view(ViewFilter::NotesAndReplies)
|
||||
.list
|
||||
.borrow_mut()
|
||||
.items_inserted_at_start(new_items);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// handle the filtered case (ViewFilter::Notes, no replies)
|
||||
//
|
||||
// TODO(jb55): this is mostly just copied from above, let's just use a loop
|
||||
// I initially tried this but ran into borrow checker issues
|
||||
{
|
||||
let mut filtered_refs = Vec::with_capacity(new_refs.len());
|
||||
for (note, nr) in &new_refs {
|
||||
let cached_note = damus.note_cache_mut().cached_note_or_insert(nr.key, note);
|
||||
|
||||
if ViewFilter::filter_notes(cached_note, note) {
|
||||
filtered_refs.push(*nr);
|
||||
}
|
||||
}
|
||||
|
||||
let timeline = &mut damus.timelines[timeline_ind];
|
||||
|
||||
let prev_items = timeline.notes(ViewFilter::Notes).len();
|
||||
|
||||
timeline.view_mut(ViewFilter::Notes).notes =
|
||||
timeline::merge_sorted_vecs(timeline.notes(ViewFilter::Notes), &filtered_refs);
|
||||
|
||||
let new_items = timeline.notes(ViewFilter::Notes).len() - prev_items;
|
||||
|
||||
// TODO: technically items could have been added inbetween
|
||||
if new_items > 0 {
|
||||
damus.timelines[timeline_ind]
|
||||
.view(ViewFilter::Notes)
|
||||
.list
|
||||
.borrow_mut()
|
||||
.items_inserted_at_start(new_items);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -322,31 +367,48 @@ fn setup_profiling() {
|
||||
}
|
||||
|
||||
fn setup_initial_nostrdb_subs(damus: &mut Damus) -> Result<()> {
|
||||
for timeline in &mut damus.timelines {
|
||||
let filters: Vec<nostrdb::Filter> = timeline
|
||||
let timelines = damus.timelines.len();
|
||||
for i in 0..timelines {
|
||||
let filters: Vec<nostrdb::Filter> = damus.timelines[i]
|
||||
.filter
|
||||
.iter()
|
||||
.map(crate::filter::convert_enostr_filter)
|
||||
.collect();
|
||||
timeline.subscription = Some(damus.ndb.subscribe(filters.clone())?);
|
||||
damus.timelines[i].subscription = Some(damus.ndb.subscribe(filters.clone())?);
|
||||
let txn = Transaction::new(&damus.ndb)?;
|
||||
debug!(
|
||||
"querying sub {} {:?}",
|
||||
timeline.subscription.as_ref().unwrap().id,
|
||||
timeline.filter
|
||||
damus.timelines[i].subscription.as_ref().unwrap().id,
|
||||
damus.timelines[i].filter
|
||||
);
|
||||
let res = damus.ndb.query(
|
||||
let results = damus.ndb.query(
|
||||
&txn,
|
||||
filters,
|
||||
timeline.filter[0].limit.unwrap_or(200) as i32,
|
||||
damus.timelines[i].filter[0].limit.unwrap_or(200) as i32,
|
||||
)?;
|
||||
timeline.notes_view_mut().notes = res
|
||||
.iter()
|
||||
.map(|qr| NoteRef {
|
||||
key: qr.note_key,
|
||||
created_at: qr.note.created_at(),
|
||||
})
|
||||
.collect();
|
||||
|
||||
let filters = {
|
||||
let views = &damus.timelines[i].views;
|
||||
let filters: Vec<fn(&CachedNote, &Note) -> bool> =
|
||||
views.iter().map(|v| v.filter.filter()).collect();
|
||||
filters
|
||||
};
|
||||
|
||||
for result in results {
|
||||
for (j, filter) in filters.iter().enumerate() {
|
||||
if filter(
|
||||
damus
|
||||
.note_cache_mut()
|
||||
.cached_note_or_insert_mut(result.note_key, &result.note),
|
||||
&result.note,
|
||||
) {
|
||||
damus.timelines[i].views[j].notes.push(NoteRef {
|
||||
key: result.note_key,
|
||||
created_at: result.note.created_at(),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -385,7 +447,7 @@ fn get_unknown_ids<'a>(txn: &'a Transaction, damus: &Damus) -> Result<Vec<Unknow
|
||||
let mut ids: HashSet<UnknownId> = HashSet::new();
|
||||
|
||||
for timeline in &damus.timelines {
|
||||
for noteref in timeline.notes() {
|
||||
for noteref in timeline.notes(ViewFilter::NotesAndReplies) {
|
||||
let note = damus.ndb.get_note_by_key(txn, noteref.key)?;
|
||||
let _ = get_unknown_note_ids(&damus.ndb, txn, ¬e, note.key().unwrap(), &mut ids);
|
||||
}
|
||||
@@ -517,11 +579,8 @@ impl Damus {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_note_cache_mut(&mut self, note_key: NoteKey, note: &Note<'_>) -> &mut CachedNote {
|
||||
self.note_cache
|
||||
.cache
|
||||
.entry(note_key)
|
||||
.or_insert_with(|| CachedNote::new(note))
|
||||
pub fn note_cache_mut(&mut self) -> &mut NoteCache {
|
||||
&mut self.note_cache
|
||||
}
|
||||
|
||||
pub fn selected_timeline(&mut self) -> &mut Timeline {
|
||||
@@ -627,7 +686,9 @@ fn render_panel(ctx: &egui::Context, app: &mut Damus, timeline_ind: usize) {
|
||||
|
||||
ui.weak(format!(
|
||||
"{} notes",
|
||||
&app.timelines[timeline_ind].notes().len()
|
||||
&app.timelines[timeline_ind]
|
||||
.notes(ViewFilter::NotesAndReplies)
|
||||
.len()
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,6 +9,20 @@ pub struct NoteCache {
|
||||
pub cache: HashMap<NoteKey, CachedNote>,
|
||||
}
|
||||
|
||||
impl NoteCache {
|
||||
pub fn cached_note_or_insert_mut(&mut self, note_key: NoteKey, note: &Note) -> &mut CachedNote {
|
||||
self.cache
|
||||
.entry(note_key)
|
||||
.or_insert_with(|| CachedNote::new(note))
|
||||
}
|
||||
|
||||
pub fn cached_note_or_insert(&mut self, note_key: NoteKey, note: &Note) -> &CachedNote {
|
||||
self.cache
|
||||
.entry(note_key)
|
||||
.or_insert_with(|| CachedNote::new(note))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CachedNote {
|
||||
reltime: TimeCached<String>,
|
||||
pub reply: NoteReplyBuf,
|
||||
|
||||
+29
-12
@@ -48,17 +48,25 @@ impl ViewFilter {
|
||||
}
|
||||
}
|
||||
|
||||
fn index(&self) -> usize {
|
||||
pub fn index(&self) -> usize {
|
||||
match self {
|
||||
ViewFilter::Notes => 0,
|
||||
ViewFilter::NotesAndReplies => 1,
|
||||
}
|
||||
}
|
||||
|
||||
fn filter(&self, cache: &CachedNote, note: &Note) -> bool {
|
||||
pub fn filter_notes(cache: &CachedNote, note: &Note) -> bool {
|
||||
!cache.reply.borrow(note.tags()).is_reply()
|
||||
}
|
||||
|
||||
fn identity(_cache: &CachedNote, _note: &Note) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub fn filter(&self) -> fn(&CachedNote, &Note) -> bool {
|
||||
match self {
|
||||
ViewFilter::Notes => !cache.reply.borrow(note.tags()).is_reply(),
|
||||
ViewFilter::NotesAndReplies => true,
|
||||
ViewFilter::Notes => ViewFilter::filter_notes,
|
||||
ViewFilter::NotesAndReplies => ViewFilter::identity,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,12 +146,16 @@ impl Timeline {
|
||||
&mut self.views[self.selected_view as usize]
|
||||
}
|
||||
|
||||
pub fn notes(&self) -> &[NoteRef] {
|
||||
&self.views[ViewFilter::NotesAndReplies.index()].notes
|
||||
pub fn notes(&self, view: ViewFilter) -> &[NoteRef] {
|
||||
&self.views[view.index()].notes
|
||||
}
|
||||
|
||||
pub fn notes_view_mut(&mut self) -> &mut TimelineView {
|
||||
&mut self.views[ViewFilter::NotesAndReplies.index()]
|
||||
pub fn view(&self, view: ViewFilter) -> &TimelineView {
|
||||
&self.views[view.index()]
|
||||
}
|
||||
|
||||
pub fn view_mut(&mut self, view: ViewFilter) -> &mut TimelineView {
|
||||
&mut self.views[view.index()]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +175,7 @@ fn shrink_range_to_width(range: egui::Rangef, width: f32) -> egui::Rangef {
|
||||
egui::Rangef::new(min, max)
|
||||
}
|
||||
|
||||
fn tabs_ui(ui: &mut egui::Ui) {
|
||||
fn tabs_ui(timeline: &mut Timeline, ui: &mut egui::Ui) {
|
||||
ui.spacing_mut().item_spacing.y = 0.0;
|
||||
|
||||
let tab_res = egui_tabs::Tabs::new(2)
|
||||
@@ -200,6 +212,8 @@ fn tabs_ui(ui: &mut egui::Ui) {
|
||||
|
||||
// fun animation
|
||||
if let Some(sel) = tab_res.selected() {
|
||||
timeline.selected_view = sel;
|
||||
|
||||
let (underline, underline_y) = tab_res.inner()[sel as usize].inner;
|
||||
let underline_width = underline.span();
|
||||
|
||||
@@ -236,19 +250,22 @@ pub fn timeline_view(ui: &mut egui::Ui, app: &mut Damus, timeline: usize) {
|
||||
let row_height = ui.fonts(|f| f.row_height(&font_id)) + ui.spacing().item_spacing.y;
|
||||
*/
|
||||
|
||||
tabs_ui(ui);
|
||||
tabs_ui(&mut app.timelines[timeline], ui);
|
||||
|
||||
// need this for some reason??
|
||||
ui.add_space(3.0);
|
||||
|
||||
let scroll_id = ui.id().with(app.timelines[timeline].selected_view);
|
||||
egui::ScrollArea::vertical()
|
||||
.id_source(scroll_id)
|
||||
.animated(false)
|
||||
.scroll_bar_visibility(ScrollBarVisibility::AlwaysVisible)
|
||||
.show(ui, |ui| {
|
||||
let view = app.timelines[timeline].current_view();
|
||||
let len = view.notes.len();
|
||||
let list = view.list.clone();
|
||||
list.borrow_mut()
|
||||
view.list
|
||||
.clone()
|
||||
.borrow_mut()
|
||||
.ui_custom_layout(ui, len, |ui, start_index| {
|
||||
ui.spacing_mut().item_spacing.y = 0.0;
|
||||
ui.spacing_mut().item_spacing.x = 4.0;
|
||||
|
||||
+12
-5
@@ -50,7 +50,8 @@ fn reply_desc(
|
||||
puffin::profile_function!();
|
||||
|
||||
let note_reply = app
|
||||
.get_note_cache_mut(note_key, note)
|
||||
.note_cache_mut()
|
||||
.cached_note_or_insert_mut(note_key, note)
|
||||
.reply
|
||||
.borrow(note.tags());
|
||||
|
||||
@@ -157,12 +158,15 @@ impl<'a> Note<'a> {
|
||||
//ui.horizontal(|ui| {
|
||||
ui.spacing_mut().item_spacing.x = 2.0;
|
||||
|
||||
let note_cache = self.app.get_note_cache_mut(note_key, self.note);
|
||||
let cached_note = self
|
||||
.app
|
||||
.note_cache_mut()
|
||||
.cached_note_or_insert_mut(note_key, self.note);
|
||||
|
||||
let (_id, rect) = ui.allocate_space(egui::vec2(50.0, 20.0));
|
||||
ui.allocate_rect(rect, Sense::hover());
|
||||
ui.put(rect, |ui: &mut egui::Ui| {
|
||||
render_reltime(ui, note_cache, false).response
|
||||
render_reltime(ui, cached_note, false).response
|
||||
});
|
||||
let (_id, rect) = ui.allocate_space(egui::vec2(150.0, 20.0));
|
||||
ui.allocate_rect(rect, Sense::hover());
|
||||
@@ -250,8 +254,11 @@ impl<'a> Note<'a> {
|
||||
.abbreviated(20),
|
||||
);
|
||||
|
||||
let note_cache = self.app.get_note_cache_mut(note_key, self.note);
|
||||
render_reltime(ui, note_cache, true);
|
||||
let cached_note = self
|
||||
.app
|
||||
.note_cache_mut()
|
||||
.cached_note_or_insert_mut(note_key, self.note);
|
||||
render_reltime(ui, cached_note, true);
|
||||
});
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
|
||||
Reference in new issue
Block a user