mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 10:53:44 +03:00
Don't unnecessarily refetch the sender twice
This commit is contained in:
parent
299b090cde
commit
db29e9b7ef
|
@ -46,11 +46,14 @@ class SenderGetter(abc.ABC):
|
||||||
# cached information, they may use the property instead.
|
# cached information, they may use the property instead.
|
||||||
if (self._sender is None or getattr(self._sender, 'min', None)) \
|
if (self._sender is None or getattr(self._sender, 'min', None)) \
|
||||||
and await self.get_input_sender():
|
and await self.get_input_sender():
|
||||||
try:
|
# self.get_input_sender may refresh in which case the sender may no longer be min
|
||||||
self._sender =\
|
# However it could still incur a cost so the cheap check is done twice instead.
|
||||||
await self._client.get_entity(self._input_sender)
|
if self._sender is None or getattr(self._sender, 'min', None):
|
||||||
except ValueError:
|
try:
|
||||||
await self._refetch_sender()
|
self._sender =\
|
||||||
|
await self._client.get_entity(self._input_sender)
|
||||||
|
except ValueError:
|
||||||
|
await self._refetch_sender()
|
||||||
return self._sender
|
return self._sender
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Reference in New Issue
Block a user