mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-03-13 08:28:13 -04:00
Remove duplicate profile names in quickSwitchProfiles. Fix #1232.
This commit is contained in:
parent
e432687831
commit
52fdd252d2
@ -374,7 +374,9 @@ class Options
|
|||||||
@_setOptions({'-showExternalProfile': true}, {persist: true})
|
@_setOptions({'-showExternalProfile': true}, {persist: true})
|
||||||
@_state.set({'showExternalProfile': showExternal})
|
@_state.set({'showExternalProfile': showExternal})
|
||||||
|
|
||||||
if changes['-enableQuickSwitch']? or changes['-quickSwitchProfiles']?
|
quickSwitchProfiles = changes['-quickSwitchProfiles']
|
||||||
|
quickSwitchProfiles = @_cleanUpQuickSwitchProfiles(quickSwitchProfiles)
|
||||||
|
if changes['-enableQuickSwitch']? or quickSwitchProfiles?
|
||||||
@reloadQuickSwitch()
|
@reloadQuickSwitch()
|
||||||
if changes['-downloadInterval']?
|
if changes['-downloadInterval']?
|
||||||
@schedule 'updateProfile', @_options['-downloadInterval'], =>
|
@schedule 'updateProfile', @_options['-downloadInterval'], =>
|
||||||
@ -395,6 +397,20 @@ class Options
|
|||||||
handler()
|
handler()
|
||||||
@_storage.watch null, handler
|
@_storage.watch null, handler
|
||||||
|
|
||||||
|
_cleanUpQuickSwitchProfiles: (quickSwitchProfiles) ->
|
||||||
|
return unless quickSwitchProfiles?
|
||||||
|
seenQuickSwitchProfile = {}
|
||||||
|
validQuickSwitchProfiles = quickSwitchProfiles.filter (name) =>
|
||||||
|
key = OmegaPac.Profiles.nameAsKey(name)
|
||||||
|
return false if seenQuickSwitchProfile[key]
|
||||||
|
return false if not OmegaPac.Profiles.byName(name, @_options)
|
||||||
|
seenQuickSwitchProfile[key] = true
|
||||||
|
return true
|
||||||
|
if validQuickSwitchProfiles.length != quickSwitchProfiles.length
|
||||||
|
@_setOptions(
|
||||||
|
{'-quickSwitchProfiles': validQuickSwitchProfiles}, {persist: true})
|
||||||
|
return validQuickSwitchProfiles
|
||||||
|
|
||||||
###*
|
###*
|
||||||
# Reload the quick switch according to settings.
|
# Reload the quick switch according to settings.
|
||||||
# @returns {Promise} A promise which is fulfilled when the quick switch is set
|
# @returns {Promise} A promise which is fulfilled when the quick switch is set
|
||||||
@ -695,6 +711,9 @@ class Options
|
|||||||
if @_options['-startupProfileName'] == fromName
|
if @_options['-startupProfileName'] == fromName
|
||||||
changes['-startupProfileName'] = toName
|
changes['-startupProfileName'] = toName
|
||||||
quickSwitch = @_options['-quickSwitchProfiles']
|
quickSwitch = @_options['-quickSwitchProfiles']
|
||||||
|
# Change fromName to toName in Quick Switch, but only if it does not contain
|
||||||
|
# toName already. Otherwise it may cause duplicates.
|
||||||
|
if quickSwitch.indexOf(toName) < 0
|
||||||
for i in [0...quickSwitch.length]
|
for i in [0...quickSwitch.length]
|
||||||
if quickSwitch[i] == fromName
|
if quickSwitch[i] == fromName
|
||||||
quickSwitch[i] = toName
|
quickSwitch[i] = toName
|
||||||
|
Loading…
Reference in New Issue
Block a user