Skip to content

Commit

Permalink
feat: Fix request sender ownership and mutability issues in FreenetAp…
Browse files Browse the repository at this point in the history
…iSynchronizer

This commit resolves compilation errors related to sender ownership and mutability by:
- Properly cloning request_sender for different closure scopes
- Making sender mutable where needed
- Ensuring request_sender is available for FreenetApiSender struct
  • Loading branch information
sanity committed Dec 25, 2024
1 parent c568690 commit 666c6b6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ui/src/components/app/freenet_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ impl FreenetApiSynchronizer {
pub fn start() -> Self {
let subscribed_contracts = HashSet::new();
let (request_sender, _request_receiver) = futures::channel::mpsc::unbounded();
let request_sender_for_api = request_sender.clone();

let _sender = FreenetApiSender { request_sender: request_sender.clone() };

// Start the sync coroutine
use_coroutine(move |mut rx| {
let request_sender = request_sender.clone();
async move {
*SYNC_STATUS.write() = SyncStatus::Connecting;

Expand Down Expand Up @@ -88,7 +90,7 @@ impl FreenetApiSynchronizer {

// Watch for changes to Rooms signal
let rooms = use_context::<Signal<Rooms>>();
let request_sender = request_sender.clone();
let request_sender_clone = request_sender.clone();

use_effect(move || {
{
Expand All @@ -99,7 +101,7 @@ impl FreenetApiSynchronizer {
key: room.contract_key,
data: freenet_stdlib::prelude::UpdateData::State(state_bytes.into()),
};
let sender = request_sender.clone();
let mut sender = request_sender_clone.clone();
wasm_bindgen_futures::spawn_local(async move {
if let Err(e) = sender.send(update_request.into()).await {
log::error!("Failed to send room update: {}", e);
Expand Down

0 comments on commit 666c6b6

Please sign in to comment.