Merge is_following fixes from kernel
kernelkind (4):
add `Accounts` to `NoteContext`
remove `MuteFun` prop
make `Contacts::is_following` use bytes instead of `Pubkey`
migrate to check following through `Contacts::is_following`
This commit is contained in:
@@ -12,7 +12,7 @@ use egui::{
|
||||
widgets::text_edit::TextEdit,
|
||||
Frame, Layout, Margin, Pos2, ScrollArea, Sense, TextBuffer,
|
||||
};
|
||||
use enostr::{FilledKeypair, FullKeypair, KeypairUnowned, NoteId, Pubkey, RelayPool};
|
||||
use enostr::{FilledKeypair, FullKeypair, NoteId, Pubkey, RelayPool};
|
||||
use nostrdb::{Ndb, Transaction};
|
||||
use notedeck_ui::{
|
||||
app_images,
|
||||
@@ -352,15 +352,9 @@ impl<'a, 'd> PostView<'a, 'd> {
|
||||
ui.vertical(|ui| {
|
||||
ui.set_max_width(avail_size.x * 0.8);
|
||||
|
||||
let zapping_acc = self
|
||||
.note_context
|
||||
.current_account_has_wallet
|
||||
.then(|| KeypairUnowned::from(&self.poster));
|
||||
|
||||
render_note_preview(
|
||||
ui,
|
||||
self.note_context,
|
||||
zapping_acc.as_ref(),
|
||||
txn,
|
||||
id.bytes(),
|
||||
nostrdb::NoteKey::new(0),
|
||||
@@ -793,6 +787,7 @@ mod preview {
|
||||
let txn = Transaction::new(app.ndb).expect("txn");
|
||||
let mut note_context = NoteContext {
|
||||
ndb: app.ndb,
|
||||
accounts: app.accounts,
|
||||
img_cache: app.img_cache,
|
||||
note_cache: app.note_cache,
|
||||
zaps: app.zaps,
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::ui::{
|
||||
note::{PostAction, PostResponse, PostType},
|
||||
};
|
||||
|
||||
use enostr::{FilledKeypair, KeypairUnowned, NoteId};
|
||||
use enostr::{FilledKeypair, NoteId};
|
||||
use notedeck::NoteContext;
|
||||
use notedeck_ui::jobs::JobsCache;
|
||||
use notedeck_ui::{NoteOptions, NoteView, ProfilePic};
|
||||
@@ -67,27 +67,16 @@ impl<'a, 'd> PostReplyView<'a, 'd> {
|
||||
let note_offset: i8 =
|
||||
pfp_offset - ProfilePic::medium_size() / 2 - NoteView::expand_size() / 2;
|
||||
|
||||
let zapping_acc = self
|
||||
.note_context
|
||||
.current_account_has_wallet
|
||||
.then(|| KeypairUnowned::from(&self.poster));
|
||||
|
||||
let quoted_note = egui::Frame::NONE
|
||||
.outer_margin(egui::Margin::same(note_offset))
|
||||
.show(ui, |ui| {
|
||||
NoteView::new(
|
||||
self.note_context,
|
||||
zapping_acc.as_ref(),
|
||||
self.note,
|
||||
self.note_options,
|
||||
self.jobs,
|
||||
)
|
||||
.truncate(false)
|
||||
.selectable_text(true)
|
||||
.actionbar(false)
|
||||
.medium_pfp(true)
|
||||
.options_button(true)
|
||||
.show(ui)
|
||||
NoteView::new(self.note_context, self.note, self.note_options, self.jobs)
|
||||
.truncate(false)
|
||||
.selectable_text(true)
|
||||
.actionbar(false)
|
||||
.medium_pfp(true)
|
||||
.options_button(true)
|
||||
.show(ui)
|
||||
})
|
||||
.inner;
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ use crate::{
|
||||
ui::timeline::{tabs_ui, TimelineTabView},
|
||||
};
|
||||
use notedeck::{
|
||||
name::get_display_name, profile::get_profile_url, Accounts, IsFollowing, MuteFun, NoteAction,
|
||||
NoteContext, NotedeckTextStyle,
|
||||
name::get_display_name, profile::get_profile_url, IsFollowing, NoteAction, NoteContext,
|
||||
NotedeckTextStyle,
|
||||
};
|
||||
use notedeck_ui::{
|
||||
app_images,
|
||||
@@ -24,11 +24,9 @@ use notedeck_ui::{
|
||||
|
||||
pub struct ProfileView<'a, 'd> {
|
||||
pubkey: &'a Pubkey,
|
||||
accounts: &'a Accounts,
|
||||
col_id: usize,
|
||||
timeline_cache: &'a mut TimelineCache,
|
||||
note_options: NoteOptions,
|
||||
is_muted: &'a MuteFun,
|
||||
note_context: &'a mut NoteContext<'d>,
|
||||
jobs: &'a mut JobsCache,
|
||||
}
|
||||
@@ -44,21 +42,17 @@ impl<'a, 'd> ProfileView<'a, 'd> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
pubkey: &'a Pubkey,
|
||||
accounts: &'a Accounts,
|
||||
col_id: usize,
|
||||
timeline_cache: &'a mut TimelineCache,
|
||||
note_options: NoteOptions,
|
||||
is_muted: &'a MuteFun,
|
||||
note_context: &'a mut NoteContext<'d>,
|
||||
jobs: &'a mut JobsCache,
|
||||
) -> Self {
|
||||
ProfileView {
|
||||
pubkey,
|
||||
accounts,
|
||||
col_id,
|
||||
timeline_cache,
|
||||
note_options,
|
||||
is_muted,
|
||||
note_context,
|
||||
jobs,
|
||||
}
|
||||
@@ -116,9 +110,7 @@ impl<'a, 'd> ProfileView<'a, 'd> {
|
||||
reversed,
|
||||
self.note_options,
|
||||
&txn,
|
||||
self.is_muted,
|
||||
self.note_context,
|
||||
&(&self.accounts.get_selected_account().key).into(),
|
||||
self.jobs,
|
||||
)
|
||||
.show(ui)
|
||||
@@ -179,14 +171,14 @@ impl<'a, 'd> ProfileView<'a, 'd> {
|
||||
ui.add_space(24.0);
|
||||
|
||||
let target_key = self.pubkey;
|
||||
let selected = self.accounts.get_selected_account();
|
||||
let selected = self.note_context.accounts.get_selected_account();
|
||||
|
||||
let profile_type = if selected.key.secret_key.is_none() {
|
||||
ProfileType::ReadOnly
|
||||
} else if &selected.key.pubkey == self.pubkey {
|
||||
ProfileType::MyProfile
|
||||
} else {
|
||||
ProfileType::Followable(selected.is_following(target_key))
|
||||
ProfileType::Followable(selected.is_following(target_key.bytes()))
|
||||
};
|
||||
|
||||
match profile_type {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use egui::{vec2, Align, Color32, CornerRadius, RichText, Stroke, TextEdit};
|
||||
use enostr::{KeypairUnowned, NoteId, Pubkey};
|
||||
use enostr::{NoteId, Pubkey};
|
||||
use state::TypingType;
|
||||
|
||||
use crate::{timeline::TimelineTab, ui::timeline::TimelineTabView};
|
||||
use egui_winit::clipboard::Clipboard;
|
||||
use nostrdb::{Filter, Ndb, Transaction};
|
||||
use notedeck::{MuteFun, NoteAction, NoteContext, NoteRef};
|
||||
use notedeck::{NoteAction, NoteContext, NoteRef};
|
||||
use notedeck_ui::{
|
||||
context_menu::{input_context, PasteBehavior},
|
||||
icons::search_icon,
|
||||
@@ -25,29 +25,23 @@ pub struct SearchView<'a, 'd> {
|
||||
query: &'a mut SearchQueryState,
|
||||
note_options: NoteOptions,
|
||||
txn: &'a Transaction,
|
||||
is_muted: &'a MuteFun,
|
||||
note_context: &'a mut NoteContext<'d>,
|
||||
cur_acc: &'a KeypairUnowned<'a>,
|
||||
jobs: &'a mut JobsCache,
|
||||
}
|
||||
|
||||
impl<'a, 'd> SearchView<'a, 'd> {
|
||||
pub fn new(
|
||||
txn: &'a Transaction,
|
||||
is_muted: &'a MuteFun,
|
||||
note_options: NoteOptions,
|
||||
query: &'a mut SearchQueryState,
|
||||
note_context: &'a mut NoteContext<'d>,
|
||||
cur_acc: &'a KeypairUnowned<'a>,
|
||||
jobs: &'a mut JobsCache,
|
||||
) -> Self {
|
||||
Self {
|
||||
txn,
|
||||
is_muted,
|
||||
query,
|
||||
note_options,
|
||||
note_context,
|
||||
cur_acc,
|
||||
jobs,
|
||||
}
|
||||
}
|
||||
@@ -155,9 +149,7 @@ impl<'a, 'd> SearchView<'a, 'd> {
|
||||
reversed,
|
||||
self.note_options,
|
||||
self.txn,
|
||||
self.is_muted,
|
||||
self.note_context,
|
||||
self.cur_acc,
|
||||
self.jobs,
|
||||
)
|
||||
.show(ui)
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use egui::InnerResponse;
|
||||
use egui_virtual_list::VirtualList;
|
||||
use enostr::KeypairUnowned;
|
||||
use nostrdb::{Note, Transaction};
|
||||
use notedeck::note::root_note_id_from_selected_id;
|
||||
use notedeck::{MuteFun, NoteAction, NoteContext};
|
||||
use notedeck::{NoteAction, NoteContext};
|
||||
use notedeck_ui::jobs::JobsCache;
|
||||
use notedeck_ui::note::NoteResponse;
|
||||
use notedeck_ui::{NoteOptions, NoteView};
|
||||
@@ -16,9 +15,7 @@ pub struct ThreadView<'a, 'd> {
|
||||
note_options: NoteOptions,
|
||||
col: usize,
|
||||
id_source: egui::Id,
|
||||
is_muted: &'a MuteFun,
|
||||
note_context: &'a mut NoteContext<'d>,
|
||||
cur_acc: &'a KeypairUnowned<'a>,
|
||||
jobs: &'a mut JobsCache,
|
||||
}
|
||||
|
||||
@@ -28,9 +25,7 @@ impl<'a, 'd> ThreadView<'a, 'd> {
|
||||
threads: &'a mut Threads,
|
||||
selected_note_id: &'a [u8; 32],
|
||||
note_options: NoteOptions,
|
||||
is_muted: &'a MuteFun,
|
||||
note_context: &'a mut NoteContext<'d>,
|
||||
cur_acc: &'a KeypairUnowned<'a>,
|
||||
jobs: &'a mut JobsCache,
|
||||
) -> Self {
|
||||
let id_source = egui::Id::new("threadscroll_threadview");
|
||||
@@ -39,9 +34,7 @@ impl<'a, 'd> ThreadView<'a, 'd> {
|
||||
selected_note_id,
|
||||
note_options,
|
||||
id_source,
|
||||
is_muted,
|
||||
note_context,
|
||||
cur_acc,
|
||||
jobs,
|
||||
col: 0,
|
||||
}
|
||||
@@ -134,21 +127,14 @@ impl<'a, 'd> ThreadView<'a, 'd> {
|
||||
ui.colored_label(ui.visuals().error_fg_color, "LOADING NOTES");
|
||||
}
|
||||
|
||||
let zapping_acc = self
|
||||
.note_context
|
||||
.current_account_has_wallet
|
||||
.then_some(self.cur_acc);
|
||||
|
||||
show_notes(
|
||||
ui,
|
||||
list,
|
||||
¬es,
|
||||
self.note_context,
|
||||
zapping_acc,
|
||||
self.note_options,
|
||||
self.jobs,
|
||||
txn,
|
||||
self.is_muted,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -159,11 +145,9 @@ fn show_notes(
|
||||
list: &mut VirtualList,
|
||||
thread_notes: &ThreadNotes,
|
||||
note_context: &mut NoteContext<'_>,
|
||||
zapping_acc: Option<&KeypairUnowned<'_>>,
|
||||
flags: NoteOptions,
|
||||
jobs: &mut JobsCache,
|
||||
txn: &Transaction,
|
||||
is_muted: &MuteFun,
|
||||
) -> Option<NoteAction> {
|
||||
let mut action = None;
|
||||
|
||||
@@ -173,6 +157,8 @@ fn show_notes(
|
||||
let selected_note_index = thread_notes.selected_index;
|
||||
let notes = &thread_notes.notes;
|
||||
|
||||
let is_muted = note_context.accounts.mutefun();
|
||||
|
||||
list.ui_custom_layout(ui, notes.len(), |ui, cur_index| {
|
||||
let note = ¬es[cur_index];
|
||||
|
||||
@@ -190,7 +176,7 @@ fn show_notes(
|
||||
return 1;
|
||||
}
|
||||
|
||||
let resp = note.show(note_context, zapping_acc, flags, jobs, ui);
|
||||
let resp = note.show(note_context, flags, jobs, ui);
|
||||
|
||||
action = if cur_index == selected_note_index {
|
||||
resp.action.and_then(strip_note_action)
|
||||
@@ -313,21 +299,14 @@ impl<'a> ThreadNote<'a> {
|
||||
fn show(
|
||||
&self,
|
||||
note_context: &'a mut NoteContext<'_>,
|
||||
zapping_acc: Option<&'a KeypairUnowned<'a>>,
|
||||
flags: NoteOptions,
|
||||
jobs: &'a mut JobsCache,
|
||||
ui: &mut egui::Ui,
|
||||
) -> NoteResponse {
|
||||
let inner = notedeck_ui::padding(8.0, ui, |ui| {
|
||||
NoteView::new(
|
||||
note_context,
|
||||
zapping_acc,
|
||||
&self.note,
|
||||
self.options(flags),
|
||||
jobs,
|
||||
)
|
||||
.unread_indicator(self.unread_and_have_replies)
|
||||
.show(ui)
|
||||
NoteView::new(note_context, &self.note, self.options(flags), jobs)
|
||||
.unread_indicator(self.unread_and_have_replies)
|
||||
.show(ui)
|
||||
});
|
||||
|
||||
match self.note_type {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use egui::containers::scroll_area::ScrollBarVisibility;
|
||||
use egui::{vec2, Direction, Layout, Pos2, Stroke};
|
||||
use egui_tabs::TabColor;
|
||||
use enostr::KeypairUnowned;
|
||||
use nostrdb::Transaction;
|
||||
use notedeck::ui::is_narrow;
|
||||
use notedeck_ui::jobs::JobsCache;
|
||||
@@ -9,7 +8,7 @@ use std::f32::consts::PI;
|
||||
use tracing::{error, warn};
|
||||
|
||||
use crate::timeline::{TimelineCache, TimelineKind, TimelineTab, ViewFilter};
|
||||
use notedeck::{note::root_note_id_from_selected_id, MuteFun, NoteAction, NoteContext, ScrollInfo};
|
||||
use notedeck::{note::root_note_id_from_selected_id, NoteAction, NoteContext, ScrollInfo};
|
||||
use notedeck_ui::{
|
||||
anim::{AnimationHelper, ICON_EXPANSION_MULTIPLE},
|
||||
show_pointer, NoteOptions, NoteView,
|
||||
@@ -20,9 +19,7 @@ pub struct TimelineView<'a, 'd> {
|
||||
timeline_cache: &'a mut TimelineCache,
|
||||
note_options: NoteOptions,
|
||||
reverse: bool,
|
||||
is_muted: &'a MuteFun,
|
||||
note_context: &'a mut NoteContext<'d>,
|
||||
cur_acc: &'a KeypairUnowned<'a>,
|
||||
jobs: &'a mut JobsCache,
|
||||
col: usize,
|
||||
scroll_to_top: bool,
|
||||
@@ -33,10 +30,8 @@ impl<'a, 'd> TimelineView<'a, 'd> {
|
||||
pub fn new(
|
||||
timeline_id: &'a TimelineKind,
|
||||
timeline_cache: &'a mut TimelineCache,
|
||||
is_muted: &'a MuteFun,
|
||||
note_context: &'a mut NoteContext<'d>,
|
||||
note_options: NoteOptions,
|
||||
cur_acc: &'a KeypairUnowned<'a>,
|
||||
jobs: &'a mut JobsCache,
|
||||
col: usize,
|
||||
) -> Self {
|
||||
@@ -47,9 +42,7 @@ impl<'a, 'd> TimelineView<'a, 'd> {
|
||||
timeline_cache,
|
||||
note_options,
|
||||
reverse,
|
||||
is_muted,
|
||||
note_context,
|
||||
cur_acc,
|
||||
jobs,
|
||||
col,
|
||||
scroll_to_top,
|
||||
@@ -63,9 +56,7 @@ impl<'a, 'd> TimelineView<'a, 'd> {
|
||||
self.timeline_cache,
|
||||
self.reverse,
|
||||
self.note_options,
|
||||
self.is_muted,
|
||||
self.note_context,
|
||||
self.cur_acc,
|
||||
self.jobs,
|
||||
self.col,
|
||||
self.scroll_to_top,
|
||||
@@ -90,9 +81,7 @@ fn timeline_ui(
|
||||
timeline_cache: &mut TimelineCache,
|
||||
reversed: bool,
|
||||
note_options: NoteOptions,
|
||||
is_muted: &MuteFun,
|
||||
note_context: &mut NoteContext,
|
||||
cur_acc: &KeypairUnowned,
|
||||
jobs: &mut JobsCache,
|
||||
col: usize,
|
||||
scroll_to_top: bool,
|
||||
@@ -187,9 +176,7 @@ fn timeline_ui(
|
||||
reversed,
|
||||
note_options,
|
||||
&txn,
|
||||
is_muted,
|
||||
note_context,
|
||||
cur_acc,
|
||||
jobs,
|
||||
)
|
||||
.show(ui)
|
||||
@@ -372,9 +359,7 @@ pub struct TimelineTabView<'a, 'd> {
|
||||
reversed: bool,
|
||||
note_options: NoteOptions,
|
||||
txn: &'a Transaction,
|
||||
is_muted: &'a MuteFun,
|
||||
note_context: &'a mut NoteContext<'d>,
|
||||
cur_acc: &'a KeypairUnowned<'a>,
|
||||
jobs: &'a mut JobsCache,
|
||||
}
|
||||
|
||||
@@ -385,9 +370,7 @@ impl<'a, 'd> TimelineTabView<'a, 'd> {
|
||||
reversed: bool,
|
||||
note_options: NoteOptions,
|
||||
txn: &'a Transaction,
|
||||
is_muted: &'a MuteFun,
|
||||
note_context: &'a mut NoteContext<'d>,
|
||||
cur_acc: &'a KeypairUnowned<'a>,
|
||||
jobs: &'a mut JobsCache,
|
||||
) -> Self {
|
||||
Self {
|
||||
@@ -395,9 +378,7 @@ impl<'a, 'd> TimelineTabView<'a, 'd> {
|
||||
reversed,
|
||||
note_options,
|
||||
txn,
|
||||
is_muted,
|
||||
note_context,
|
||||
cur_acc,
|
||||
jobs,
|
||||
}
|
||||
}
|
||||
@@ -406,7 +387,7 @@ impl<'a, 'd> TimelineTabView<'a, 'd> {
|
||||
let mut action: Option<NoteAction> = None;
|
||||
let len = self.tab.notes.len();
|
||||
|
||||
let is_muted = self.is_muted;
|
||||
let is_muted = self.note_context.accounts.mutefun();
|
||||
|
||||
self.tab
|
||||
.list
|
||||
@@ -444,21 +425,10 @@ impl<'a, 'd> TimelineTabView<'a, 'd> {
|
||||
};
|
||||
|
||||
if !muted {
|
||||
let zapping_acc = if self.note_context.current_account_has_wallet {
|
||||
Some(self.cur_acc)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
notedeck_ui::padding(8.0, ui, |ui| {
|
||||
let resp = NoteView::new(
|
||||
self.note_context,
|
||||
zapping_acc,
|
||||
¬e,
|
||||
self.note_options,
|
||||
self.jobs,
|
||||
)
|
||||
.show(ui);
|
||||
let resp =
|
||||
NoteView::new(self.note_context, ¬e, self.note_options, self.jobs)
|
||||
.show(ui);
|
||||
|
||||
if let Some(note_action) = resp.action {
|
||||
action = Some(note_action)
|
||||
|
||||
Reference in New Issue
Block a user