updateHybridList method
Updates the hybrid list with a new user or updates an existing user
Implementation
void updateHybridList(LocationDataModel _newUser) async {
var contains = _allReceivedUsersList[_newUser.sender] != null;
if (!contains) {
_locationReceivedData[_newUser.sender] = _newUser;
var _image = await getImageOfAtsignNew(_newUser.sender);
var _user = HybridModel(
displayName: _newUser.sender,
latLng: _newUser.getLatLng,
image: _image,
eta: '?');
_allReceivedUsersList[_newUser.sender] = _user;
_allReceivedUsersController.add(_allReceivedUsersList);
allReceivedUsersSink.add(_allReceivedUsersList);
LocationService().newList(_newUser.sender);
} else {
/// don't add past data
if (_locationReceivedData[_newUser.sender]!
.lastUpdatedAt
.isBefore(_newUser.lastUpdatedAt)) {
_locationReceivedData[_newUser.sender] = _newUser;
} else {
return;
}
_allReceivedUsersList[_newUser.sender]!.latLng = _newUser.getLatLng;
_allReceivedUsersList[_newUser.sender]!.eta = '?';
_allReceivedUsersController.add(_allReceivedUsersList);
allReceivedUsersSink.add(_allReceivedUsersList);
LocationService().newList(_newUser.sender);
}
/// also update UI
KeyStreamService().notifyListeners();
}