mirror of
https://github.com/discourse/discourse.git
synced 2024-12-04 11:13:41 +08:00
038e5deb2a
* `@ember/owner` instead of `@ember/application` * `discourse-i18n` instead of `I18n` * `{ service } from "@ember/service"` instead of `inject as service`
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"
|
|
);
|
|
}
|
|
}
|