From 3e4c2a70dc551f2f15295bbf7b5dd980d7397b1b Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Thu, 9 May 2024 01:56:10 +0300 Subject: [PATCH] cleanup logs --- ng-app/src-tauri/src/lib.rs | 2 +- ng-app/src/lib/Test.svelte | 6 ++--- ng-app/src/store.ts | 14 +++++----- ng-sdk-js/src/lib.rs | 2 +- ng-verifier/src/request_processor.rs | 4 +-- ng-verifier/src/verifier.rs | 38 +++++++++++++--------------- 6 files changed, 31 insertions(+), 35 deletions(-) diff --git a/ng-app/src-tauri/src/lib.rs b/ng-app/src-tauri/src/lib.rs index 1a1c035..30398fc 100644 --- a/ng-app/src-tauri/src/lib.rs +++ b/ng-app/src-tauri/src/lib.rs @@ -269,7 +269,7 @@ async fn app_request_stream( .await .map_err(|e| e.to_string())?; - log_debug!("END OF LOOP"); + //log_debug!("END OF LOOP"); Ok(()) } diff --git a/ng-app/src/lib/Test.svelte b/ng-app/src/lib/Test.svelte index ca15ca4..e36f832 100644 --- a/ng-app/src/lib/Test.svelte +++ b/ng-app/src/lib/Test.svelte @@ -259,11 +259,11 @@ {:then} {#each $files as file}

- {file.V0.File.name}
- did:ng{file.V0.File.nuri} + {file.V0.File.name} + {#await get_img(file.V0.File) then url} {#if url} - + {/if} {/await}

diff --git a/ng-app/src/store.ts b/ng-app/src/store.ts index 22013b7..e97771e 100644 --- a/ng-app/src/store.ts +++ b/ng-app/src/store.ts @@ -174,11 +174,11 @@ export const branch_subs = function(nura) { return { load: async () => { - console.log("load upper"); + //console.log("load upper"); let already_subscribed = all_branches[nura]; if (!already_subscribed) return; if (already_subscribed.load) { - console.log("doing the load"); + //console.log("doing the load"); let loader = already_subscribed.load; already_subscribed.load = undefined; // already_subscribed.load2 = loader; @@ -195,7 +195,7 @@ export const branch_subs = function(nura) { already_subscribed = { load: async () => { try { - console.log("load down"); + //console.log("load down"); let session = get(active_session); if (!session) { console.error("no session"); @@ -206,7 +206,7 @@ export const branch_subs = function(nura) { set([]); unsub = await ng.app_request_stream(session.session_id, await ng.doc_fetch_private_subscribe(), async (commit) => { - console.log("GOT APP RESPONSE", commit); + //console.log("GOT APP RESPONSE", commit); update( (old) => {old.unshift(commit); return old;} ) }); } @@ -218,12 +218,12 @@ export const branch_subs = function(nura) { }, increase: () => { count += 1; - console.log("increase sub to",count); + //console.log("increase sub to",count); return readonly({subscribe}); }, decrease: () => { count -= 1; - console.log("decrease sub to",count); + //console.log("decrease sub to",count); // if (count == 0) { // unsub(); // console.log("removed sub"); @@ -238,7 +238,7 @@ export const branch_subs = function(nura) { let read_unsub = new_store.subscribe(run, invalid); return () => { read_unsub(); - console.log("callback unsub"); + //console.log("callback unsub"); already_subscribed.decrease(); } diff --git a/ng-sdk-js/src/lib.rs b/ng-sdk-js/src/lib.rs index e755f6f..4df91ee 100644 --- a/ng-sdk-js/src/lib.rs +++ b/ng-sdk-js/src/lib.rs @@ -537,7 +537,7 @@ pub async fn app_request_stream( } } } - log_info!("END OF LOOP"); + //log_info!("END OF LOOP"); Ok(()) } diff --git a/ng-verifier/src/request_processor.rs b/ng-verifier/src/request_processor.rs index 7ab0e2a..240f288 100644 --- a/ng-verifier/src/request_processor.rs +++ b/ng-verifier/src/request_processor.rs @@ -41,9 +41,7 @@ impl AppRequestCommandV0 { AppFetchContentV0::Subscribe => { let (_, branch_id, _) = Self::open_for_target(verifier, &nuri.target, false).await?; - Ok(verifier - .create_branch_subscription(branch_id, false) - .await?) + Ok(verifier.create_branch_subscription(branch_id).await?) } _ => unimplemented!(), }, diff --git a/ng-verifier/src/verifier.rs b/ng-verifier/src/verifier.rs index aa77f4a..3b85b5d 100644 --- a/ng-verifier/src/verifier.rs +++ b/ng-verifier/src/verifier.rs @@ -154,11 +154,11 @@ impl Verifier { } pub(crate) async fn push_app_response(&mut self, branch: &BranchId, response: AppResponse) { - log_info!( - "push_app_response {} {:?}", - branch, - self.branch_subscriptions - ); + // log_info!( + // "push_app_response {} {:?}", + // branch, + // self.branch_subscriptions + // ); if let Some(sender) = self.branch_subscriptions.get_mut(branch) { if sender.is_closed() { log_info!("closed so removed"); @@ -172,7 +172,6 @@ impl Verifier { pub(crate) async fn create_branch_subscription( &mut self, branch: BranchId, - resub: bool, ) -> Result<(Receiver, CancelFn), VerifierError> { // async fn send(mut tx: Sender, msg: AppResponse) -> ResultSend<()> { // while let Ok(_) = tx.send(msg.clone()).await { @@ -185,26 +184,25 @@ impl Verifier { // spawn_and_log_error(send(tx.clone(), commit)); //log_info!("#### create_branch_subscription {}", branch); let (tx, rx) = mpsc::unbounded::(); - log_info!("SUBSCRIBE"); + //log_info!("SUBSCRIBE"); if let Some(returned) = self.branch_subscriptions.insert(branch, tx.clone()) { - log_info!("RESUBSCRIBE"); + //log_info!("RESUBSCRIBE"); if !returned.is_closed() { - log_info!("FORCE CLOSE"); + //log_info!("FORCE CLOSE"); returned.close_channel(); //return Err(VerifierError::DoubleBranchSubscription); } } - if !resub { - //let tx = self.branch_subscriptions.entry(branch).or_insert_with(|| {}); - for file in self - .user_storage - .as_ref() - .unwrap() - .branch_get_all_files(&branch)? - { - self.push_app_response(&branch, AppResponse::V0(AppResponseV0::File(file))) - .await; - } + + //let tx = self.branch_subscriptions.entry(branch).or_insert_with(|| {}); + for file in self + .user_storage + .as_ref() + .unwrap() + .branch_get_all_files(&branch)? + { + self.push_app_response(&branch, AppResponse::V0(AppResponseV0::File(file))) + .await; } let fnonce = Box::new(move || {