Only load ignored inbox items in inbox view (#2400)

Depends on https://github.com/openhab/openhab-core/pull/4108.

In most places, the inbox content is loaded only to show a count of items in inbox.
For any decent size systems the inbox may contain hundreds of entries that are ignored,
which equates to lots of unnecessary data being transferred and processed in the browser.

---------

Signed-off-by: Arne Seime <arne.seime@gmail.com>
pull/2484/head
Arne Seime 2024-03-18 19:57:09 +01:00 committed by GitHub
parent 970afa0b58
commit f784419eb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 8 additions and 8 deletions

View File

@ -291,7 +291,7 @@ export default {
}, },
loadCounters () { loadCounters () {
if (!this.apiEndpoints) return if (!this.apiEndpoints) return
if (this.$store.getters.apiEndpoint('inbox')) this.$oh.api.get('/rest/inbox').then((data) => { this.inboxCount = data.filter((e) => e.flag === 'NEW').length.toString() }) if (this.$store.getters.apiEndpoint('inbox')) this.$oh.api.get('/rest/inbox?includeIgnored=false').then((data) => { this.inboxCount = data.filter((e) => e.flag === 'NEW').length.toString() })
if (this.$store.getters.apiEndpoint('things')) this.$oh.api.get('/rest/things?staticDataOnly=true').then((data) => { this.thingsCount = data.length.toString() }) if (this.$store.getters.apiEndpoint('things')) this.$oh.api.get('/rest/things?staticDataOnly=true').then((data) => { this.thingsCount = data.length.toString() })
if (this.$store.getters.apiEndpoint('items')) this.$oh.api.get('/rest/items?staticDataOnly=true').then((data) => { this.itemsCount = data.length.toString() }) if (this.$store.getters.apiEndpoint('items')) this.$oh.api.get('/rest/items?staticDataOnly=true').then((data) => { this.itemsCount = data.length.toString() })
if (this.$store.getters.apiEndpoint('ui')) this.$oh.api.get('/rest/ui/components/system:sitemap').then((data) => { this.sitemapsCount = data.length }) if (this.$store.getters.apiEndpoint('ui')) this.$oh.api.get('/rest/ui/components/system:sitemap').then((data) => { this.sitemapsCount = data.length })

View File

@ -37,7 +37,7 @@
:link="binding.id" :link="binding.id"
:title="binding.label" :title="binding.label"
:header="binding.uid" :header="binding.uid"
:badge="inbox.filter((e) => e.thingTypeUID.split(':')[0] === binding.id && e.flag !== 'IGNORED').length || undefined" :badge="inbox.filter((e) => e.thingTypeUID.split(':')[0] === binding.id).length || undefined"
badge-color="red" badge-color="red"
:footer="(binding.description && binding.description.indexOf('<br>') >= 0) ? :footer="(binding.description && binding.description.indexOf('<br>') >= 0) ?
binding.description.split('<br>')[0] : binding.description" /> binding.description.split('<br>')[0] : binding.description" />
@ -88,7 +88,7 @@ export default {
} }
}) })
}) })
this.$oh.api.get('/rest/inbox').then((data) => { this.$oh.api.get('/rest/inbox?includeIgnored=false').then((data) => {
this.inbox = data this.inbox = data
}) })
} }

View File

@ -156,9 +156,9 @@ export default {
loadInbox () { loadInbox () {
if (this.loading) return if (this.loading) return
this.loading = true this.loading = true
this.$oh.api.get('/rest/inbox').then((data) => { this.$oh.api.get('/rest/inbox?includeIgnored=false').then((data) => {
this.loading = false this.loading = false
this.scanResults = data.filter((e) => e.thingTypeUID.split(':')[0] === this.bindingId && e.flag !== 'IGNORED') this.scanResults = data.filter((e) => e.thingTypeUID.split(':')[0] === this.bindingId)
const searchbar = this.$refs.searchbar.$el.f7Searchbar const searchbar = this.$refs.searchbar.$el.f7Searchbar
const filterQuery = searchbar.query const filterQuery = searchbar.query
this.initSearchbar = false this.initSearchbar = false

View File

@ -187,7 +187,7 @@ export default {
methods: { methods: {
load () { load () {
this.loading = true this.loading = true
this.$oh.api.get('/rest/inbox').then((data) => { this.$oh.api.get('/rest/inbox?includeIgnored=true').then((data) => {
this.inbox = data.sort((a, b) => a.label.localeCompare(b.label)) this.inbox = data.sort((a, b) => a.label.localeCompare(b.label))
this.initSearchbar = true this.initSearchbar = true
this.loading = false this.loading = false

View File

@ -218,7 +218,7 @@ export default {
} }
}, },
inboxCount () { inboxCount () {
return this.inbox.filter((e) => e.flag !== 'IGNORED').length return this.inbox.length
}, },
searchPlaceholder () { searchPlaceholder () {
return window.innerWidth >= 1280 ? 'Search (for advanced search, use the developer sidebar (Shift+Alt+D))' : 'Search' return window.innerWidth >= 1280 ? 'Search (for advanced search, use the developer sidebar (Shift+Alt+D))' : 'Search'
@ -244,7 +244,7 @@ export default {
this.loadInbox() this.loadInbox()
}, },
loadInbox () { loadInbox () {
this.$oh.api.get('/rest/inbox').then((data) => { this.$oh.api.get('/rest/inbox?includeIgnored=false').then((data) => {
this.inbox = data this.inbox = data
}) })
}, },