The frontend/UI server, written in JS using the MarkoJS library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
657 B

  1. module.exports = class {
  2. onCreate(input) {
  3. this.state = {
  4. channels: input.channels,
  5. modal: null,
  6. }
  7. }
  8. open(modal) {
  9. this.state.modal = modal
  10. }
  11. close() {
  12. this.state.modal = null
  13. }
  14. channelEdited(channel, patch) {
  15. const channels = this.state.channels.slice()
  16. const index = channels.findIndex(c => c.name === channel.name)
  17. if (index === -1) {
  18. return
  19. }
  20. channels[index] = Object.assign({}, channels[index], patch)
  21. this.state.channels = channels
  22. }
  23. channelAdded(channel) {
  24. this.state.channels = this.state.channels.concat(channel).sort((a,b) => a.name.localeCompare(b.name))
  25. }
  26. }