From b68df2c3a25e4288a1d61585f48f8add4a3d04ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20K=C3=BCrten?= <sebastian@mobanisto.de>
Date: Sun, 23 Jul 2023 11:18:01 +0200
Subject: [PATCH] Add some logging to debug ability to share private groups

---
 .../sharing/PrivateGroupSharingViewModel.kt           | 11 +++++++++++
 .../sharing/ThreadedGroupSharingViewModel.kt          |  6 ++++++
 briar-desktop/src/main/resources/logback.xml          |  3 +++
 3 files changed, 20 insertions(+)

diff --git a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/privategroup/sharing/PrivateGroupSharingViewModel.kt b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/privategroup/sharing/PrivateGroupSharingViewModel.kt
index 7dea7c6da1..b3983c8282 100644
--- a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/privategroup/sharing/PrivateGroupSharingViewModel.kt
+++ b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/privategroup/sharing/PrivateGroupSharingViewModel.kt
@@ -218,12 +218,23 @@ class PrivateGroupSharingViewModel @Inject constructor(
         members: List<GroupMemberItem>,
         isCreator: Boolean,
     ) {
+        println("loading sharing status")
         val contacts = contactManager.getContacts(txn)
         if (isCreator) {
             val map = contacts.associate { contact ->
                 contact.id to privateGroupInvitationManager.getSharingStatus(txn, contact, groupId)
             }
+            val idToContact = contacts.associate { contact ->
+                contact.id to contact
+            }
+            map.forEach {
+                val contact = idToContact[it.key]
+                if (contact != null) {
+                    println("${contact.id.int} ${contact.author.name} ${contact.alias}: ${it.value.name}")
+                }
+            }
             val sharing = map.filterValues { it == SHARING }.keys
+            println("shareable: $sharing")
             txn.attach {
                 val online =
                     sharing.fold(0) { acc, it -> if (connectionRegistry.isConnected(it)) acc + 1 else acc }
diff --git a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/threadedgroup/sharing/ThreadedGroupSharingViewModel.kt b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/threadedgroup/sharing/ThreadedGroupSharingViewModel.kt
index 55779093e0..3a8cd3147b 100644
--- a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/threadedgroup/sharing/ThreadedGroupSharingViewModel.kt
+++ b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/threadedgroup/sharing/ThreadedGroupSharingViewModel.kt
@@ -93,6 +93,12 @@ abstract class ThreadedGroupSharingViewModel(
     override fun onInit() {
         super.onInit()
         loadContacts()
+        runOnDbThreadWithTransaction(true) { txn ->
+            val contacts = contactManager.getContacts(txn)
+            for (c in contacts) {
+                println("${c.id.int} ${c.author.name} ${c.alias}")
+            }
+        }
     }
 
     @UiExecutor
diff --git a/briar-desktop/src/main/resources/logback.xml b/briar-desktop/src/main/resources/logback.xml
index 5db4b0e406..fa2107368e 100644
--- a/briar-desktop/src/main/resources/logback.xml
+++ b/briar-desktop/src/main/resources/logback.xml
@@ -11,6 +11,9 @@
 
     <logger name="org.briarproject.briar" level="INFO"/>
     <logger name="org.briarproject.briar.desktop" level="INFO"/>
+    <logger name="org.briarproject.onionwrapper" level="ERROR"/>
+    <logger name="org.briarproject.bramble.lifecycle" level="ERROR"/>
+    <logger name="org.briarproject.bramble.plugin" level="ERROR"/>
 
     <root level="INFO">
         <appender-ref ref="STDOUT"/>
-- 
GitLab