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

+35
View File
@@ -13,6 +13,7 @@ struct SharesView: View {
@State private var browsing = false
@State private var repairing: ShareRecord?
@State private var removing: ShareRecord?
@State private var renaming: ShareRecord?
var body: some View {
TabPage("Shares") {
@@ -34,6 +35,7 @@ struct SharesView: View {
share: share,
onRefresh: { model.refreshShare(share.id) },
onRepair: { repairing = share },
onRename: { renaming = share },
onRemove: { removing = share }
)
}
@@ -78,6 +80,9 @@ struct SharesView: View {
.fullScreenCover(isPresented: $browsing) {
DriveBrowser()
}
.sheet(item: $renaming) { share in
RenameShareSheet(share: share) { model.renameShare(id: share.id, name: $0) }
}
.sheet(item: $repairing) { share in
RepairShareSheet(share: share) { url, password in
model.repairShare(id: share.id, url: url, password: password)
@@ -124,6 +129,7 @@ private struct ShareRow: View {
let share: ShareRecord
let onRefresh: () -> Void
let onRepair: () -> Void
let onRename: () -> Void
let onRemove: () -> Void
@Environment(\.scheme) private var scheme
@@ -147,6 +153,7 @@ private struct ShareRow: View {
// One share, not the library: a link that has just had files
// added should not cost a walk of every other one.
Button(action: onRefresh) { Label("Refresh", systemImage: "arrow.clockwise") }
Button(action: onRename) { Label("Rename", systemImage: "pencil") }
// Not a remove: a share whose secret has become unreadable
// cannot be removed either.
if !share.fromAccount {
@@ -165,6 +172,34 @@ private struct ShareRow: View {
}
}
/// A new name for a share. The library, history and downloads stay.
private struct RenameShareSheet: View {
let share: ShareRecord
let onRename: (String) -> Void
@Environment(\.dismiss) private var dismiss
@State private var name: String
init(share: ShareRecord, onRename: @escaping (String) -> Void) {
self.share = share
self.onRename = onRename
_name = State(initialValue: share.name)
}
var body: some View {
DialogSheet("Rename \(share.name)") {
Field(label: "Name", text: $name)
} buttons: {
Button("Cancel") { dismiss() }.buttonStyle(.tonal)
Button("Save") {
onRename(name.trimmingCharacters(in: .whitespaces))
dismiss()
}
.buttonStyle(.accent)
.disabled(name.trimmingCharacters(in: .whitespaces).isEmpty)
}
}
}
/// Re-enter the link for a share the app can no longer decrypt its secret for.
///
/// It has to be the *same* link — a different token is a different share.