text: 'use strict';
  
  angular.module('copayApp.controllers').controller('preferencesColorController',
    function($scope, configService, profileService, go) {
      var config = configService.getSync();
      this.colorOpts = configService.colorOpts;
  
      var fc = profileService.focusedClient;
      var walletId = fc.credentials.walletId;
  
      var config = configService.getSync();
      config.colorFor = config.colorFor || {};
      this.color = config.colorFor[walletId] || '#FADA58';
  
      this.save = function(color) {
        var self = this;
        var opts = {
          colorFor: {}
        };
        opts.colorFor[walletId] = color;
  
        configService.set(opts, function(err) {
          if (err) {
            $scope.$emit('Local/DeviceError', err);
            return;
          }
          self.color = color;
          $scope.$emit('Local/ColorUpdated');
        });
  
      };
    });
  