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 chatInput by remember { mutableStateOf("") }
|
||||||
var selectedNotebookId by remember { mutableIntStateOf(-1) }
|
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
|
// Kalau ada notebook yang dipilih, tampilkan detail screen
|
||||||
if (selectedNotebookId != -1) {
|
if (selectedNotebookId != -1) {
|
||||||
|
println("✨ Menampilkan NotebookDetailScreen untuk ID: $selectedNotebookId")
|
||||||
com.example.notebook.ui.screens.NotebookDetailScreen(
|
com.example.notebook.ui.screens.NotebookDetailScreen(
|
||||||
viewModel = viewModel,
|
viewModel = viewModel,
|
||||||
notebookId = selectedNotebookId,
|
notebookId = selectedNotebookId,
|
||||||
onBack = { selectedNotebookId = -1 }
|
onBack = {
|
||||||
|
println("⬅️ Kembali dari detail screen")
|
||||||
|
selectedNotebookId = -1
|
||||||
|
}
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -258,14 +267,13 @@ fun NotebookCard(
|
|||||||
val dateFormat = SimpleDateFormat("dd MMM yyyy, HH:mm", Locale.getDefault())
|
val dateFormat = SimpleDateFormat("dd MMM yyyy, HH:mm", Locale.getDefault())
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier.fillMaxWidth(),
|
||||||
.fillMaxWidth()
|
|
||||||
.clickable {
|
|
||||||
println("🔵 Notebook diklik: ID=${notebook.id}, Title=${notebook.title}")
|
|
||||||
onClick()
|
|
||||||
},
|
|
||||||
shape = RoundedCornerShape(12.dp),
|
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(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
@ -60,9 +60,19 @@ fun NotebookDetailScreen(
|
|||||||
|
|
||||||
// Load notebook data
|
// Load notebook data
|
||||||
LaunchedEffect(notebookId) {
|
LaunchedEffect(notebookId) {
|
||||||
|
println("🚀 NotebookDetailScreen: LaunchedEffect triggered untuk ID: $notebookId")
|
||||||
viewModel.selectNotebook(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(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
|
|||||||
@ -82,11 +82,15 @@ class NotebookViewModel(application: Application) : AndroidViewModel(application
|
|||||||
* Pilih notebook untuk dibuka
|
* Pilih notebook untuk dibuka
|
||||||
*/
|
*/
|
||||||
fun selectNotebook(notebookId: Int) {
|
fun selectNotebook(notebookId: Int) {
|
||||||
|
println("📂 selectNotebook dipanggil dengan ID: $notebookId")
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
repository.getNotebookById(notebookId).collect { notebook ->
|
repository.getNotebookById(notebookId).collect { notebook ->
|
||||||
|
println("📖 Notebook data: ${notebook?.title ?: "NULL"}")
|
||||||
_currentNotebook.value = notebook
|
_currentNotebook.value = notebook
|
||||||
notebook?.let {
|
notebook?.let {
|
||||||
|
println("📦 Loading sources untuk notebook ID: $notebookId")
|
||||||
loadSources(notebookId)
|
loadSources(notebookId)
|
||||||
|
println("💬 Loading chat history untuk notebook ID: $notebookId")
|
||||||
loadChatHistory(notebookId)
|
loadChatHistory(notebookId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user