Add showEmpty option for NextcloudUserStatus widget

When a user status doesn't include a status message, it still
may have a status emoji and it always has a status indicator
(e.g. online). When {showEmpty=true} then statuses without
a message are shown, otherwise hidden. Defaults to {false}.
This commit is contained in:
Marcell Fülöp 2022-06-19 13:39:23 +00:00
parent 821af62426
commit e76f552830
1 changed files with 5 additions and 1 deletions

View File

@ -74,6 +74,9 @@ export default {
if (this.options.users.length > 100) return this.options.users.slice(0, 100);
return this.options.users;
},
showEmpty() {
return !!this.options.showEmpty;
},
},
data() {
return {
@ -119,6 +122,7 @@ export default {
const newStatuses = {};
Object.values(statuses).forEach((status) => {
if (!this.users.includes(status.userId)) return;
if (!status.message && !this.showEmpty) return;
newStatuses[status.userId] = status;
});
this.statuses = newStatuses;
@ -126,7 +130,7 @@ export default {
processStatus(response) {
const raw = this.validateResponse(response);
const status = Array.isArray(raw) && raw.length ? raw[0] : raw;
if (status) {
if (status && (status.message || this.showEmpty)) {
this.newStatuses[status.userId] = status;
}
},