Skip to content

Commit eb9d9aa

Browse files
Fix issues with data processors applying to invalid object types
1 parent 1480f51 commit eb9d9aa

File tree

5 files changed

+31
-14
lines changed

5 files changed

+31
-14
lines changed

Lib/Launchpad/Entity/LauncherEntity.ahk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ class LauncherEntity extends EntityBase {
311311
}
312312

313313
InitializeDefaults() {
314-
315314
defaults := super.InitializeDefaults()
316315
defaults.Delete("DataSourceItemKey")
317316
defaults["DestinationDir"] := this.GetDefaultDestinationDir()

Lib/Shared/AppLib/Entity/EntityBase.ahk

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,12 @@ class EntityBase {
9595
InvalidParameterException.CheckEmpty("EntityBase", "key", key)
9696

9797
sanitizer := StringSanitizer()
98-
9998
this.app := app
10099
this.keyVal := sanitizer.Process(key)
101100
this.configObj := configObj
102101
this.parentEntity := parentEntity
103-
104-
this.entityData := LayeredEntityData(configObj.Clone(), this.InitializeDefaults())
102+
defaults := this.InitializeDefaults()
103+
this.entityData := LayeredEntityData(configObj.Clone(), defaults)
105104
this.entityData.SetDataSourceDefaults(this.AggregateDataSourceDefaults())
106105
this.entityData.SetAutoDetectedDefaults(this.AutoDetectValues())
107106
this.entityData.StoreOriginal()
@@ -136,13 +135,13 @@ class EntityBase {
136135

137136
; NOTICE: Object not yet fully loaded. Might not be safe to call this.entityData
138137
InitializeDefaults() {
139-
defaults := Map()
140-
defaults["DataSourceKeys"] := ["api"]
141-
defaults["DataSourceItemKey"] := ""
142-
defaults["DisplayName"] := this.keyVal
143-
defaults["AssetsDir"] := this.app.Config.AssetsDir . "\" . this.keyVal
144-
defaults["DependenciesDir"] := this.app.appDir . "\Vendor"
145-
return defaults
138+
return Map(
139+
"DataSourceKeys", ["api"],
140+
"DataSourceItemKey", "",
141+
"DisplayName", this.keyVal,
142+
"AssetsDir", this.app.Config.AssetsDir . "\" . this.keyVal,
143+
"DependenciesDir", this.app.appDir . "\Vendor"
144+
)
146145
}
147146

148147
AggregateDataSourceDefaults(includeParentData := true, includeChildData := true) {
@@ -187,7 +186,7 @@ class EntityBase {
187186
itemKey := this.GetDataSourceItemKey()
188187

189188
if (itemKey) {
190-
dsData := dataSource.ReadJson(this.GetDataSourceItemKey(), this.GetDataSourceItemPath())
189+
dsData := dataSource.ReadJson(itemKey, this.GetDataSourceItemPath())
191190

192191
if (dsData) {
193192
this.existsInDataSource := true
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
class DataProcessorBase {
22
Process(value) {
3+
if (this.AppliesTo(value)) {
4+
if (Type(value) == "String") {
5+
value := this.ProcessSingleValue(value)
6+
} else if (Type(value) == "Array" || Type(value) == "Map") {
7+
for key, arrayVal in value {
8+
value[key] := this.Process(arrayVal)
9+
}
10+
}
11+
}
12+
13+
return value
14+
}
15+
16+
ProcessSingleValue(value) {
317
throw MethodNotImplementedException("DataProcessorBase", "Process")
418
}
19+
20+
AppliesTo(value) {
21+
objType := Type(value)
22+
return (objType == "String" || objType == "Map" || objType == "Array")
23+
}
524
}

Lib/Shared/DataLib/DataProcessor/PlaceholderExpander.ahk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class PlaceholderExpander extends DataProcessorBase {
55
this.layeredData := layeredData
66
}
77

8-
Process(value) {
8+
ProcessSingleValue(value) {
99
mergedData := this.layeredData.GetMergedData(false)
1010

1111
for key, varVal in mergedData {

Lib/Shared/DataLib/DataProcessor/StringSanitizer.ahk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class StringSanitizer extends DataProcessorBase {
77
}
88
}
99

10-
Process(value) {
10+
ProcessSingleValue(value) {
1111
return RegExReplace(value, "[^\000-\377]")
1212
}
1313
}

0 commit comments

Comments
 (0)