Don't unnecessarily refetch the sender twice

This commit is contained in:
Lonami Exo 2022-10-03 13:11:48 +02:00
parent 299b090cde
commit db29e9b7ef

View File

@ -46,11 +46,14 @@ class SenderGetter(abc.ABC):
# cached information, they may use the property instead.
if (self._sender is None or getattr(self._sender, 'min', None)) \
and await self.get_input_sender():
try:
self._sender =\
await self._client.get_entity(self._input_sender)
except ValueError:
await self._refetch_sender()
# self.get_input_sender may refresh in which case the sender may no longer be min
# However it could still incur a cost so the cheap check is done twice instead.
if self._sender is None or getattr(self._sender, 'min', None):
try:
self._sender =\
await self._client.get_entity(self._input_sender)
except ValueError:
await self._refetch_sender()
return self._sender
@property