xmpp.chapril.org-conversejs/src/plugins/chatboxviews/container.js
JC Brand 1949356ede Work on turning chat views into custom elements
The eventual goal is to avoid UI-related stanza processing if the relevant chats
aren't in the DOM.

With the current architecture, chatboxes are created (and the stanzas
related to them processed) even if `#conversejs` isn't in the DOM.

* Initial work on making controlbox an element
* Create a shared base class
* Ceate ChatBoxViews proxy
* Update sass now that certain classes are moved to converse-chats element
2021-02-09 15:48:21 +01:00

46 lines
769 B
JavaScript

class ChatBoxViews {
constructor () {
this.views = {};
}
add (key, val) {
this.views[key] = val;
}
get (key) {
return this.views[key];
}
getAll () {
return Object.values(this.views);
}
keys () {
return Object.keys(this.views);
}
remove (key) {
delete this.views[key];
}
map (f) {
return Object.values(this.views).map(f);
}
forEach (f) {
return Object.values(this.views).forEach(f);
}
filter (f) {
return Object.values(this.views).filter(f);
}
closeAllChatBoxes () {
return Promise.all(Object.values(this.views).map(v => v.close({ 'name': 'closeAllChatBoxes' })));
}
}
export default ChatBoxViews;