(
entity: TargetEntity,
indexValue: TargetValue
)
| 105 | } |
| 106 | |
| 107 | function updateItemIndexWithValue( |
| 108 | entity: TargetEntity, |
| 109 | indexValue: TargetValue |
| 110 | ) { |
| 111 | // Item might already be indexed somewhere |
| 112 | const currentIndexList = currentItemIndexMap.get(entity); |
| 113 | // Get where it should be indexed now |
| 114 | const targetIndexList = observableMapGetOrCreate( |
| 115 | observableIndex, |
| 116 | indexValue, |
| 117 | () => observable.array() |
| 118 | ); |
| 119 | |
| 120 | // There is no need to do anything - indexed value did not change |
| 121 | if (currentIndexList === targetIndexList) return; |
| 122 | |
| 123 | runInAction(() => { |
| 124 | if (currentIndexList) { |
| 125 | currentIndexList.remove(entity); |
| 126 | } |
| 127 | targetIndexList.push(entity); |
| 128 | |
| 129 | currentItemIndexMap.set(entity, targetIndexList); |
| 130 | }); |
| 131 | } |
| 132 | |
| 133 | function updateItemIndex(entity: TargetEntity) { |
| 134 | const indexValue = getCurrentIndexValue(entity); |
no test coverage detected