File tree Expand file tree Collapse file tree 1 file changed +17
-12
lines changed
OneSignalSDK/onesignal/core/src/main/java/com/onesignal/common/modeling Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -122,21 +122,26 @@ open class Model(
122122 * @param model The model to initialize this model from.
123123 */
124124 fun initializeFromModel (id : String? , model : Model ) {
125- synchronized(initializationLock) {
126- for (item in model.data) {
127- if (item.value is Model ) {
128- val childModel = item.value as Model
129- childModel._parentModel = this
130- data[item.key] = childModel
131- } else {
132- data[item.key] = item.value
133- }
134- }
125+ val newData = Collections .synchronizedMap(mutableMapOf<String , Any ?>())
135126
136- if (id != null ) {
137- data[::id.name] = id
127+ for (item in model.data) {
128+ if (item.value is Model ) {
129+ val childModel = item.value as Model
130+ childModel._parentModel = this
131+ newData[item.key] = childModel
132+ } else {
133+ newData[item.key] = item.value
138134 }
139135 }
136+
137+ if (id != null ) {
138+ newData[::id.name] = id
139+ }
140+
141+ synchronized(initializationLock) {
142+ data.clear()
143+ data.putAll(newData)
144+ }
140145 }
141146
142147 /* *
You can’t perform that action at this time.
0 commit comments