From 548672d243e1247f12b4f1bba399736e67e7965a Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 5 Dec 2025 23:50:44 +0200 Subject: [PATCH] client: simplify IsLoggedIn check --- pkg/connector/client.go | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/pkg/connector/client.go b/pkg/connector/client.go index 8870e034..f6a3d445 100644 --- a/pkg/connector/client.go +++ b/pkg/connector/client.go @@ -622,22 +622,9 @@ func (t *TelegramClient) getSingleChannel(ctx context.Context, id int64) (*tg.Ch } func (t *TelegramClient) IsLoggedIn() bool { - if t == nil || t.clientCtx == nil { - return false - } - select { - case <-t.clientCtx.Done(): - t.main.Bridge.Log.Debug(). - Bool("client_context_done", true). - Msg("Checking if user is logged in") - return false - default: - t.main.Bridge.Log.Debug(). - Bool("has_client", t.client != nil). - Bool("has_auth_key", t.userLogin.Metadata.(*UserLoginMetadata).Session.HasAuthKey()). - Msg("Checking if user is logged in") - return t.client != nil && t.userLogin.Metadata.(*UserLoginMetadata).Session.HasAuthKey() - } + // TODO use less hacky check than context cancellation + return t != nil && t.clientCtx != nil && t.client != nil && t.clientCtx.Err() == nil && + t.userLogin.Metadata.(*UserLoginMetadata).Session.HasAuthKey() } func (t *TelegramClient) LogoutRemote(ctx context.Context) {