`Day 79` - Bug fixes ◦ *issue (solved)* - :whi...
# 100daysofkotlin-2021
b
Day 79
• Bug fixes ◦ issue (solved) - - Note not saving / caching ▪︎ Changed VM coroutine from ViewModelScope to GlobalScope. I changed the NoteAddViewModel from being created on startup to when navigating to NoteAddScreen. Problem here was the coroutine wasn't surviving long enough to complete in the VM lifecycle. ◦ issue (discovered) - Taking 10-15 seconds for new/updated note displays on listScreen & 15+ seconds for it to register the newly changed/added note when navigating to the add/edit notescreen. Discovered it's only an issue if the emulator has a connection & server is down. (if airplane mode is on or if emulator has connect + server is up... works fine)issue (discovered) - when creating a new note, if the note is not saved directly, it is not being cached. I had deleted some old caching method, just needs reimplementingissue (solved) - When logging out, instead of deleting the notes from cache, it flickers by deleting and re-inserting the notes. Perhaps I need to add a delay or check for credentials somewhere between deleting/reinserting while syncing... ▪︎ Added code below to UserScreen. Another issue with resetting authentication. Perhaps I should hoist an authentication state here to avoid missing these calls. 😅
Copy code
LaunchedEffect(username) {
        vm.authenticateApi(username ?: "", password ?: "")
        syncNotes()
    }
issue (solved) - When registering, it does not refresh the syncNotes keeping the old notes (from previous bug) and not starting with an empty list. ▪︎ Added
vm.authenticateApi(trimmedUsername, trimmedPassword)
to the register button after a successfully registering the account. Had this on the login button, but since I'm navigating to the user screen on succesfully creating an account, I needed to authenticate the new user • Owner is now assigned to note on creation & is inserted/updated through server to MongoDb • Notes now sync upon login. (issue above)