fixed visits update

This commit is contained in:
Izlydov 2025-02-20 16:32:27 +03:00
parent e13035320d
commit a40c448fc2
2 changed files with 16 additions and 2 deletions

View File

@ -108,6 +108,7 @@ class ProfileFragment : Fragment(R.layout.fragment_profile) {
private fun refreshData() {
viewModel.getInfo()
viewModel.resetVisits()
viewModel.visitListState.collectWithLifecycle(this) { data ->
adapter.submitData(data)
}

View File

@ -32,7 +32,7 @@ class ProfileViewModel() : ViewModel() {
val _state = MutableStateFlow<State>(State.Loading)
val state = _state.asStateFlow()
val visitListState = Pager(
var visitListState = Pager(
config = PagingConfig(
pageSize = 20,
enablePlaceholders = false,
@ -43,7 +43,7 @@ class ProfileViewModel() : ViewModel() {
}.flow
.cachedIn(viewModelScope)
val visitListStateFromLogin = Pager(
var visitListStateFromLogin = Pager(
config = PagingConfig(pageSize = 20, enablePlaceholders = false, maxSize = 100)
) {
VisitListPagingSource { pageNum, pageSize ->
@ -55,6 +55,19 @@ class ProfileViewModel() : ViewModel() {
UserServiceST.getInstance().logout()
}
fun resetVisits(){
visitListState = Pager(
config = PagingConfig(
pageSize = 20,
enablePlaceholders = false,
maxSize = 100
)
) {
VisitListPagingSource(VisitServiceST.getInstance()::getMyLastVisits)
}.flow
.cachedIn(viewModelScope)
}
fun getInfo() {
viewModelScope.launch {
UserServiceST.getInstance().getInfo().fold(