30 lines
645 B
JavaScript
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"
|
|
);
|
|
}
|
|
}
|