Debug Navigation
This commit is contained in:
parent
3dec997d41
commit
30b9e45aa3
@ -64,12 +64,21 @@ fun NotebookApp(viewModel: NotebookViewModel) {
|
||||
var chatInput by remember { mutableStateOf("") }
|
||||
var selectedNotebookId by remember { mutableIntStateOf(-1) }
|
||||
|
||||
// Log setiap kali selectedNotebookId berubah
|
||||
LaunchedEffect(selectedNotebookId) {
|
||||
println("🎯 selectedNotebookId berubah menjadi: $selectedNotebookId")
|
||||
}
|
||||
|
||||
// Kalau ada notebook yang dipilih, tampilkan detail screen
|
||||
if (selectedNotebookId != -1) {
|
||||
println("✨ Menampilkan NotebookDetailScreen untuk ID: $selectedNotebookId")
|
||||
com.example.notebook.ui.screens.NotebookDetailScreen(
|
||||
viewModel = viewModel,
|
||||
notebookId = selectedNotebookId,
|
||||
onBack = { selectedNotebookId = -1 }
|
||||
onBack = {
|
||||
println("⬅️ Kembali dari detail screen")
|
||||
selectedNotebookId = -1
|
||||
}
|
||||
)
|
||||
return
|
||||
}
|
||||
@ -258,14 +267,13 @@ fun NotebookCard(
|
||||
val dateFormat = SimpleDateFormat("dd MMM yyyy, HH:mm", Locale.getDefault())
|
||||
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable {
|
||||
println("🔵 Notebook diklik: ID=${notebook.id}, Title=${notebook.title}")
|
||||
onClick()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
colors = CardDefaults.cardColors(containerColor = Color(0xFFF8F9FA))
|
||||
colors = CardDefaults.cardColors(containerColor = Color(0xFFF8F9FA)),
|
||||
onClick = {
|
||||
println("🔵 Card onClick: ID=${notebook.id}, Title=${notebook.title}")
|
||||
onClick()
|
||||
}
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
|
||||
@ -60,9 +60,19 @@ fun NotebookDetailScreen(
|
||||
|
||||
// Load notebook data
|
||||
LaunchedEffect(notebookId) {
|
||||
println("🚀 NotebookDetailScreen: LaunchedEffect triggered untuk ID: $notebookId")
|
||||
viewModel.selectNotebook(notebookId)
|
||||
}
|
||||
|
||||
// Debug log untuk state changes
|
||||
LaunchedEffect(notebook) {
|
||||
println("📝 Notebook state updated: ${notebook?.title ?: "NULL"}")
|
||||
}
|
||||
|
||||
LaunchedEffect(sources) {
|
||||
println("📚 Sources updated: ${sources.size} items")
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
|
||||
@ -82,11 +82,15 @@ class NotebookViewModel(application: Application) : AndroidViewModel(application
|
||||
* Pilih notebook untuk dibuka
|
||||
*/
|
||||
fun selectNotebook(notebookId: Int) {
|
||||
println("📂 selectNotebook dipanggil dengan ID: $notebookId")
|
||||
viewModelScope.launch {
|
||||
repository.getNotebookById(notebookId).collect { notebook ->
|
||||
println("📖 Notebook data: ${notebook?.title ?: "NULL"}")
|
||||
_currentNotebook.value = notebook
|
||||
notebook?.let {
|
||||
println("📦 Loading sources untuk notebook ID: $notebookId")
|
||||
loadSources(notebookId)
|
||||
println("💬 Loading chat history untuk notebook ID: $notebookId")
|
||||
loadChatHistory(notebookId)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user