mirror of
https://github.com/mattermost/focalboard.git
synced 2024-11-27 08:31:20 +02:00
Thanks. Merging as the CI failure is not related to this change.
This commit is contained in:
parent
62672cb231
commit
e82305de56
@ -223,7 +223,8 @@ func (p *BoardPatch) Patch(board *Board) *Board {
|
||||
}
|
||||
|
||||
if len(p.UpdatedCardProperties) != 0 || len(p.DeletedCardProperties) != 0 {
|
||||
// first we accumulate all properties indexed by ID
|
||||
// first we accumulate all properties indexed by, and maintain their order
|
||||
keyOrder := []string{}
|
||||
cardPropertyMap := map[string]map[string]interface{}{}
|
||||
for _, prop := range board.CardProperties {
|
||||
id, ok := prop["id"].(string)
|
||||
@ -233,6 +234,7 @@ func (p *BoardPatch) Patch(board *Board) *Board {
|
||||
}
|
||||
|
||||
cardPropertyMap[id] = prop
|
||||
keyOrder = append(keyOrder, id)
|
||||
}
|
||||
|
||||
// if there are properties marked for removal, we delete them
|
||||
@ -249,13 +251,20 @@ func (p *BoardPatch) Patch(board *Board) *Board {
|
||||
continue
|
||||
}
|
||||
|
||||
_, exists := cardPropertyMap[id]
|
||||
if !exists {
|
||||
keyOrder = append(keyOrder, id)
|
||||
}
|
||||
cardPropertyMap[id] = newprop
|
||||
}
|
||||
|
||||
// and finally we flatten and save the updated properties
|
||||
newCardProperties := []map[string]interface{}{}
|
||||
for _, p := range cardPropertyMap {
|
||||
newCardProperties = append(newCardProperties, p)
|
||||
for _, key := range keyOrder {
|
||||
p, exists := cardPropertyMap[key]
|
||||
if exists {
|
||||
newCardProperties = append(newCardProperties, p)
|
||||
}
|
||||
}
|
||||
|
||||
board.CardProperties = newCardProperties
|
||||
|
Loading…
Reference in New Issue
Block a user