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