Skip to content

Commit b5ebfda

Browse files
JOHNJOHN
authored andcommitted
fix: add missing @hiltviewmodel annotations
1 parent f029658 commit b5ebfda

File tree

6 files changed

+12
-177
lines changed

6 files changed

+12
-177
lines changed

app/src/main/java/to/bitkit/paykit/viewmodels/AutoPayViewModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ import to.bitkit.paykit.models.PeerSpendingLimit
1212
import to.bitkit.paykit.services.AutopayEvaluationResult
1313
import to.bitkit.paykit.services.IAutopayEvaluator
1414
import to.bitkit.paykit.storage.AutoPayStorage
15+
import dagger.hilt.android.lifecycle.HiltViewModel
1516
import to.bitkit.utils.Logger
1617
import javax.inject.Inject
1718

1819
/**
1920
* ViewModel for Auto-Pay settings
2021
*/
22+
@HiltViewModel
2123
class AutoPayViewModel @Inject constructor(
2224
private val autoPayStorage: AutoPayStorage
2325
) : ViewModel() {

app/src/main/java/to/bitkit/paykit/viewmodels/ContactsViewModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import kotlinx.coroutines.launch
99
import to.bitkit.paykit.models.Contact
1010
import to.bitkit.paykit.services.DirectoryService
1111
import to.bitkit.paykit.storage.ContactStorage
12+
import dagger.hilt.android.lifecycle.HiltViewModel
1213
import to.bitkit.utils.Logger
1314
import javax.inject.Inject
1415

1516
/**
1617
* ViewModel for Contacts management
1718
*/
19+
@HiltViewModel
1820
class ContactsViewModel @Inject constructor(
1921
private val contactStorage: ContactStorage,
2022
private val directoryService: DirectoryService

app/src/main/java/to/bitkit/paykit/viewmodels/DashboardViewModel.kt

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import kotlinx.coroutines.flow.MutableStateFlow
66
import kotlinx.coroutines.flow.StateFlow
77
import kotlinx.coroutines.flow.asStateFlow
88
import kotlinx.coroutines.launch
9-
import org.json.JSONObject
109
import to.bitkit.paykit.models.Receipt
10+
import dagger.hilt.android.lifecycle.HiltViewModel
1111
import to.bitkit.paykit.storage.*
1212
import javax.inject.Inject
1313

1414
/**
1515
* ViewModel for Paykit Dashboard
1616
*/
17+
@HiltViewModel
1718
class DashboardViewModel @Inject constructor(
1819
private val receiptStorage: ReceiptStorage,
1920
private val contactStorage: ContactStorage,
@@ -59,39 +60,9 @@ class DashboardViewModel @Inject constructor(
5960
val publishedMethodsCount: StateFlow<Int> = _publishedMethodsCount.asStateFlow()
6061

6162
fun loadDashboard() {
62-
// #region agent log
63-
try {
64-
val logData = mapOf(
65-
"location" to "DashboardViewModel.kt:60",
66-
"message" to "loadDashboard called",
67-
"data" to emptyMap<String, Any>(),
68-
"timestamp" to System.currentTimeMillis(),
69-
"sessionId" to "debug-session",
70-
"runId" to "run1",
71-
"hypothesisId" to "B"
72-
)
73-
java.io.File("/Users/john/Library/Mobile Documents/com~apple~CloudDocs/vibes/pubky-ring/.cursor/debug.log").appendText(org.json.JSONObject(logData).toString() + "\n")
74-
} catch (e: Exception) {}
75-
// #endregion
76-
7763
viewModelScope.launch {
7864
_isLoading.value = true
7965

80-
// #region agent log
81-
try {
82-
val logData = mapOf(
83-
"location" to "DashboardViewModel.kt:68",
84-
"message" to "Before loading receipts",
85-
"data" to emptyMap<String, Any>(),
86-
"timestamp" to System.currentTimeMillis(),
87-
"sessionId" to "debug-session",
88-
"runId" to "run1",
89-
"hypothesisId" to "B"
90-
)
91-
java.io.File("/Users/john/Library/Mobile Documents/com~apple~CloudDocs/vibes/pubky-ring/.cursor/debug.log").appendText(org.json.JSONObject(logData).toString() + "\n")
92-
} catch (e: Exception) {}
93-
// #endregion
94-
9566
// Load recent receipts
9667
_recentReceipts.value = receiptStorage.recentReceipts(limit = 5)
9768

app/src/main/java/to/bitkit/paykit/viewmodels/ReceiptsViewModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import kotlinx.coroutines.launch
99
import to.bitkit.paykit.models.PaymentDirection
1010
import to.bitkit.paykit.models.PaymentStatus
1111
import to.bitkit.paykit.models.Receipt
12+
import dagger.hilt.android.lifecycle.HiltViewModel
1213
import to.bitkit.paykit.storage.ReceiptStorage
1314
import javax.inject.Inject
1415

1516
/**
1617
* ViewModel for Receipts view
1718
*/
19+
@HiltViewModel
1820
class ReceiptsViewModel @Inject constructor(
1921
private val receiptStorage: ReceiptStorage
2022
) : ViewModel() {

app/src/main/java/to/bitkit/paykit/viewmodels/SubscriptionsViewModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import kotlinx.coroutines.flow.asStateFlow
88
import kotlinx.coroutines.launch
99
import to.bitkit.paykit.models.Subscription
1010
import to.bitkit.paykit.storage.SubscriptionStorage
11+
import dagger.hilt.android.lifecycle.HiltViewModel
1112
import to.bitkit.utils.Logger
1213
import javax.inject.Inject
1314

1415
/**
1516
* ViewModel for Subscriptions management
1617
*/
18+
@HiltViewModel
1719
class SubscriptionsViewModel @Inject constructor(
1820
private val subscriptionStorage: SubscriptionStorage
1921
) : ViewModel() {

app/src/main/java/to/bitkit/ui/paykit/PaykitDashboardScreen.kt

Lines changed: 2 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ import androidx.compose.runtime.Composable
4343
import androidx.compose.runtime.LaunchedEffect
4444
import androidx.compose.runtime.collectAsState
4545
import androidx.compose.runtime.getValue
46-
import androidx.compose.runtime.mutableStateOf
4746
import androidx.compose.runtime.remember
48-
import androidx.compose.runtime.setValue
4947
import androidx.compose.ui.Alignment
5048
import androidx.compose.ui.Modifier
5149
import androidx.compose.ui.graphics.vector.ImageVector
@@ -54,7 +52,6 @@ import androidx.compose.ui.text.font.FontWeight
5452
import androidx.compose.ui.text.style.TextAlign
5553
import androidx.compose.ui.unit.dp
5654
import androidx.hilt.navigation.compose.hiltViewModel
57-
import org.json.JSONObject
5855
import to.bitkit.paykit.services.PubkyRingBridge
5956
import to.bitkit.paykit.viewmodels.DashboardViewModel
6057
import to.bitkit.ui.components.Title
@@ -77,38 +74,7 @@ fun PaykitDashboardScreen(
7774
onNavigateToPubkyRingAuth: () -> Unit = {},
7875
viewModel: DashboardViewModel = hiltViewModel(),
7976
) {
80-
// #region agent log
81-
try {
82-
val logData = mapOf(
83-
"location" to "PaykitDashboardScreen.kt:79",
84-
"message" to "PaykitDashboardScreen composable entry",
85-
"data" to mapOf("hasViewModel" to (viewModel != null)),
86-
"timestamp" to System.currentTimeMillis(),
87-
"sessionId" to "debug-session",
88-
"runId" to "run1",
89-
"hypothesisId" to "A"
90-
)
91-
java.io.File("/Users/john/Library/Mobile Documents/com~apple~CloudDocs/vibes/pubky-ring/.cursor/debug.log").appendText(org.json.JSONObject(logData).toString() + "\n")
92-
} catch (e: Exception) {}
93-
// #endregion
94-
9577
val context = LocalContext.current
96-
97-
// #region agent log
98-
try {
99-
val logData = mapOf(
100-
"location" to "PaykitDashboardScreen.kt:82",
101-
"message" to "Before collectAsState calls",
102-
"data" to mapOf("contextNotNull" to (context != null)),
103-
"timestamp" to System.currentTimeMillis(),
104-
"sessionId" to "debug-session",
105-
"runId" to "run1",
106-
"hypothesisId" to "B"
107-
)
108-
java.io.File("/Users/john/Library/Mobile Documents/com~apple~CloudDocs/vibes/pubky-ring/.cursor/debug.log").appendText(org.json.JSONObject(logData).toString() + "\n")
109-
} catch (e: Exception) {}
110-
// #endregion
111-
11278
val recentReceipts by viewModel.recentReceipts.collectAsState()
11379
val contactCount by viewModel.contactCount.collectAsState()
11480
val totalSent by viewModel.totalSent.collectAsState()
@@ -120,126 +86,16 @@ fun PaykitDashboardScreen(
12086
val pendingRequests by viewModel.pendingRequests.collectAsState()
12187
val publishedMethodsCount by viewModel.publishedMethodsCount.collectAsState()
12288

123-
// #region agent log
124-
try {
125-
val logData = mapOf(
126-
"location" to "PaykitDashboardScreen.kt:95",
127-
"message" to "Before PubkyRingBridge.getInstance()",
128-
"data" to emptyMap<String, Any>(),
129-
"timestamp" to System.currentTimeMillis(),
130-
"sessionId" to "debug-session",
131-
"runId" to "run1",
132-
"hypothesisId" to "A"
133-
)
134-
java.io.File("/Users/john/Library/Mobile Documents/com~apple~CloudDocs/vibes/pubky-ring/.cursor/debug.log").appendText(org.json.JSONObject(logData).toString() + "\n")
135-
} catch (e: Exception) {}
136-
// #endregion
137-
13889
val pubkyRingBridge = remember {
139-
try {
140-
PubkyRingBridge.getInstance()
141-
} catch (e: Exception) {
142-
// #region agent log
143-
try {
144-
val logData = mapOf(
145-
"location" to "PaykitDashboardScreen.kt:98",
146-
"message" to "PubkyRingBridge.getInstance() failed",
147-
"data" to mapOf("error" to (e.message ?: "unknown"), "errorType" to e.javaClass.simpleName),
148-
"timestamp" to System.currentTimeMillis(),
149-
"sessionId" to "debug-session",
150-
"runId" to "run1",
151-
"hypothesisId" to "A"
152-
)
153-
java.io.File("/Users/john/Library/Mobile Documents/com~apple~CloudDocs/vibes/pubky-ring/.cursor/debug.log").appendText(org.json.JSONObject(logData).toString() + "\n")
154-
} catch (logErr: Exception) {}
155-
// #endregion
156-
null
157-
}
90+
runCatching { PubkyRingBridge.getInstance() }.getOrNull()
15891
}
15992

160-
// #region agent log
161-
try {
162-
val logData = mapOf(
163-
"location" to "PaykitDashboardScreen.kt:105",
164-
"message" to "After PubkyRingBridge.getInstance()",
165-
"data" to mapOf("pubkyRingBridgeNotNull" to (pubkyRingBridge != null)),
166-
"timestamp" to System.currentTimeMillis(),
167-
"sessionId" to "debug-session",
168-
"runId" to "run1",
169-
"hypothesisId" to "A"
170-
)
171-
java.io.File("/Users/john/Library/Mobile Documents/com~apple~CloudDocs/vibes/pubky-ring/.cursor/debug.log").appendText(org.json.JSONObject(logData).toString() + "\n")
172-
} catch (e: Exception) {}
173-
// #endregion
174-
17593
val isPubkyRingInstalled = remember(pubkyRingBridge) {
176-
// #region agent log
177-
try {
178-
val logData = mapOf(
179-
"location" to "PaykitDashboardScreen.kt:115",
180-
"message" to "Calling isPubkyRingInstalled",
181-
"data" to mapOf("pubkyRingBridgeNotNull" to (pubkyRingBridge != null), "contextNotNull" to (context != null)),
182-
"timestamp" to System.currentTimeMillis(),
183-
"sessionId" to "debug-session",
184-
"runId" to "run1",
185-
"hypothesisId" to "A"
186-
)
187-
java.io.File("/Users/john/Library/Mobile Documents/com~apple~CloudDocs/vibes/pubky-ring/.cursor/debug.log").appendText(org.json.JSONObject(logData).toString() + "\n")
188-
} catch (e: Exception) {}
189-
// #endregion
19094
pubkyRingBridge?.isPubkyRingInstalled(context) ?: false
19195
}
19296

19397
LaunchedEffect(Unit) {
194-
// #region agent log
195-
try {
196-
val logData = mapOf(
197-
"location" to "PaykitDashboardScreen.kt:192",
198-
"message" to "LaunchedEffect triggered, calling loadDashboard",
199-
"data" to emptyMap<String, Any>(),
200-
"timestamp" to System.currentTimeMillis(),
201-
"sessionId" to "debug-session",
202-
"runId" to "run1",
203-
"hypothesisId" to "B"
204-
)
205-
java.io.File("/Users/john/Library/Mobile Documents/com~apple~CloudDocs/vibes/pubky-ring/.cursor/debug.log").appendText(org.json.JSONObject(logData).toString() + "\n")
206-
} catch (e: Exception) {}
207-
// #endregion
208-
209-
try {
210-
viewModel.loadDashboard()
211-
212-
// #region agent log
213-
try {
214-
val logData = mapOf(
215-
"location" to "PaykitDashboardScreen.kt:205",
216-
"message" to "loadDashboard call completed",
217-
"data" to emptyMap<String, Any>(),
218-
"timestamp" to System.currentTimeMillis(),
219-
"sessionId" to "debug-session",
220-
"runId" to "run1",
221-
"hypothesisId" to "B"
222-
)
223-
java.io.File("/Users/john/Library/Mobile Documents/com~apple~CloudDocs/vibes/pubky-ring/.cursor/debug.log").appendText(org.json.JSONObject(logData).toString() + "\n")
224-
} catch (e: Exception) {}
225-
// #endregion
226-
} catch (e: Exception) {
227-
// #region agent log
228-
try {
229-
val logData = mapOf(
230-
"location" to "PaykitDashboardScreen.kt:217",
231-
"message" to "loadDashboard threw exception",
232-
"data" to mapOf("error" to (e.message ?: "unknown"), "errorType" to e.javaClass.simpleName, "stackTrace" to e.stackTraceToString()),
233-
"timestamp" to System.currentTimeMillis(),
234-
"sessionId" to "debug-session",
235-
"runId" to "run1",
236-
"hypothesisId" to "B"
237-
)
238-
java.io.File("/Users/john/Library/Mobile Documents/com~apple~CloudDocs/vibes/pubky-ring/.cursor/debug.log").appendText(org.json.JSONObject(logData).toString() + "\n")
239-
} catch (logErr: Exception) {}
240-
// #endregion
241-
throw e
242-
}
98+
viewModel.loadDashboard()
24399
}
244100

245101
ScreenColumn {

0 commit comments

Comments
 (0)