gui: one held-list strip for Documents, Clippings and podcast episodes
Three screens each drew "N new … — Show" for a list a sync is holding back, in two different looks. components::incoming_banner::held_strip is the list-level counterpart of incoming_banner, and all three use it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b66874262e
commit
ed7e3171bb
4 files changed
+61
-67
No files matched your search
@@ -65,7 +65,7 @@ use synchronicity::stores::Store;
|
||||
use synchronicity::stores::document::DocumentCursor;
|
||||
|
||||
use crate::components::button::{OnClickIf, button, danger_button};
|
||||
use crate::components::incoming_banner::incoming_banner;
|
||||
use crate::components::incoming_banner::{held_strip, incoming_banner};
|
||||
use crate::components::note::error_line;
|
||||
use crate::components::screen_header::{screen_header, screen_title};
|
||||
use crate::components::sync_guarded::SyncGuarded;
|
||||
@@ -894,23 +894,12 @@ impl ClippingsView {
|
||||
fn render_pending(&self, theme: &Theme, cx: &mut Context<Self>) -> Option<Div> {
|
||||
let waiting =
|
||||
self.clippings.incoming()?.len().saturating_sub(self.clippings.current().len());
|
||||
Some(
|
||||
div()
|
||||
.flex()
|
||||
.flex_row()
|
||||
.items_center()
|
||||
.gap_3()
|
||||
.child(
|
||||
div()
|
||||
.flex_1()
|
||||
.text_color(theme.text_secondary)
|
||||
.child(copy_clippings::pending(waiting)),
|
||||
)
|
||||
.child(
|
||||
button(theme, "clippings-show-new", action::SHOW, true, true)
|
||||
.on_click(cx.listener(|this, _, _, cx| this.show_pending(cx))),
|
||||
),
|
||||
)
|
||||
Some(held_strip(
|
||||
theme,
|
||||
"clippings-show-new",
|
||||
copy_clippings::pending(waiting),
|
||||
cx.listener(|this, _, _, cx| this.show_pending(cx)),
|
||||
))
|
||||
}
|
||||
|
||||
/// Nothing more than the fact. Where clippings come from is the browser
|
||||
|
||||
@@ -23,7 +23,7 @@ use gpui::{
|
||||
use synchronicity::agents::AgentId;
|
||||
use synchronicity::content_ledger::{NodeHolding, SubtreeContent, subtree_content};
|
||||
use synchronicity::copy::documents as copy_documents;
|
||||
use synchronicity::copy::{action, content_presence, document_display, format_bytes};
|
||||
use synchronicity::copy::{content_presence, document_display, format_bytes};
|
||||
use synchronicity::documents::import::{
|
||||
ImportProgress, ImportTarget, ImportTotals, create_collection_node, import_directory_tree,
|
||||
import_file,
|
||||
@@ -46,8 +46,8 @@ use tokio::runtime::Handle;
|
||||
use crate::agent_sidebar::{AgentSidebar, View};
|
||||
use crate::app::AppServices;
|
||||
use crate::background::spawn_then;
|
||||
use crate::components::button::button;
|
||||
use crate::components::imports_in_progress::ImportsInProgress;
|
||||
use crate::components::incoming_banner::held_strip;
|
||||
use crate::components::note::{dismissible_error, fill_note};
|
||||
use crate::components::table::{GridColumns, Table};
|
||||
use crate::components::tabs::{tab_bar, tab_pill};
|
||||
@@ -1147,33 +1147,15 @@ fn empty_note(theme: &Theme) -> gpui::AnyElement {
|
||||
impl DocumentsView {
|
||||
/// The held-change strip: what a sync did while the user was busy, and the
|
||||
/// way to see it.
|
||||
///
|
||||
/// Deliberately quiet — the ground color and secondary text of a note,
|
||||
/// not the error banner's warning border. Nothing has gone wrong; there is
|
||||
/// simply a newer list than the one on screen, and it is being kept out of
|
||||
/// the way until it is asked for.
|
||||
fn render_changed_strip(&self, theme: &Theme, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
div()
|
||||
.flex()
|
||||
.flex_row()
|
||||
.items_center()
|
||||
.gap_2()
|
||||
.px_4()
|
||||
.py_2()
|
||||
.bg(theme.bg_raised)
|
||||
.child(
|
||||
div()
|
||||
.flex_1()
|
||||
.text_size(font::BODY)
|
||||
.text_color(theme.text_secondary)
|
||||
.child(copy_documents::CHANGED_ELSEWHERE),
|
||||
)
|
||||
.child(
|
||||
// "Show" is the explicit act, so it is the full reload the
|
||||
// Refresh button runs — which also clears this strip.
|
||||
button(theme, "docs-show-changes", action::SHOW, false, true)
|
||||
.on_click(cx.listener(|this, _, _, cx| this.reload(cx))),
|
||||
)
|
||||
// "Show" is the explicit act, so it is the full reload the Refresh
|
||||
// button runs — which also clears this strip.
|
||||
held_strip(
|
||||
theme,
|
||||
"docs-show-changes",
|
||||
copy_documents::CHANGED_ELSEWHERE,
|
||||
cx.listener(|this, _, _, cx| this.reload(cx)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,7 @@ use gpui::{
|
||||
};
|
||||
use synchronicity::agents::AgentId;
|
||||
use synchronicity::agents::podcast::{self, PodcastIndexEpisode, get_podcast_episodes};
|
||||
use synchronicity::copy::{
|
||||
action, episode_download, library_empty, listen_state, podcast_episodes,
|
||||
};
|
||||
use synchronicity::copy::{episode_download, library_empty, listen_state, podcast_episodes};
|
||||
use synchronicity::documents::{DocumentID, ListenState, Timestamp};
|
||||
use synchronicity::jobs::runner::JobRunner;
|
||||
use synchronicity::node::NodePubkey;
|
||||
@@ -37,6 +35,7 @@ use crate::agents::podcasts::{
|
||||
use crate::app::AppServices;
|
||||
use crate::background::spawn_then;
|
||||
use crate::components::button::{OnClickIf, button};
|
||||
use crate::components::incoming_banner::held_strip;
|
||||
use crate::components::note::error_line;
|
||||
use crate::components::player_controls::{PlayerControls, PlayerControlsEvent};
|
||||
use crate::components::sync_guarded::SyncGuarded;
|
||||
@@ -919,23 +918,12 @@ impl PodcastDetailView {
|
||||
/// acted on rather than by timing out.
|
||||
fn render_pending(&self, theme: &Theme, cx: &mut Context<Self>) -> Option<Div> {
|
||||
let waiting = self.episodes.incoming()?.len().saturating_sub(self.episodes.current().len());
|
||||
Some(
|
||||
div()
|
||||
.flex()
|
||||
.flex_row()
|
||||
.items_center()
|
||||
.gap_3()
|
||||
.child(
|
||||
div()
|
||||
.flex_1()
|
||||
.text_color(theme.text_secondary)
|
||||
.child(podcast_episodes::held(waiting)),
|
||||
)
|
||||
.child(
|
||||
button(theme, "podcast-episodes-show-new", action::SHOW, true, true)
|
||||
.on_click(cx.listener(|this, _, _, cx| this.show_pending(cx))),
|
||||
),
|
||||
)
|
||||
Some(held_strip(
|
||||
theme,
|
||||
"podcast-episodes-show-new",
|
||||
podcast_episodes::held(waiting),
|
||||
cx.listener(|this, _, _, cx| this.show_pending(cx)),
|
||||
))
|
||||
}
|
||||
|
||||
/// One episode card: title, date + optional duration, elided description.
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
//! [`SyncGuarded`](super::sync_guarded::SyncGuarded) for the state it is
|
||||
//! usually drawn over.
|
||||
|
||||
use gpui::{App, ClickEvent, Div, Window, div, prelude::*, px, svg};
|
||||
use gpui::{App, ClickEvent, Div, ElementId, SharedString, Window, div, prelude::*, px, svg};
|
||||
use synchronicity::copy::action;
|
||||
use synchronicity::copy::incoming_change::Subject;
|
||||
|
||||
use crate::assets::Icon;
|
||||
@@ -54,3 +55,37 @@ pub fn incoming_banner(
|
||||
.child(button(theme, ids.0, subject.take_theirs(), false, true).on_click(on_take))
|
||||
.child(button(theme, ids.1, subject.keep_mine(), false, true).on_click(on_keep))
|
||||
}
|
||||
|
||||
/// The list-level counterpart: a newer version of a whole list is being held
|
||||
/// back, and the one choice is to show it. `text` says how much is waiting
|
||||
/// (`copy::podcast_episodes::held`, `copy::clippings::pending`, …), so that
|
||||
/// ignoring it is an informed choice.
|
||||
///
|
||||
/// Deliberately quiet — the ground color and secondary text of a note, not an
|
||||
/// error's warning. Nothing has gone wrong; there is simply a newer list than
|
||||
/// the one on screen.
|
||||
pub fn held_strip(
|
||||
theme: &Theme,
|
||||
id: impl Into<ElementId>,
|
||||
text: impl Into<SharedString>,
|
||||
on_show: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
|
||||
) -> Div {
|
||||
div()
|
||||
.flex_none()
|
||||
.flex()
|
||||
.flex_row()
|
||||
.items_center()
|
||||
.gap_3()
|
||||
.px_4()
|
||||
.py_2()
|
||||
.bg(theme.bg_raised)
|
||||
.child(
|
||||
div()
|
||||
.flex_1()
|
||||
.min_w(px(0.))
|
||||
.text_size(font::SMALL)
|
||||
.text_color(theme.text_secondary)
|
||||
.child(text.into()),
|
||||
)
|
||||
.child(button(theme, id, action::SHOW, false, true).on_click(on_show))
|
||||
}
|
||||
Reference in new issue
Block a user