mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
Inline flatten method
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
53fc6a7af9
commit
db515d48c1
@ -3,12 +3,6 @@ export class Disambiguator {
|
||||
this._map = new Map();
|
||||
}
|
||||
|
||||
_flatten(name, array) {
|
||||
const vm = array.pop();
|
||||
vm.setDisambiguation(false);
|
||||
this._map.set(name, vm);
|
||||
}
|
||||
|
||||
_unDisambiguate(vm, array) {
|
||||
const idx = array.indexOf(vm);
|
||||
if (idx !== -1) {
|
||||
@ -23,7 +17,11 @@ export class Disambiguator {
|
||||
const value = this._map.get(previousName);
|
||||
if (Array.isArray(value)) {
|
||||
this._unDisambiguate(vm, value);
|
||||
if (value.length === 1) { this._flatten(previousName, value); }
|
||||
if (value.length === 1) {
|
||||
const vm = value[0];
|
||||
vm.setDisambiguation(false);
|
||||
this._map.set(previousName, vm);
|
||||
}
|
||||
} else {
|
||||
this._map.delete(previousName);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user