fixed visits update
This commit is contained in:
parent
e13035320d
commit
a40c448fc2
@ -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)
|
||||
}
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user