фикс кнопки звонка не людям. issue #44
This commit is contained in:
@@ -19,6 +19,7 @@ class ChatHeaderRow extends StatelessWidget {
|
||||
final ValueListenable<String> headerStatus;
|
||||
final ValueListenable<int> scheduledCount;
|
||||
final ValueListenable<int> otherUnread;
|
||||
final bool showCall;
|
||||
final VoidCallback? onClose;
|
||||
final VoidCallback onOpenInfo;
|
||||
final VoidCallback onOpenScheduled;
|
||||
@@ -39,6 +40,7 @@ class ChatHeaderRow extends StatelessWidget {
|
||||
required this.headerStatus,
|
||||
required this.scheduledCount,
|
||||
required this.otherUnread,
|
||||
required this.showCall,
|
||||
required this.onClose,
|
||||
required this.onOpenInfo,
|
||||
required this.onOpenScheduled,
|
||||
@@ -191,10 +193,11 @@ class ChatHeaderRow extends StatelessWidget {
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Symbols.call, weight: 500, color: cs.onSurface),
|
||||
onPressed: onCall,
|
||||
),
|
||||
if (showCall)
|
||||
IconButton(
|
||||
icon: Icon(Symbols.call, weight: 500, color: cs.onSurface),
|
||||
onPressed: onCall,
|
||||
),
|
||||
Builder(
|
||||
builder: (btnContext) => IconButton(
|
||||
icon: Icon(
|
||||
@@ -335,10 +338,11 @@ class ChatHeaderRow extends StatelessWidget {
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Symbols.call, weight: 400, color: cs.onSurface),
|
||||
onPressed: onCall,
|
||||
),
|
||||
if (showCall)
|
||||
IconButton(
|
||||
icon: Icon(Symbols.call, weight: 400, color: cs.onSurface),
|
||||
onPressed: onCall,
|
||||
),
|
||||
Builder(
|
||||
builder: (btnContext) => IconButton(
|
||||
icon: Icon(Symbols.more_vert, weight: 400, color: cs.onSurface),
|
||||
|
||||
@@ -311,6 +311,7 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
int get _myId => _chatController.myId;
|
||||
set _myId(int v) => _chatController.myId = v;
|
||||
CachedChat? chat;
|
||||
bool _peerIsBot = false;
|
||||
ChatWallpaper? _wallpaper;
|
||||
final ValueNotifier<double> _composerHeight = ValueNotifier(96);
|
||||
|
||||
@@ -425,11 +426,27 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadPeerKind() async {
|
||||
if (widget.chatType != 'DIALOG' || _myId == 0) return;
|
||||
final peerId = widget.chatId ^ _myId;
|
||||
if (peerId <= 0) return;
|
||||
final cached = ContactInfoFetch.peek(peerId);
|
||||
if (cached != null) _applyPeerKind(cached.isBot);
|
||||
final info = await ContactInfoFetch.get(peerId);
|
||||
if (info != null) _applyPeerKind(info.isBot);
|
||||
}
|
||||
|
||||
void _applyPeerKind(bool isBot) {
|
||||
if (!mounted || _peerIsBot == isBot) return;
|
||||
setState(() => _peerIsBot = isBot);
|
||||
}
|
||||
|
||||
Future<void> _fastPreloadCache() async {
|
||||
final p = await AppDatabase.loadActiveProfile();
|
||||
if (!mounted) return;
|
||||
_myId = p?.id ?? 0;
|
||||
_restoreDraft();
|
||||
unawaited(_loadPeerKind());
|
||||
unawaited(_loadWallpaper());
|
||||
unawaited(_refreshBadge());
|
||||
|
||||
@@ -1744,6 +1761,8 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
headerStatus: _headerStatusNotifier,
|
||||
scheduledCount: _scheduledCount,
|
||||
otherUnread: _otherUnread,
|
||||
showCall:
|
||||
widget.chatType == 'DIALOG' && !_peerIsBot,
|
||||
onClose: widget.onClose,
|
||||
onOpenInfo: () => Navigator.push(
|
||||
context,
|
||||
@@ -1981,7 +2000,7 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
}
|
||||
|
||||
Future<void> _startCall() async {
|
||||
if (widget.chatType != 'DIALOG') {
|
||||
if (widget.chatType != 'DIALOG' || _peerIsBot) {
|
||||
showCustomNotification(context, 'Звонки доступны только в диалогах');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -67,5 +67,7 @@ class ContactInfo {
|
||||
return o is List ? o.whereType<String>().toList() : const [];
|
||||
}
|
||||
|
||||
bool get isBot => options.contains('BOT');
|
||||
|
||||
int? get id => raw['id'] as int?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user