import Ember from 'ember';

export default Ember.Controller.extend({
  init () {
    Ember.run.schedule('afterRender', () => {
      componentHandler.upgradeAllRegistered();
    });
  },

  settingsSnackbar (message) {
    const _this = this;
    const snackbarContainer = document.querySelector('#snackbar-container');

    const handler = function () {
      _this.transitionToRoute('home');
      Ember.run.later(() => {
        window.location.reload(true);
      }, 500);
    };

    const data = {
      message,
      timeout: 4000,
      actionHandler: handler,
      actionText: 'Reload'
    };
    snackbarContainer.MaterialSnackbar.showSnackbar(data);
  },
  currency: function () {
    let currency = this.get('model').findBy('id', 'currency');
    if (!currency) {
      return {
        id: false,
        setting: 'Currency',
        value: '£'
      };
    }
    return currency;
  }.property('model.@each.value'),

  userName: function () {
    let userName = this.get('model').findBy('id', 'user-name');

    if (!userName) {
      return {
        id: false,
        setting: 'Name',
        value: 'Guest'
      };
    }
    return userName;
  }.property('model.@each.value')
});

@@ -746,24 +746,25 @@
 currency');%0A
+%0A
     if (!cur
@@ -792,32 +792,62 @@
  %7B%0A        i
-d: false
+sDefault: true,%0A        id: 'currency'
 ,%0A        se
@@ -885,9 +885,9 @@
 e: '
-%C2%A3
+$
 '%0A  
@@ -939,28 +939,16 @@
 y('model
-.@each.value
 '),%0A%0A  u
@@ -1063,32 +1063,57 @@
 %0A      return %7B%0A
+        isDefault: true,%0A
         id: fals
@@ -1112,13 +1112,19 @@
 id: 
-false
+'user-name'
 ,%0A  
@@ -1228,22 +1228,12 @@
 odel
-.@each.value
 ')
+,%0A
 %0A%7D);

Add isDefault property for each setting