community: a proposal on your board arrives as a toast, carried sealed through the inbox

This commit is contained in:
KeelrLeek committed 2026-09-03 12:16:33 -05:00
1 parent 4d03cf849b
commit fd216ecd3d
6 files changed
+241 -1

No files matched your search

+37 -1
View File
@@ -24,18 +24,21 @@ use library::{NewPlaylistItem, PlaylistItem};
use persona_state::playlist as pl;
use persona_state::proposals as pr;
use serde::{Deserialize, Serialize};
use tauri::Manager;
use tauri::{Emitter, Manager};
use crate::persona;
use crate::pipeline::LibraryState;
use crate::playlists;
use crate::shared_playlists::{self, Published};
use crate::inbox::{self, Cargo, ProposalPing};
use crate::ledger;
use crate::slsk_link;
use crate::spaces;
use crate::state::AppState;
const BOARD_WASM: &[u8] = include_bytes!("../assets/proposal_contract.wasm");
/// A proposal landed on a board of ours. The UI answers with a toast.
pub const EVENT: &str = "community:proposal";
#[derive(Default, Clone, Serialize, Deserialize)]
struct BoardRecord {
@@ -502,8 +505,22 @@ pub async fn propose(app: &tauri::AppHandle, space_owner_b58: &str, space_b58: &
if !pr::proposal_valid(&p) {
return Err("the proposal did not validate (a size or field cap)".into());
}
let pid = p.proposal_id;
offer_board(app, &pin.owner, &pin.uuid, &partial(&pin.owner, &pin.uuid, None, vec![p], vec![]), false).await?;
log::info!("proposals: offered a proposal to board {}", b58(&pin.uuid));
// The board only gets read on open and Refresh, so tell the owner it is
// there. Best-effort by design: it needs their published inbox, and the
// proposal stands on the board whether or not this lands.
if pin.owner != me {
let ping = Cargo::ProposalPing(ProposalPing {
playlist_uuid: pin.uuid,
name: manifest.name.clone(),
proposal_id: pid,
});
if let Err(e) = inbox::send(app, &pin.owner, &ping).await {
log::info!("proposals: no ping to the owner ({e}) — the board still holds it");
}
}
open(app, space_owner_b58, space_b58).await
}
@@ -555,6 +572,25 @@ pub async fn decide(app: &tauri::AppHandle, space_owner_b58: &str, space_b58: &s
open(app, space_owner_b58, space_b58).await
}
/// Sealed cargo from inbox.rs: someone proposed against a playlist of ours.
/// Nothing is stored — the board is the record; this only raises the toast.
pub(crate) fn on_inbox_proposal(app: &tauri::AppHandle, sender: [u8; 32], ping: ProposalPing) {
let key = b58(&sender);
let who = slsk_link::username_for_key(app, &key).unwrap_or(key);
log::info!("proposals: {who} proposed a change to {:?}", ping.name);
let _ = app.emit(
EVENT,
ProposalPingEvent { from: who, playlist: ping.name, proposal_id: b58(&ping.proposal_id) },
);
}
#[derive(Debug, Clone, Serialize)]
struct ProposalPingEvent {
from: String,
playlist: String,
proposal_id: String,
}
/// Bring the owner's local playlist to `entries`, then publish it as the
/// next revision. Refused when the local copy has drifted from the base
/// revision — the exact-base rule holds on this side too.