Skip to content

Commit

Permalink
[fix]: small final fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
F0x1d committed Oct 18, 2023
1 parent fdfce8a commit d6aeba3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ class LogsFragment: BaseViewModelFragment<LogsViewModel, FragmentLogsBinding>(),
})

binding.scrollFab.setOnClickListener {
scrollLogToBottom()

if (viewModel.resumeLoggingWithBottomTouch)
viewModel.resume()
else
scrollLogToBottom()
}

viewModel.selectedItems.asLiveData().observe(viewLifecycleOwner) {
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/f0x1d/logfox/viewmodel/LogsViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.scan
Expand Down Expand Up @@ -47,12 +48,12 @@ class LogsViewModel @Inject constructor(
fileUri?.readFileContentsAsFlow(ctx, appPreferences) ?: loggingRepository.logsFlow,
database.userFilterDao().getAllAsFlow(),
query,
if (!viewingFile) paused else MutableStateFlow(true)
if (!viewingFile) paused else flowOf(false)
) { logs, filters, query, paused ->
LogsData(logs, filters, query, paused)
}.scan(null as LogsData?) { accumulator, data ->
when {
!data.paused || viewingFile -> data
!data.paused -> data

data.query != accumulator?.query -> data.copy(logs = accumulator?.logs ?: emptyList())
data.filters != accumulator?.filters -> data.copy(logs = accumulator?.logs ?: emptyList())
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim">
app:popExitAnim="@anim/nav_default_pop_exit_anim"
app:popUpTo="@id/logsFragment"
app:popUpToInclusive="false">
<argument
android:name="file_uri"
app:argType="android.net.Uri"
Expand Down

0 comments on commit d6aeba3

Please sign in to comment.