Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions addon/services/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import Service from '@ember/service';
import { A } from '@ember/array';
import EmberObject, { set } from '@ember/object';
import { later, cancel } from '@ember/runloop';
import config from 'ember-get-config';
import { getOwner } from '@ember/application';

const globals = config['ember-cli-notifications'] || {}; // Import app config object
function getGlobalConfig(instance) {
const config = getOwner(instance).resolveRegistration('config:environment');
return config['ember-cli-notifications'] || {}; // Import app config object
}

export default class NotificationsService extends Service {
content = A();
Expand All @@ -16,6 +19,7 @@ export default class NotificationsService extends Service {
if (!options.message) {
throw new Error('No notification message set');
}
const globals = getGlobalConfig(this);

const notification = EmberObject.create({
message: options.message,
Expand Down Expand Up @@ -123,10 +127,12 @@ export default class NotificationsService extends Service {
}

setDefaultAutoClear(autoClear) {
const globals = getGlobalConfig(this);
set(globals, 'autoClear', autoClear);
}

setDefaultClearDuration(clearDuration) {
const globals = getGlobalConfig(this);
set(globals, 'clearDuration', clearDuration);
}
}
Loading