fix: щавель виноград, ебырь омайгад
This commit is contained in:
@@ -68,6 +68,9 @@ class Api {
|
||||
Timer? _reconnectTimer;
|
||||
int _reconnectAttempts = 0;
|
||||
bool _autoReconnect = false;
|
||||
int _sessionEpoch = 0;
|
||||
|
||||
int get sessionEpoch => _sessionEpoch;
|
||||
|
||||
/// Залипает на время сессии: VPN-путь не сработал — идём мимо туннеля.
|
||||
bool _bypassActive = false;
|
||||
@@ -125,6 +128,7 @@ class Api {
|
||||
_callsSeed = response.payload['callsSeed'] as int?;
|
||||
_registrationCountries = _parseRegistrationCountries(response.payload);
|
||||
_sessionState = SessionState.online;
|
||||
_sessionEpoch++;
|
||||
_startPinging();
|
||||
logger.i('Сессия онлайн, хэндшейк ок');
|
||||
if (_onReconnectCallback != null) {
|
||||
|
||||
@@ -328,6 +328,36 @@ class ChatsModule {
|
||||
_bump();
|
||||
}
|
||||
|
||||
static Future<int?> markUnread(
|
||||
Api api,
|
||||
int accountId,
|
||||
int chatId,
|
||||
int mark,
|
||||
) async {
|
||||
int? unread;
|
||||
try {
|
||||
final resp = await api.sendRequest(Opcode.chatMark, {
|
||||
'type': 'SET_AS_UNREAD',
|
||||
'chatId': chatId,
|
||||
'mark': mark,
|
||||
});
|
||||
final payload = resp.payload;
|
||||
if (payload is Map) unread = payload['unread'] as int?;
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
if (unread == null) return null;
|
||||
|
||||
final rows = await AppDatabase.loadChat(accountId, chatId);
|
||||
if (rows.isNotEmpty) {
|
||||
final row = Map<String, dynamic>.from(rows.first);
|
||||
row['unread_count'] = unread;
|
||||
await AppDatabase.saveChats([row]);
|
||||
_bump();
|
||||
}
|
||||
return unread;
|
||||
}
|
||||
|
||||
static Future<void> applyOutgoing(
|
||||
int accountId,
|
||||
int chatId, {
|
||||
|
||||
Reference in New Issue
Block a user