Sha256: 9cf9999bee007ec54cc69fa4247b8d741dc31735bbdde296b13bfb301276bf60

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

import ApplicationController from "signum/controllers/application_controller"

export default class extends ApplicationController {
  static values = { type: String, timeout: Number, sticky: Boolean, signalId: String, signalState: String }
  connect() {
    if (this.typeValue == "balloon" && !this.stickyValue) {
      this.timeoutId = setTimeout(() => {
        this.close()
      }, this.timeoutValue * 1000 + 500)
    }
  }

  close(event) {
    setTimeout(() => {
      this.element?.parentElement?.remove()
      if (event && this.typeValue != "balloon") {
        this.markClose()
      }
    }, 300)
  }

  markClose() {
    fetch("/signal/close", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ id: this.signalIdValue }),
    })
      .then((res) => {
        const niE = new CustomEvent("nd-item-activity", {
          bubbles: true,
          detail: "closed",
        })
        window.dispatchEvent(niE)
      })
      .catch((err) => {
        console.log(err)
      })
  }
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
signum-0.7.4 app/components/signum/notification_body/component_controller.js
signum-0.7.2 app/components/signum/notification_body/component_controller.js
signum-0.7.1 app/components/signum/notification_body/component_controller.js
signum-0.7.0 app/components/signum/notification_body/component_controller.js
signum-0.6.0 app/components/signum/notification_body/component_controller.js
signum-0.5.1 app/components/signum/notification_body/component_controller.js
signum-0.5.0 app/components/signum/notification_body/component_controller.js