Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make fixes in Markets #7534

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ fun EtfPage(
ViewState.Success -> {
val listState = rememberSaveable(
uiState.sortBy,
uiState.timeDuration,
saver = LazyListState.Saver
) {
LazyListState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import io.horizontalsystems.bankwallet.modules.market.etf.EtfModule.EtfViewItem
import io.horizontalsystems.marketkit.models.Etf
import io.horizontalsystems.marketkit.models.EtfPoint
import io.horizontalsystems.marketkit.models.HsTimePeriod
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
Expand Down Expand Up @@ -90,6 +91,8 @@ class EtfViewModel(
updateViewItems()

viewState = ViewState.Success
} catch (e: CancellationException) {
// no-op
} catch (e: Throwable) {
viewState = ViewState.Error(e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ fun MarketFavoritesScreen(
onSelect = { selected ->
manualOrderEnabled = false
openSortingSelector = false
scrollToTopAfterUpdate = true
viewModel.onSelectSortingField(selected)

stat(page = StatPage.Markets, section = StatSection.Watchlist, event = StatEvent.SwitchSortType(selected.statSortType))
Expand All @@ -183,8 +184,9 @@ fun MarketFavoritesScreen(
title = R.string.CoinPage_Period,
select = Select(uiState.period, viewModel.periods),
onSelect = { selected ->
viewModel.onSelectPeriod(selected)
openPeriodSelector = false
scrollToTopAfterUpdate = true
viewModel.onSelectPeriod(selected)

stat(page = StatPage.Markets, section = StatSection.Watchlist, event = StatEvent.SwitchPeriod(selected.statPeriod))
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import io.horizontalsystems.core.BackgroundManager
import io.horizontalsystems.marketkit.models.Analytics
import io.reactivex.Observable
import io.reactivex.subjects.BehaviorSubject
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
Expand Down Expand Up @@ -73,6 +74,8 @@ class MarketFavoritesService(
if (menuService.showSignals) {
syncSignals()
}
} catch (e: CancellationException) {
// no-op
} catch (e: Throwable) {
marketItemsSubject.onNext(DataState.Error(e))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class MarketFiltersViewModel(val service: MarketFiltersService)
solidDexOn = false
goodDistributionOn = false
selectedBlockchains = emptyList()
filterTradingSignal = FilterViewItemWrapper.getAny()
updateSelectedBlockchains()
emitState()
reloadData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import io.horizontalsystems.bankwallet.modules.market.TimeDuration
import io.horizontalsystems.bankwallet.modules.market.TopMarket
import io.horizontalsystems.bankwallet.modules.market.category.MarketItemWrapper
import io.reactivex.subjects.BehaviorSubject
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
Expand Down Expand Up @@ -84,6 +85,8 @@ class MarketTopCoinsService(
).await()

syncItems()
} catch (e: CancellationException) {
//do nothing
} catch (e: Throwable) {
stateObservable.onNext(DataState.Error(e))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ fun TopCoins(
onSelect = { selected ->
viewModel.onSelectPeriod(selected)
openPeriodSelector = false
scrollToTopAfterUpdate = true

stat(page = StatPage.Markets, section = StatSection.Coins, event = StatEvent.SwitchPeriod(selected.statPeriod))
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
Expand Down Expand Up @@ -56,6 +58,10 @@ fun TopPairsScreen() {
val uiState = viewModel.uiState
val context = LocalContext.current

val state = rememberSaveable(uiState.sortDescending, saver = LazyListState.Saver) {
LazyListState(0, 0)
}

Scaffold(
backgroundColor = ComposeAppTheme.colors.tyler,
) {
Expand All @@ -79,6 +85,7 @@ fun TopPairsScreen() {

ViewState.Success -> {
LazyColumn(
state = state,
modifier = Modifier.fillMaxSize()
) {
stickyHeader {
Expand All @@ -98,7 +105,7 @@ fun TopPairsScreen() {
}
}
itemsIndexed(uiState.items) { i, item ->
TopPairItem(item, borderTop = i == 0, borderBottom = true) {
TopPairItem(item, borderBottom = true) {
it.tradeUrl?.let {
LinkHelper.openLinkInAppBrowser(context, it)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import io.horizontalsystems.bankwallet.core.stats.StatSortType
import io.horizontalsystems.bankwallet.core.stats.stat
import io.horizontalsystems.bankwallet.entities.ViewState
import io.horizontalsystems.bankwallet.modules.market.overview.TopPairViewItem
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -63,6 +64,8 @@ class TopPairsViewModel(
}
items = sortItems(pairs)
viewState = ViewState.Success
} catch (e: CancellationException) {
// no-op
} catch (e: Throwable) {
viewState = ViewState.Error(e)
}
Expand Down
Loading