Skip to content

Commit

Permalink
Merge pull request #364 from 1024pix/remove-ember-get-config
Browse files Browse the repository at this point in the history
Stop using `ember-get-config`
  • Loading branch information
mansona authored Nov 24, 2023
2 parents efe41af + 257c681 commit 97cd416
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 466 deletions.
21 changes: 14 additions & 7 deletions addon/services/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ 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';

const globals = config['ember-cli-notifications'] || {}; // Import app config object
import { getOwner } from '@ember/application';

export default class NotificationsService extends Service {
content = A();

constructor(...args) {
super(...args);

const config = getOwner(this).resolveRegistration('config:environment');

this.globals = config['ember-cli-notifications'] || {}; // Import app config object
}

// Method for adding a notification
addNotification(options) {
// If no message is set, throw an error
Expand All @@ -20,8 +26,9 @@ export default class NotificationsService extends Service {
const notification = EmberObject.create({
message: options.message,
type: options.type || 'info',
autoClear: options.autoClear ?? globals.autoClear ?? false,
clearDuration: options.clearDuration ?? globals.clearDuration ?? 3200,
autoClear: options.autoClear ?? this.globals.autoClear ?? false,
clearDuration:
options.clearDuration ?? this.globals.clearDuration ?? 3200,
onClick: options.onClick,
htmlContent: options.htmlContent || false,
cssClasses: options.cssClasses,
Expand Down Expand Up @@ -123,10 +130,10 @@ export default class NotificationsService extends Service {
}

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

setDefaultClearDuration(clearDuration) {
set(globals, 'clearDuration', clearDuration);
this.globals.clearDuration = clearDuration;
}
}
1 change: 0 additions & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module.exports = function (defaults) {

const { maybeEmbroider } = require('@embroider/test-setup');
return maybeEmbroider(app, {
compatAdapters: new Map([['ember-get-config', null]]),
// Needed for IE11 https://github.com/embroider-build/embroider/issues/731
skipBabel: [
{
Expand Down
Loading

0 comments on commit 97cd416

Please sign in to comment.