mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-27 02:23:28 +08:00
fix(config): removeAtKeyPath => undo, guard with assertions
This commit is contained in:
parent
48556bef98
commit
3fdffb4b81
2 changed files with 7 additions and 1 deletions
|
@ -111,7 +111,7 @@ class NylasLongConnection
|
|||
res.on 'data', (chunk) =>
|
||||
if chunk.toString().indexOf('Invalid cursor') > 0
|
||||
error = new Error('Delta Connection: Cursor is invalid. Need to blow away local cache.')
|
||||
NylasEnv.config.removeAtKeyPath("nylas.#{@_accountId}.cursor")
|
||||
NylasEnv.config.unset("nylas.#{@_accountId}.cursor")
|
||||
DatabaseStore._handleSetupError(error)
|
||||
@close()
|
||||
return
|
||||
|
|
|
@ -485,18 +485,24 @@ class Config
|
|||
|
||||
pushAtKeyPath: (keyPath, value) ->
|
||||
arrayValue = @get(keyPath) ? []
|
||||
unless arrayValue instanceof Array
|
||||
throw new Error("Config.pushAtKeyPath is intended for array values. Value #{JSON.stringify(arrayValue)} is not an array.")
|
||||
result = arrayValue.push(value)
|
||||
@set(keyPath, arrayValue)
|
||||
result
|
||||
|
||||
unshiftAtKeyPath: (keyPath, value) ->
|
||||
arrayValue = @get(keyPath) ? []
|
||||
unless arrayValue instanceof Array
|
||||
throw new Error("Config.unshiftAtKeyPath is intended for array values. Value #{JSON.stringify(arrayValue)} is not an array.")
|
||||
result = arrayValue.unshift(value)
|
||||
@set(keyPath, arrayValue)
|
||||
result
|
||||
|
||||
removeAtKeyPath: (keyPath, value) ->
|
||||
arrayValue = @get(keyPath) ? []
|
||||
unless arrayValue instanceof Array
|
||||
throw new Error("Config.removeAtKeyPath is intended for array values. Value #{JSON.stringify(arrayValue)} is not an array.")
|
||||
result = _.remove(arrayValue, value)
|
||||
@set(keyPath, arrayValue)
|
||||
result
|
||||
|
|
Loading…
Reference in a new issue