Sync channels from most to least recently updated
This commit is contained in:
parent
cf9fbc6d57
commit
3abb296109
|
@ -426,7 +426,16 @@ class User(DBUser, BaseUser):
|
||||||
sync_count = num_channels if sync_count < 0 else min(sync_count, num_channels)
|
sync_count = num_channels if sync_count < 0 else min(sync_count, num_channels)
|
||||||
await self.push_bridge_state(BridgeStateEvent.BACKFILLING)
|
await self.push_bridge_state(BridgeStateEvent.BACKFILLING)
|
||||||
self.log.debug(f"Syncing {sync_count} of {num_channels} channels...")
|
self.log.debug(f"Syncing {sync_count} of {num_channels} channels...")
|
||||||
for login_data in login_result.channelList[:sync_count]:
|
|
||||||
|
def get_channel_update_time(login_data: LoginDataItem):
|
||||||
|
channel_info = login_data.channel.info
|
||||||
|
return channel_info.lastChatLog.sendAt if channel_info.lastChatLog else 0
|
||||||
|
|
||||||
|
for login_data in sorted(
|
||||||
|
login_result.channelList,
|
||||||
|
reverse=True,
|
||||||
|
key=get_channel_update_time
|
||||||
|
)[:sync_count]:
|
||||||
try:
|
try:
|
||||||
await self._sync_channel(login_data)
|
await self._sync_channel(login_data)
|
||||||
except AuthenticationRequired:
|
except AuthenticationRequired:
|
||||||
|
|
Loading…
Reference in New Issue