TT#129653 Conversations - List filtering is corrupted after performing an action on single item

Change-Id: Ife12c45065bd170ef0824d5bd04dc52a0cd84301
mr10.0
Sergii Leonenko 4 years ago
parent 334997907c
commit 611d34e07c

@ -43,12 +43,6 @@
<div <div
class="row justify-center" class="row justify-center"
> >
<div
v-if="listLoading"
class="col-xs-12 col-md-8"
>
<csc-list-spinner />
</div>
<q-list <q-list
v-if="items.length > 0" v-if="items.length > 0"
class="col-xs-12 col-md-8" class="col-xs-12 col-md-8"
@ -66,9 +60,9 @@
@download-fax="downloadFax" @download-fax="downloadFax"
@download-voice-mail="downloadVoiceMail" @download-voice-mail="downloadVoiceMail"
@play-voice-mail="playVoiceMail" @play-voice-mail="playVoiceMail"
@toggle-block-incoming="toggleBlockIncoming" @toggle-block-incoming="toggleBlockIncomingAction"
@toggle-block-outgoing="toggleBlockOutgoing" @toggle-block-outgoing="toggleBlockOutgoingAction"
@toggle-block-both="toggleBlockBoth" @toggle-block-both="toggleBlockBothAction"
@delete-voicemail="$refs.confirmDeletionDialog.open();deletionId=$event.id" @delete-voicemail="$refs.confirmDeletionDialog.open();deletionId=$event.id"
/> />
</q-list> </q-list>
@ -79,14 +73,11 @@
{{ noResultsMessage }} {{ noResultsMessage }}
</div> </div>
<div <div
v-if="listLoading && items.length > 0" v-if="listLoading"
class="col-xs-12 col-md-8" class="col-xs-12 col-md-8"
> >
<csc-list-spinner /> <csc-list-spinner />
</div> </div>
<q-page-scroller
color="primary"
/>
</div> </div>
</q-infinite-scroll> </q-infinite-scroll>
<csc-remove-dialog <csc-remove-dialog
@ -104,8 +95,7 @@
<script> <script>
import platformMixin from 'src/mixins/platform' import platformMixin from 'src/mixins/platform'
import { import {
mapGetters, mapGetters, mapMutations,
mapActions,
mapState mapState
} from 'vuex' } from 'vuex'
import CscPageStickyTabs from 'components/CscPageStickyTabs' import CscPageStickyTabs from 'components/CscPageStickyTabs'
@ -113,6 +103,7 @@ import CscListSpinner from 'components/CscListSpinner'
import CscConversationItem from 'components/pages/Conversations/CscConversationItem' import CscConversationItem from 'components/pages/Conversations/CscConversationItem'
import CscConversationsFilter from 'components/pages/Conversations/CscConversationsFilter' import CscConversationsFilter from 'components/pages/Conversations/CscConversationsFilter'
import CscRemoveDialog from 'components/CscRemoveDialog' import CscRemoveDialog from 'components/CscRemoveDialog'
import { mapWaitingActions } from 'vue-wait'
export default { export default {
name: 'CscConversations', name: 'CscConversations',
components: { components: {
@ -169,20 +160,10 @@ export default {
]), ]),
...mapGetters('conversations', [ ...mapGetters('conversations', [
'items', 'items',
'isNextPageRequesting',
'downloadFaxState',
'downloadVoiceMailState',
'downloadFaxError',
'downloadVoiceMailError',
'itemsReloaded',
'reloadItemsError',
'toggleBlockedState',
'lastToggledType',
'isNumberIncomingBlocked', 'isNumberIncomingBlocked',
'isNumberOutgoingBlocked' 'isNumberOutgoingBlocked'
]), ]),
...mapGetters('call', [ ...mapGetters('call', [
'callState',
'isCallEnabled' 'isCallEnabled'
]), ]),
pageStyle () { pageStyle () {
@ -237,21 +218,27 @@ export default {
}, },
async mounted () { async mounted () {
this.topMargin = this.$refs.pageSticky.$el.offsetHeight this.topMargin = this.$refs.pageSticky.$el.offsetHeight
this.$store.commit('conversations/resetList') this.resetList()
await this.$store.dispatch('conversations/getBlockedNumbers') await this.$store.dispatch('conversations/getBlockedNumbers')
this.$refs.infiniteScroll.poll() this.$refs.infiniteScroll.poll()
}, },
methods: { methods: {
...mapActions('conversations', [ ...mapWaitingActions('conversations', {
'deleteVoicemail' nextPage: 'csc-conversations',
deleteVoicemail: 'csc-conversations',
toggleBlockIncoming: 'csc-conversations',
toggleBlockOutgoing: 'csc-conversations',
toggleBlockBoth: 'csc-conversations'
}),
...mapMutations('conversations', [
'resetList'
]), ]),
loadNextPage (index, done) { async loadNextPage (index, done) {
let type = this.selectedTab let type = this.selectedTab
if (this.selectedTab === 'call-fax-voicemail') { if (this.selectedTab === 'call-fax-voicemail') {
type = null type = null
} }
this.startLoader() await this.nextPage({
this.$store.dispatch('conversations/nextPage', {
type: type, type: type,
index: index, index: index,
filter: this.filter, filter: this.filter,
@ -267,8 +254,10 @@ export default {
}, },
forceTabReload (tabName) { forceTabReload (tabName) {
this.selectedTab = tabName this.selectedTab = tabName
this.startLoader() // Note: we have to set loading mark manually as a workaround that we cannot force infinitScroll to load data immediately
this.$store.commit('conversations/resetList') this.$wait.start('csc-conversations')
this.resetList()
this.$refs.infiniteScroll.reset() this.$refs.infiniteScroll.reset()
if (this.reachedLastPage) { if (this.reachedLastPage) {
this.$refs.infiniteScroll.resume() this.$refs.infiniteScroll.resume()
@ -299,33 +288,37 @@ export default {
format: voiceMail.format format: voiceMail.format
}) })
}, },
toggleBlockIncoming (options) { async toggleBlockIncomingAction (options) {
this.startLoader() this.resetList()
this.$store.commit('conversations/resetList') try {
this.$store.dispatch('conversations/toggleBlockIncoming', options).finally(() => { await this.toggleBlockIncoming(options)
} finally {
this.forceReload() this.forceReload()
}) }
}, },
toggleBlockOutgoing (options) { async toggleBlockOutgoingAction (options) {
this.startLoader() this.resetList()
this.$store.commit('conversations/resetList') try {
this.$store.dispatch('conversations/toggleBlockOutgoing', options).finally(() => { await this.toggleBlockOutgoing(options)
} finally {
this.forceReload() this.forceReload()
}) }
}, },
toggleBlockBoth (options) { async toggleBlockBothAction (options) {
this.startLoader() this.resetList()
this.$store.commit('conversations/resetList') try {
this.$store.dispatch('conversations/toggleBlockBoth', options).finally(() => { await this.toggleBlockBoth(options)
} finally {
this.forceReload() this.forceReload()
}) }
}, },
deleteVoicemailConfirmed (payload) { async deleteVoicemailConfirmed (payload) {
this.startLoader() this.resetList()
this.$store.commit('conversations/resetList') try {
this.deleteVoicemail(payload).finally(() => { await this.deleteVoicemail(payload)
} finally {
this.forceReload() this.forceReload()
}) }
}, },
blockedIncoming (item) { blockedIncoming (item) {
if (item.direction === 'out') { if (item.direction === 'out') {
@ -340,9 +333,6 @@ export default {
} else { } else {
return this.isNumberOutgoingBlocked(item.caller) return this.isNumberOutgoingBlocked(item.caller)
} }
},
startLoader () {
this.$wait.start('csc-conversations')
} }
} }
} }

@ -16,7 +16,7 @@ import {
toggleNumberInBothLists toggleNumberInBothLists
} from 'src/api/call-blocking' } from 'src/api/call-blocking'
const ROWS_PER_PAGE = 15 export const ROWS_PER_PAGE = 15
const ReloadConfig = { const ReloadConfig = {
retryLimit: 5, retryLimit: 5,
@ -96,12 +96,12 @@ export default {
} catch (err) { } catch (err) {
context.commit('nextPageFailed', err.message) context.commit('nextPageFailed', err.message)
} finally { } finally {
if (options.done !== undefined && (res === undefined || res.items === undefined)) { if (typeof options.done === 'function') {
options.done(true) if (res?.items === undefined || res?.items?.length === 0 || res?.items?.length < ROWS_PER_PAGE) {
} else if (options.done !== undefined && res.items && res.items.length === 0) { options.done(true)
options.done(true) } else {
} else if (options.done !== undefined) { options.done()
options.done() }
} }
} }
}, },

@ -2,6 +2,7 @@ import Vue from 'vue'
import { import {
RequestState RequestState
} from '../common' } from '../common'
import { ROWS_PER_PAGE } from './actions'
function linkCallsWithSameId (state) { function linkCallsWithSameId (state) {
let callId = null let callId = null
@ -86,7 +87,7 @@ export default {
state.nextPageState = RequestState.succeeded state.nextPageState = RequestState.succeeded
state.nextPageError = null state.nextPageError = null
state.items = state.items.concat(res.items) state.items = state.items.concat(res.items)
state.reachedLastPage = res.items.length === 0 state.reachedLastPage = res.items.length === 0 || res.items.length < ROWS_PER_PAGE
}, },
nextPageFailed (state, error) { nextPageFailed (state, error) {
state.nextPageState = RequestState.failed state.nextPageState = RequestState.failed

Loading…
Cancel
Save