Просмотр исходного кода

Allow clearing remote copy of options in sync storage. Fix #282.

FelisCatus 10 лет назад
Родитель
Сommit
dab98bb943

+ 3 - 0
omega-locales/cs/LC_MESSAGES/omega-web.po

@@ -381,6 +381,9 @@ msgstr "Stáhnout ze synchronizace"
 msgid "options_syncDisable"
 msgstr "Zrušit synchronizaci"
 
+msgid "options_syncReset"
+msgstr "Clear remote copy"
+
 msgid "options_syncPristineHelp"
 msgstr ""
 "Vy můžete nyní automaticky synchronizovat Vaše nastavení, profily napříč "

+ 3 - 0
omega-locales/en_US/LC_MESSAGES/omega-web.po

@@ -373,6 +373,9 @@ msgstr "Download from Syncing"
 msgid "options_syncDisable"
 msgstr "Disable syncing"
 
+msgid "options_syncReset"
+msgstr "Clear remote copy"
+
 msgid "options_syncPristineHelp"
 msgstr ""
 "You can now automatically synchroize your settings and profiles across all "

+ 3 - 0
omega-locales/es_AR/LC_MESSAGES/omega-web.po

@@ -381,6 +381,9 @@ msgstr "Download from Syncing"
 msgid "options_syncDisable"
 msgstr "Disable syncing"
 
+msgid "options_syncReset"
+msgstr "Clear remote copy"
+
 msgid "options_syncPristineHelp"
 msgstr ""
 "You can now automatically synchroize your settings and profiles across all "

+ 3 - 0
omega-locales/ja/LC_MESSAGES/omega-web.po

@@ -374,6 +374,9 @@ msgstr "Download from Syncing"
 msgid "options_syncDisable"
 msgstr "Disable syncing"
 
+msgid "options_syncReset"
+msgstr "Clear remote copy"
+
 msgid "options_syncPristineHelp"
 msgstr ""
 "You can now automatically synchroize your settings and profiles across all "

+ 3 - 0
omega-locales/tr/LC_MESSAGES/omega-web.po

@@ -380,6 +380,9 @@ msgstr "Download from Syncing"
 msgid "options_syncDisable"
 msgstr "Disable syncing"
 
+msgid "options_syncReset"
+msgstr "Clear remote copy"
+
 msgid "options_syncPristineHelp"
 msgstr ""
 "You can now automatically synchroize your settings and profiles across all "

+ 3 - 0
omega-locales/zh_CN/LC_MESSAGES/omega-web.po

@@ -341,6 +341,9 @@ msgstr "下载云端版本"
 msgid "options_syncDisable"
 msgstr "禁用同步"
 
+msgid "options_syncReset"
+msgstr "删除云端版本"
+
 msgid "options_syncPristineHelp"
 msgstr "您可以将设置和情景模式同步到所有使用Chrome浏览器的桌面设备。"
 

+ 3 - 0
omega-locales/zh_TW/LC_MESSAGES/omega-web.po

@@ -341,6 +341,9 @@ msgstr "下載雲端版本"
 msgid "options_syncDisable"
 msgstr "禁用同步"
 
+msgid "options_syncReset"
+msgstr "刪除雲端版本"
+
 msgid "options_syncPristineHelp"
 msgstr "您可以將設定和情景模式同步到所有使用Chrome瀏覽器的桌面裝置。"
 

+ 1 - 0
omega-target-chromium-extension/omega_target_web.coffee

@@ -140,6 +140,7 @@ angular.module('omegaTarget', []).factory 'omegaTarget', ($q) ->
       chrome.tabs.create url: 'chrome://extensions/configureCommands'
     setOptionsSync: (enabled, args) ->
       callBackground('setOptionsSync', enabled, args)
+    resetOptionsSync: (enabled, args) -> callBackground('resetOptionsSync')
     setRequestInfoCallback: (callback) ->
       requestInfoCallback = callback
 

+ 16 - 0
omega-target/src/options.coffee

@@ -985,4 +985,20 @@ class Options
           @_syncWatchStop = @sync.watchAndPull(@_storage)
           return
 
+  ###*
+  # Clear the sync storage, resetting syncing state to pristine.
+  # @returns {Promise} A promise which is fulfilled when the syncing is reset.
+  ###
+  resetOptionsSync: ->
+    @log.method('Options#resetOptionsSync', this, arguments)
+    if not @sync?
+      return Promise.reject(new Error('Options syncing is unsupported.'))
+    @sync.enabled = false
+    @_syncWatchStop?()
+    @_syncWatchStop = null
+    @_state.set({'syncOptions': 'conflict'})
+
+    return @sync.storage.remove().then =>
+      @_state.set({'syncOptions': 'pristine'})
+
 module.exports = Options

+ 5 - 0
omega-web/src/omega/controllers/io.coffee

@@ -60,3 +60,8 @@ angular.module('omega').controller 'IoCtrl', ($scope, $rootScope,
     omegaTarget.setOptionsSync(false).then ->
       $rootScope.applyOptionsConfirm().then ->
         $window.location.reload()
+
+  $scope.resetOptionsSync = ->
+    omegaTarget.resetOptionsSync().then ->
+      $rootScope.applyOptionsConfirm().then ->
+        $window.location.reload()

+ 5 - 0
omega-web/src/partials/io.jade

@@ -66,5 +66,10 @@ section.settings-group
         span.glyphicon.glyphicon-cloud-download
         = ' '
         | {{'options_syncEnableForce' | tr}}
+      = ' '
+      button.btn.btn-link(ng-click='resetOptionsSync()')
+        span.glyphicon.glyphicon-erase
+        = ' '
+        | {{'options_syncReset' | tr}}
   div(ng-show='syncOptions == "unsupported"')
     p.help-block(omega-html='"options_syncUnsupportedHelp" | tr')