Sync channels from most to least recently updated

This commit is contained in:
Andrew Ferrazzutti 2022-04-08 05:06:09 -04:00
parent cf9fbc6d57
commit 3abb296109
1 changed files with 10 additions and 1 deletions

View File

@ -426,7 +426,16 @@ class User(DBUser, BaseUser):
sync_count = num_channels if sync_count < 0 else min(sync_count, num_channels)
await self.push_bridge_state(BridgeStateEvent.BACKFILLING)
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:
await self._sync_channel(login_data)
except AuthenticationRequired: