Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post mentions #723

Merged
merged 10 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ uuid = { version = "1.10.0", features = ["v4"] }
security-framework = "2.11.0"
sha2 = "0.10.8"

[patch.crates-io]
egui = { git = "https://github.com/kernelkind/egui", branch = "update_layouter_0.29.1" }
epaint = { git = "https://github.com/kernelkind/egui", branch = "update_layouter_0.29.1" }

[profile.small]
inherits = 'release'
opt-level = 'z' # Optimize for size
Expand Down
1 change: 1 addition & 0 deletions crates/notedeck_columns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ rfd = "0.15"

[dev-dependencies]
tempfile = { workspace = true }
pretty_assertions = "1.4.1"

[target.'cfg(target_os = "macos")'.dependencies]
security-framework = "2.11.0"
Expand Down
18 changes: 11 additions & 7 deletions crates/notedeck_columns/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@ fn render_damus_mobile(app: &mut Damus, app_ctx: &mut AppContext<'_>, ui: &mut e
//let routes = app.timelines[0].routes.clone();

if !app.columns(app_ctx.accounts).columns().is_empty()
&& nav::render_nav(0, app, app_ctx, ui).process_render_nav_response(app, app_ctx)
&& nav::render_nav(0, ui.available_rect_before_wrap(), app, app_ctx, ui)
.process_render_nav_response(app, app_ctx)
&& !app.tmp_columns
{
storage::save_decks_cache(app_ctx.path, &app.decks_cache);
Expand Down Expand Up @@ -584,14 +585,17 @@ fn timelines_view(ui: &mut egui::Ui, sizes: Size, app: &mut Damus, ctx: &mut App
for col_index in 0..num_cols {
strip.cell(|ui| {
let rect = ui.available_rect_before_wrap();
responses.push(nav::render_nav(col_index, app, ctx, ui));
let v_line_stroke = ui.visuals().widgets.noninteractive.bg_stroke;
let inner_rect = {
let mut inner = rect;
inner.set_right(rect.right() - v_line_stroke.width);
inner
};
responses.push(nav::render_nav(col_index, inner_rect, app, ctx, ui));

// vertical line
ui.painter().vline(
rect.right(),
rect.y_range(),
ui.visuals().widgets.noninteractive.bg_stroke,
);
ui.painter()
.vline(rect.right(), rect.y_range(), v_line_stroke);
});

//strip.cell(|ui| timeline::timeline_view(ui, app, timeline_ind));
Expand Down
15 changes: 12 additions & 3 deletions crates/notedeck_columns/src/draft.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
use egui::text::LayoutJob;
use poll_promise::Promise;

use crate::{media_upload::Nip94Event, ui::note::PostType, Error};
use crate::{media_upload::Nip94Event, post::PostBuffer, ui::note::PostType, Error};
use std::collections::HashMap;

#[derive(Default)]
pub struct Draft {
pub buffer: String,
pub buffer: PostBuffer,
pub cur_layout: Option<(String, LayoutJob)>, // `PostBuffer::text_buffer` to current `LayoutJob`
pub cur_mention_hint: Option<MentionHint>,
pub uploaded_media: Vec<Nip94Event>, // media uploads to include
pub uploading_media: Vec<Promise<Result<Nip94Event, Error>>>, // promises that aren't ready yet
pub upload_errors: Vec<String>, // media upload errors to show the user
}

pub struct MentionHint {
pub index: usize,
pub pos: egui::Pos2,
pub text: String,
}

#[derive(Default)]
pub struct Drafts {
replies: HashMap<[u8; 32], Draft>,
Expand Down Expand Up @@ -46,7 +55,7 @@ impl Draft {
}

pub fn clear(&mut self) {
self.buffer = "".to_string();
self.buffer = PostBuffer::default();
self.upload_errors = Vec::new();
self.uploaded_media = Vec::new();
self.uploading_media = Vec::new();
Expand Down
7 changes: 6 additions & 1 deletion crates/notedeck_columns/src/nav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ fn render_nav_body(
top: &Route,
depth: usize,
col: usize,
inner_rect: egui::Rect,
) -> Option<RenderNavAction> {
match top {
Route::Timeline(kind) => render_timeline_route(
Expand Down Expand Up @@ -308,6 +309,7 @@ fn render_nav_body(
ctx.note_cache,
ctx.img_cache,
&note,
inner_rect,
)
.id_source(id)
.show(ui)
Expand Down Expand Up @@ -342,6 +344,7 @@ fn render_nav_body(
ctx.img_cache,
draft,
&note,
inner_rect,
)
.id_source(id)
.show(ui)
Expand All @@ -362,6 +365,7 @@ fn render_nav_body(
ctx.img_cache,
ctx.note_cache,
kp,
inner_rect,
)
.ui(&txn, ui);

Expand Down Expand Up @@ -473,6 +477,7 @@ fn render_nav_body(
#[must_use = "RenderNavResponse must be handled by calling .process_render_nav_response(..)"]
pub fn render_nav(
col: usize,
inner_rect: egui::Rect,
app: &mut Damus,
ctx: &mut AppContext<'_>,
ui: &mut egui::Ui,
Expand Down Expand Up @@ -508,7 +513,7 @@ pub fn render_nav(
.show(ui),
NavUiType::Body => {
if let Some(top) = nav.routes().last() {
render_nav_body(ui, app, ctx, top, nav.routes().len(), col)
render_nav_body(ui, app, ctx, top, nav.routes().len(), col, inner_rect)
} else {
None
}
Expand Down
Loading