Skip to content

Commit

Permalink
feat: 認証済みの状態でテストできるようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
pantasystem committed Sep 16, 2024
1 parent ac12d3b commit e636896
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Intent
import jp.panta.misskeyandroidclient.BuildConfig
import jp.panta.misskeyandroidclient.ui.main.viewmodel.MainViewModel
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import net.pantasystem.milktea.model.account.Account
import net.pantasystem.milktea.model.account.AccountRepository
Expand Down Expand Up @@ -46,15 +47,22 @@ internal class IntentToAddAccountHandler(
val token = intent.getStringExtra("token") ?: return@launch
val remoteId = intent.getStringExtra("remoteId") ?: return@launch

accountRepository.add(
val state = mainViewModel.accountState.first()
if (state.state.accounts.any {
it.userName == username && it.instanceDomain == host
}) {
return@launch
}

mainViewModel.accountStore.addAccount(
Account(
remoteId = remoteId,
instanceDomain = host,
userName = username,
token = token,
instanceType = Account.InstanceType.MISSKEY,
)
).getOrThrow()
)
} finally {
mainViewModel.setShouldWaitForAuthentication(false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class TabFragment : Fragment(R.layout.fragment_tab) {
viewLifecycleOwner.lifecycleScope.launch {
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) {
mTabViewModel.pages.collect { pages ->
requireActivity().reportFullyDrawn()
mPages = pages
mPagerAdapter.setList(
pages.sortedBy {
Expand Down

0 comments on commit e636896

Please sign in to comment.