'use strict';

var angular = require('angular');
require('./modules');
require('../notice/services/NoticeService');
require('./services/huaweiPermissionSetService');
var module = angular.module('setting');

module.run(function(AppConfig, $timeout, NoticeService, LinkerService, CacheService, huaweiPermissionSetService) {
	AppConfig.addSetItem({
		text: '版本更新',
		state: 'setting-version',
		order: 1
	}, {
		text: '关于我们',
		state: 'setting-aboutus',
		order: 4
	}, {
    text: '缓存设置',
    state: 'setting-filecache',
    order: 7
  }, {
    text: '辅助功能',
    state: 'setting_assist',
    order: 8
  });

  $timeout(function() {
    var noticeOrder = CacheService.get(LinkerService.currentUserId);
    var moduleNames = AppConfig.getModuleNames();
    if(noticeOrder === 'noticeOrder_module') {
      NoticeService.appNotices.orderNotices(moduleNames);
    } else {
      NoticeService.appNotices.orderNotices();
    }

  }, 300);

  if(window.device.manufacturer === 'HUAWEI') {
    AppConfig.addSetItem({
      text: '华为权限设置',
      state: function () {
        return huaweiPermissionSetService.goToHuaweiPermissionSet();
      },
      order: 10
    });
  }
});
