discourse/app/assets/javascripts/float-kit/addon/lib/d-toast-instance.js
Jarek Radosz 038e5deb2a
DEV: Clean up imports (#28060)
* `@ember/owner` instead of `@ember/application`
* `discourse-i18n` instead of `I18n`
* `{ service } from "@ember/service"` instead of `inject as service`
2024-07-25 15:09:06 +02:00

30 lines
645 B
JavaScript

import { action } from "@ember/object";
import { setOwner } from "@ember/owner";
import { service } from "@ember/service";
import uniqueId from "discourse/helpers/unique-id";
import { TOAST } from "float-kit/lib/constants";
export default class DToastInstance {
@service site;
@service toasts;
options = null;
id = uniqueId();
constructor(owner, options = {}) {
setOwner(this, owner);
this.options = { ...TOAST.options, ...options };
}
@action
close() {
this.toasts.close(this);
}
get isValidForView() {
return this.options.views.includes(
this.site.desktopView ? "desktop" : "mobile"
);
}
}