client: resume chat list sync after restart

This commit is contained in:
Tulir Asokan
2026-03-19 16:47:17 +02:00
parent 64724aa654
commit b17bb0d5c7
2 changed files with 16 additions and 1 deletions
+10
View File
@@ -111,6 +111,7 @@ type TelegramClient struct {
stopTakeoutTimer *time.Timer
takeoutDialogsOnce sync.Once
syncChatsLock sync.Mutex
isNewLogin bool
prevReactionPoll map[networkid.PortalKey]time.Time
prevReactionPollLock sync.Mutex
@@ -511,6 +512,15 @@ func (t *TelegramClient) runInBackground(ctx context.Context) {
log := zerolog.Ctx(ctx)
err := t.client.Run(ctx, func(ctx context.Context) error {
t.clientInitialized.Set()
// If takeout dialog sync is enabled, we assume it'll resume from a getTakeoutID call.
// If not, resume dialog sync manually here.
if !t.isNewLogin && !t.main.Config.Takeout.DialogSync {
go func() {
if err := t.syncChats(log.WithContext(t.clientCtx), 0, false, false); err != nil {
log.Err(err).Msg("Failed to resume chat sync")
}
}()
}
log.Info().Msg("Client running, starting updates")
err := t.updatesManager.Run(ctx, t.client.API(), t.telegramUserID, updates.AuthOptions{
IsBot: t.metadata.IsBot,