fix: Уведомление приходит, хотя чат открыт. Нет зелёной точки «в сети» в списке чатов. Тап по уведомлению не открывает чат. Реакции на сторис. Пропали галочки в папке «Все».

This commit is contained in:
Jganenokk
2026-08-19 22:07:16 +07:00
parent 3e6254bc5d
commit 3e4edc535c
14 changed files with 461 additions and 360 deletions
+19 -4
View File
@@ -40,6 +40,11 @@ CachedChat? parseChatRow(
existing,
);
final lastMessage = _resolveLastMessage(chat['lastMessage']);
final previous = existing[id];
final sameLastMessage =
previous != null &&
lastMessage.id != null &&
previous.lastMsgId == lastMessage.id;
final muteFav = _resolveMuteAndFavorite(chatsConfig, id, existing);
final presence = _resolvePresence(type, otherId, presenceMap);
final adminsOwner = _resolveAdmins(chat);
@@ -59,7 +64,10 @@ CachedChat? parseChatRow(
lastMsgText: lastMessage.text,
lastMsgElements: lastMessage.elements,
lastMsgPreview: lastMessage.preview,
lastMsgSenderId: lastMessage.senderId,
lastMsgSenderId:
lastMessage.senderId ??
(sameLastMessage ? previous.lastMsgSenderId : null),
lastMsgStatus: sameLastMessage ? previous.lastMsgStatus : null,
unreadCount: (chat['newMessages'] as int?) ?? 0,
lastEventTime: (chat['lastEventTime'] as int?) ?? 0,
cachedAt: cachedAt,
@@ -146,15 +154,22 @@ _resolveLastMessage(dynamic lastMsg) {
);
}
return (
id: lastMsg['id'] as int?,
time: lastMsg['time'] as int?,
id: _asIntOrNull(lastMsg['id']),
time: _asIntOrNull(lastMsg['time']),
text: messagePreviewText(lastMsg),
elements: messagePreviewElements(lastMsg),
preview: messagePreviewMedia(lastMsg),
senderId: lastMsg['sender'] as int?,
senderId: _asIntOrNull(lastMsg['sender']),
);
}
int? _asIntOrNull(Object? value) {
if (value is int) return value;
if (value is num) return value.toInt();
if (value is String) return int.tryParse(value);
return null;
}
({int? id, String? text, int? time, bool isPreview}) _resolvePinnedMessage(
dynamic pinned,
) {
+5
View File
@@ -1388,11 +1388,16 @@ class ChatsModule {
}
}
final Set<int> _repairedSenders = {};
Future<List<CachedChat>> getChats(
int accountId, {
bool includeHidden = false,
}) async {
try {
if (_repairedSenders.add(accountId)) {
await AppDatabase.repairLastMessageSenders(accountId);
}
final rows = await AppDatabase.loadChats(
accountId,
includeHidden: includeHidden,
-38
View File
@@ -396,44 +396,6 @@ class StoriesModule {
unawaited(_persistPreviews());
}
/// Поставить ([reaction] != null) или снять (null) реакцию на историю.
Future<bool> react(
StoryOwner owner,
int storyId,
StoryReaction? reaction,
) async {
if (_api.state != SessionState.online) return false;
try {
final ok = await _api.sendRequestOk(Opcode.storiesReact, {
'owner': owner.toMap(),
'storyId': storyId,
if (reaction != null) 'reaction': reaction.toMap(),
});
if (ok) _applyReactionLocally(owner.ownerId, storyId, reaction);
return ok;
} catch (e) {
logger.w('StoriesModule.react: $e');
return false;
}
}
void _applyReactionLocally(
int ownerId,
int storyId,
StoryReaction? reaction,
) {
final stories = _peerStories[ownerId];
if (stories == null) return;
final idx = stories.indexWhere((s) => s.id == storyId);
if (idx < 0) return;
stories[idx] = stories[idx].copyWith(
reaction: reaction,
clearReaction: reaction == null,
);
_bump();
unawaited(_persistPeers());
}
/// Публикация фото-истории. [photoToken] — токен уже загруженного фото.
/// [settings]: 1 = видно всем, 2 = только контактам. [expiration] — TTL, мс.
/// Бросает [PacketError]/[TimeoutException] при ошибке сервера — чтобы UI