Skip to content

Commit

Permalink
Merge pull request #68 from Efimj/fix/minor
Browse files Browse the repository at this point in the history
Fix/minor
  • Loading branch information
Efimj committed Jul 14, 2024
2 parents 739e227 + 686619b commit b58d88e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
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

0 comments on commit b58d88e

Please sign in to comment.