feat(core,app,android,ios): rename a share

ShareStore::rename changes only the name; the id that the catalog, watch
state and offline files are keyed by stays the same. Sync carries the
change as it does any other change to the share's register. The desktop
renames in the share's row. The phones rename from the share's menu.
Before, the name given at add time was permanent short of removing the
share.
This commit is contained in:
nvrl committed 2026-10-13 16:01:11 +02:00
1 parent 5b931111b3
commit abb3e3aaf8
10 files changed
+185

No files matched your search

+12
View File
@@ -146,6 +146,11 @@ pub enum Action {
OpenShareForm,
/// Stop offering posters and synopses on the library page.
DismissMetadataOffer,
/// Call a share something else.
RenameShare {
id: String,
name: String,
},
/// Store a new link, and password, for a share already in the library.
RepairShare {
id: String,
@@ -563,6 +568,9 @@ pub struct ShareForm {
pub repairing: Option<String>,
pub repair_url: String,
pub repair_password: String,
/// The share being renamed in its own row, if any, and the name so far.
pub renaming: Option<String>,
pub rename_to: String,
}
pub struct App {
@@ -1671,6 +1679,10 @@ impl App {
self.form.error = None;
self.note(ctx, "share link pasted — add it, or name it first", false);
}
Action::RenameShare { id, name } => {
self.form.renaming = None;
self.engine.rename_share(id, name);
}
Action::RepairShare { id, url, password } => {
self.crawling = true;
self.form.repairing = None;
+10
View File
@@ -696,6 +696,16 @@ impl Engine {
});
}
/// Call a share something else. See [`ShareStore::rename`].
pub fn rename_share(&self, id: String, name: String) {
let engine = self.clone();
self.runtime
.spawn_blocking(move || match engine.store.rename(&id, &name) {
Ok(_) => engine.load_shares(),
Err(error) => engine.fail("rename the share", error),
});
}
/// Re-supply the link behind a share whose stored secret is unreadable —
/// a keyring that was reset — or whose custom password changed, keeping
/// its catalog, watch state and downloads. See
+35
View File
@@ -108,6 +108,10 @@ fn share_row(
if ui.button("Crawl").clicked() {
actions.push(Action::Crawl(Some(share.id.clone())));
}
if ui.button("Rename").clicked() {
form.renaming = Some(share.id.clone());
form.rename_to = share.name.clone();
}
// Not for a folder of the account, which has no link.
if share.folder.is_none()
&& ui
@@ -127,10 +131,41 @@ fn share_row(
if form.repairing.as_deref() == Some(share.id.as_str()) {
repair_form(ui, share, form, actions);
}
if form.renaming.as_deref() == Some(share.id.as_str()) {
rename_form(ui, share, form, actions);
}
});
ui.add_space(theme::space::S);
}
/// A new name for a share, in its own row. Enter saves, as everywhere else.
fn rename_form(ui: &mut egui::Ui, share: &Share, form: &mut ShareForm, actions: &mut Vec<Action>) {
ui.add_space(theme::space::M);
ui.horizontal(|ui| {
let field = ui.add(
egui::TextEdit::singleline(&mut form.rename_to)
.hint_text("Name")
.desired_width(320.0),
);
let ready = !form.rename_to.trim().is_empty();
let entered = field.lost_focus() && ui_enter_pressed(ui.ctx());
if ui
.add_enabled_ui(ready, |ui| ui::accent_button(ui, "Save"))
.inner
.clicked()
|| (ready && entered)
{
actions.push(Action::RenameShare {
id: share.id.clone(),
name: form.rename_to.trim().to_owned(),
});
}
if ui.button("Cancel").clicked() {
form.renaming = None;
}
});
}
/// The same link again, and a password if it has one, for a share already in
/// the library.
fn repair_form(ui: &mut egui::Ui, share: &Share, form: &mut ShareForm, actions: &mut Vec<Action>) {