Skip to content

Commit

Permalink
Fix sending sync update status from feed utils
Browse files Browse the repository at this point in the history
  • Loading branch information
sictiru committed Apr 1, 2024
1 parent eed5bda commit ce2b579
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ open class NbActivity : AppCompatActivity() {

// Facilitates the db updates by the sync service on the UI
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.RESUMED) {
repeatOnLifecycle(Lifecycle.State.CREATED) {
launch {
NbSyncManager.state.collectLatest {
withContext(Dispatchers.Main) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.newsblur.service

import com.newsblur.util.NBScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.launch
Expand All @@ -26,7 +27,7 @@ object NbSyncManager {
fun submitError(msg: String) = submit(NBSync.Error(msg))

private fun submit(nbSync: NBSync) {
NBScope.launch {
NBScope.launch(Dispatchers.IO) {
_state.emit(nbSync)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.text.TextUtils
import com.newsblur.NbApplication
import com.newsblur.R
import com.newsblur.activity.NbActivity
import com.newsblur.database.BlurDatabaseHelper
Expand All @@ -13,10 +14,11 @@ import com.newsblur.domain.Story
import com.newsblur.fragment.ReadingActionConfirmationFragment
import com.newsblur.network.APIConstants
import com.newsblur.network.APIManager
import com.newsblur.service.NBSyncService
import com.newsblur.service.NbSyncManager
import com.newsblur.service.NbSyncManager.UPDATE_METADATA
import com.newsblur.service.NbSyncManager.UPDATE_SOCIAL
import com.newsblur.service.NbSyncManager.UPDATE_STORY
import com.newsblur.service.NBSyncService
import com.newsblur.service.OriginalTextService
import com.newsblur.util.FeedExt.disableNotification
import com.newsblur.util.FeedExt.setNotifyFocus
Expand Down Expand Up @@ -486,8 +488,10 @@ class FeedUtils(
UIUtils.handleUri(context, Uri.parse(url))
}

private fun syncUpdateStatus(updateType: Int) {

private fun syncUpdateStatus(update: Int) {
if (NbApplication.isAppForeground) {
NbSyncManager.submitUpdate(update)
}
}

companion object {
Expand Down

0 comments on commit ce2b579

Please sign in to comment.