Skip to content

Commit

Permalink
feat: プッシュ通知を開いた時に正しくアカウントが切り替わらない問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
pantasystem committed Jan 11, 2024
1 parent f902712 commit 2fe67dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.google.firebase.crashlytics.FirebaseCrashlytics
import dagger.hilt.android.scopes.ActivityScoped
import jp.panta.misskeyandroidclient.R
import kotlinx.coroutines.launch
import net.pantasystem.milktea.app_store.account.AccountStore
import net.pantasystem.milktea.common.mapCancellableCatching
import net.pantasystem.milktea.common.runCancellableCatching
import net.pantasystem.milktea.common_navigation.UserDetailNavigation
Expand All @@ -31,12 +32,14 @@ class MainActivityInitialIntentHandler(
private val activity: AppCompatActivity,
private val userDetailNavigation: UserDetailNavigation,
private val accountRepository: AccountRepository,
private val accountStore: AccountStore,
) {

@ActivityScoped
class Factory @Inject constructor(
private val userDetailNavigation: UserDetailNavigation,
private val accountRepository: AccountRepository,
private val accountStore: AccountStore,
) {
fun create(
bottomNavigationView: BottomNavigationView,
Expand All @@ -47,6 +50,7 @@ class MainActivityInitialIntentHandler(
activity,
userDetailNavigation,
accountRepository,
accountStore,
)
}
}
Expand All @@ -57,7 +61,7 @@ class MainActivityInitialIntentHandler(
if (pushNotification != null) {
activity.lifecycleScope.launch {
accountRepository.get(pushNotification.accountId).mapCancellableCatching {
accountRepository.setCurrentAccount(it).getOrThrow()
accountStore.setCurrent(it)
}.onSuccess {
navigateBy(pushNotification)
}.onFailure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class AccountStore @Inject constructor(
}

suspend fun removePage(page: Page): Boolean {
val account = _state.value.get(page.accountId)
val account = _state.value[page.accountId]
?: _state.value.currentAccount
?: return false
val updated = account.copy(pages = account.pages.filterNot { it.pageId == page.pageId })
Expand Down

0 comments on commit 2fe67dd

Please sign in to comment.