Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/minor #68

Merged
merged 2 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.navigation.compose.composable
import androidx.navigation.toRoute
import com.jobik.shkiper.helpers.IntentHelper
import com.jobik.shkiper.navigation.NavigationHelpers.Companion.canNavigate
import com.jobik.shkiper.navigation.NavigationHelpers.Companion.navigateToMain
import com.jobik.shkiper.screens.about.AboutNotepadScreen
import com.jobik.shkiper.screens.advancedSettings.AdvancedSettings
import com.jobik.shkiper.screens.calendar.CalendarScreen
Expand Down Expand Up @@ -88,12 +89,15 @@ fun SetupAppScreenNavGraph(
LocalNavAnimatedVisibilityScope provides this,
LocalSharedElementKey provides noteScreenArgs.sharedElementOrigin
) {
val context = LocalContext.current
NoteScreen(
onBack = {
if (navController.canNavigate().not()) return@NoteScreen
if (navController.previousBackStackEntry == null) {
IntentHelper().startAppActivity(context)
navController.navigate(Screen.NoteList) {
popUpTo<Screen.Note> {
inclusive = true
}
}
} else {
navController.popBackStack()
}
Expand Down
27 changes: 9 additions & 18 deletions app/src/main/java/com/jobik/shkiper/screens/note/NoteViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import com.jobik.shkiper.database.data.reminder.ReminderMongoRepository
import com.jobik.shkiper.database.models.Note
import com.jobik.shkiper.database.models.NotePosition
import com.jobik.shkiper.database.models.Reminder
import com.jobik.shkiper.database.models.RepeatMode
import com.jobik.shkiper.helpers.DateHelper
import com.jobik.shkiper.helpers.DateHelper.Companion.sortReminders
import com.jobik.shkiper.helpers.IntentHelper
Expand All @@ -27,12 +26,16 @@ import com.jobik.shkiper.widgets.handlers.handleNoteWidgetPin
import com.mohamedrejeb.richeditor.model.RichTextState
import dagger.hilt.android.lifecycle.HiltViewModel
import io.realm.kotlin.ext.realmSetOf
import kotlinx.coroutines.*
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.mongodb.kbson.ObjectId
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime
import java.util.*
import java.util.Timer
import java.util.TimerTask
import javax.inject.Inject

data class NoteScreenState(
Expand Down Expand Up @@ -207,7 +210,7 @@ class NoteViewModel @Inject constructor(
override fun run() {
fetchLinkMetaData()
}
}, 300L)
}, 1500L)
}

private fun fetchLinkMetaData() {
Expand Down Expand Up @@ -453,12 +456,6 @@ class NoteViewModel @Inject constructor(
updatedNote.position = newPosition
updatedNote.isPinned = false
}

// when returning, the snackbar turns off
// showSnackbar(
// message = application.applicationContext.getString(R.string.NoteArchived),
// icon = Icons.Default.Archive
// )
}
}

Expand All @@ -474,12 +471,6 @@ class NoteViewModel @Inject constructor(
noteRepository.updateNote(screenState.value.noteId) { updatedNote ->
updatedNote.position = newPosition
}

// when returning, the snackbar turns off
// showSnackbar(
// message = application.applicationContext.getString(R.string.NoteUnarchived),
// icon = Icons.Default.Unarchive
// )
}
}

Expand Down