Skip to content

Commit b82f7e6

Browse files
committed
fix: telegram chat-id discovery vs live poll race
Polling required only a saved token to start, so it could consume (and permanently ack) the user's first message before "Detectar chat ID" ever saw it. Now it also requires a valid chat id.
1 parent df6aa2b commit b82f7e6

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.29.1] - 2026-07-01
11+
12+
### Fixed
13+
- "Detectar chat ID" in Telegram settings now reliably finds your first message to the bot: previously, enabling the toggle started the live polling loop as soon as a token was saved, which immediately consumed (and discarded) any pending message before the detect button ever got to read it. Polling now waits until a chat id is actually configured before it starts.
14+
1015
## [0.29.0] - 2026-07-01
1116

1217
### Added
@@ -314,6 +319,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
314319
- Pin panel open option
315320

316321
[Unreleased]: https://github.com/javierpr0/notchly/compare/v0.28.3...HEAD
322+
[0.29.1]: https://github.com/javierpr0/notchly/compare/v0.29.0...v0.29.1
317323
[0.29.0]: https://github.com/javierpr0/notchly/compare/v0.28.3...v0.29.0
318324
[0.28.3]: https://github.com/javierpr0/notchly/compare/v0.28.2...v0.28.3
319325
[0.28.2]: https://github.com/javierpr0/notchly/compare/v0.28.1...v0.28.2

Notchy/TelegramConfigStore.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ final class TelegramConfigStore {
5656
didSet {
5757
guard config != oldValue else { return }
5858
save()
59-
if config.enabled != oldValue.enabled {
59+
if config.enabled != oldValue.enabled || config.chatId != oldValue.chatId {
6060
TelegramService.shared.restart()
6161
}
6262
}

Notchy/TelegramService.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ final class TelegramService {
3030
func startIfConfigured() {
3131
guard pollTask == nil else { return }
3232
let config = TelegramConfigStore.shared.config
33-
guard config.enabled, let token = TelegramKeychain.load(), !token.isEmpty else { return }
33+
// Require a chat id before polling starts — otherwise the live loop
34+
// acknowledges (and permanently discards) the user's very first
35+
// message before "Detectar chat ID" ever gets to see it.
36+
guard config.enabled, Int64(config.chatId) != nil,
37+
let token = TelegramKeychain.load(), !token.isEmpty else { return }
3438
let client = TelegramBotClient(token: token)
3539
pollTask = Task { [weak self] in await self?.pollLoop(client: client) }
3640
}

0 commit comments

Comments
 (0)