android: share a note with a group
CI & Build / Python lint (push) Successful in 2s
CI & Build / Build now, or wait for Android? (push) Successful in 3s
Android / Build, or is the channel already serving this? (push) Successful in 3s
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 2s
CI & Build / Web typecheck and unit tests (push) Successful in 9s
CI & Build / Python tests (push) Successful in 11s
CI & Build / integration (push) Successful in 1m22s
CI & Build / Build & push image (push) Skipped
Desktop (Tauri) / Web tests, clippy, Rust tests and rustfmt (push) Successful in 2m39s
Desktop (Tauri) / Windows installer (cross-compiled) (push) Successful in 2m37s
Desktop (Tauri) / Tauri desktop (Linux) (push) Successful in 3m26s
Desktop (Tauri) / Update manifest (push) Successful in 3s
Android / Kotlin + Rust (APK) (push) Successful in 8m16s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Build now, or wait for Android? (push) Successful in 3s
Android / Build, or is the channel already serving this? (push) Successful in 3s
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 2s
CI & Build / Web typecheck and unit tests (push) Successful in 9s
CI & Build / Python tests (push) Successful in 11s
CI & Build / integration (push) Successful in 1m22s
CI & Build / Build & push image (push) Skipped
Desktop (Tauri) / Web tests, clippy, Rust tests and rustfmt (push) Successful in 2m39s
Desktop (Tauri) / Windows installer (cross-compiled) (push) Successful in 2m37s
Desktop (Tauri) / Tauri desktop (Linux) (push) Successful in 3m26s
Desktop (Tauri) / Update manifest (push) Successful in 3s
Android / Kotlin + Rust (APK) (push) Successful in 8m16s
The Share sheet lists groups after people, shows a group share as its name and how many are in it, and shares through the FFI's ShareTarget. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+10
-9
@@ -43,8 +43,9 @@ use inkwell_core::sync::blobs::BlobStore;
|
||||
use inkwell_core::sync::{client, compat, engine, push, sharing, state};
|
||||
|
||||
use models::{
|
||||
patch_from, BodyItem, BodyTag, ClientUpdate, Identity, Label, Member, Note, NoteDraft,
|
||||
NoteEdit, NoteQuery, NoteShare, ProbeResult, RevokeOutcome, SyncOutcome, SyncStatus,
|
||||
patch_from, BodyItem, BodyTag, ClientUpdate, Directory, Identity, Label, Note, NoteDraft,
|
||||
NoteEdit, NoteQuery, NoteShare, ProbeResult, RevokeOutcome, ShareTarget, SyncOutcome,
|
||||
SyncStatus,
|
||||
};
|
||||
|
||||
uniffi::setup_scaffolding!();
|
||||
@@ -612,13 +613,13 @@ impl Inkwell {
|
||||
// The Share dialog asks the server directly (#5175). Unlinked, each answers
|
||||
// `NotLinked`, which the dialog turns into "sharing needs a server".
|
||||
|
||||
/// Everyone on the instance a note can be shared with.
|
||||
pub async fn share_directory(&self) -> Result<Vec<Member>, CoreError> {
|
||||
/// Everyone on the instance a note can be shared with, and every group.
|
||||
pub async fn share_directory(&self) -> Result<Directory, CoreError> {
|
||||
self.credentials()?;
|
||||
let members = sharing::directory(&self.db)
|
||||
let directory = sharing::directory(&self.db)
|
||||
.await
|
||||
.map_err(CoreError::network)?;
|
||||
Ok(members.into_iter().map(Member::from).collect())
|
||||
Ok(directory.into())
|
||||
}
|
||||
|
||||
/// Who this note is shared with.
|
||||
@@ -630,15 +631,15 @@ impl Inkwell {
|
||||
Ok(shares.into_iter().map(NoteShare::from).collect())
|
||||
}
|
||||
|
||||
/// Share with one member at "view" or "edit", or change their permission.
|
||||
/// Share with a person or a group at "view" or "edit", or change their permission.
|
||||
pub async fn share_note(
|
||||
&self,
|
||||
note_id: String,
|
||||
user_id: String,
|
||||
target: ShareTarget,
|
||||
permission: String,
|
||||
) -> Result<Vec<NoteShare>, CoreError> {
|
||||
self.credentials()?;
|
||||
let shares = sharing::share(&self.db, ¬e_id, &user_id, &permission)
|
||||
let shares = sharing::share(&self.db, ¬e_id, &target.into(), &permission)
|
||||
.await
|
||||
.map_err(CoreError::network)?;
|
||||
Ok(shares.into_iter().map(NoteShare::from).collect())
|
||||
|
||||
@@ -636,11 +636,68 @@ impl From<core_client::Member> for Member {
|
||||
}
|
||||
}
|
||||
|
||||
/// One person a note is shared with, at "view" or "edit".
|
||||
/// A group the admin made, which a note can be shared with (#5177).
|
||||
#[derive(Debug, Clone, uniffi::Record)]
|
||||
pub struct ShareGroup {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub member_count: u32,
|
||||
}
|
||||
|
||||
impl From<core_client::ShareGroup> for ShareGroup {
|
||||
fn from(value: core_client::ShareGroup) -> Self {
|
||||
let core_client::ShareGroup {
|
||||
id,
|
||||
name,
|
||||
member_count,
|
||||
} = value;
|
||||
ShareGroup {
|
||||
id,
|
||||
name,
|
||||
member_count,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Everyone a note can be shared with: the other people, and every group.
|
||||
#[derive(Debug, Clone, uniffi::Record)]
|
||||
pub struct Directory {
|
||||
pub members: Vec<Member>,
|
||||
pub groups: Vec<ShareGroup>,
|
||||
}
|
||||
|
||||
impl From<core_client::Directory> for Directory {
|
||||
fn from(value: core_client::Directory) -> Self {
|
||||
let core_client::Directory { members, groups } = value;
|
||||
Directory {
|
||||
members: members.into_iter().map(Member::from).collect(),
|
||||
groups: groups.into_iter().map(ShareGroup::from).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Who a new share goes to: one person, or a group.
|
||||
#[derive(Debug, Clone, uniffi::Enum)]
|
||||
pub enum ShareTarget {
|
||||
Member { id: String },
|
||||
Group { id: String },
|
||||
}
|
||||
|
||||
impl From<ShareTarget> for core_client::ShareTarget {
|
||||
fn from(value: ShareTarget) -> Self {
|
||||
match value {
|
||||
ShareTarget::Member { id } => core_client::ShareTarget::Member(id),
|
||||
ShareTarget::Group { id } => core_client::ShareTarget::Group(id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One share of a note, at "view" or "edit": to a person or to a group, never both.
|
||||
#[derive(Debug, Clone, uniffi::Record)]
|
||||
pub struct NoteShare {
|
||||
pub id: String,
|
||||
pub member: Member,
|
||||
pub member: Option<Member>,
|
||||
pub group: Option<ShareGroup>,
|
||||
pub permission: String,
|
||||
}
|
||||
|
||||
@@ -650,12 +707,14 @@ impl From<core_client::NoteShare> for NoteShare {
|
||||
let core_client::NoteShare {
|
||||
id,
|
||||
member,
|
||||
group,
|
||||
permission,
|
||||
created_at: _,
|
||||
} = value;
|
||||
NoteShare {
|
||||
id,
|
||||
member: member.into(),
|
||||
member: member.map(Member::from),
|
||||
group: group.map(ShareGroup::from),
|
||||
permission,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user