Only show own activity in last activity
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../models/last_heard_item.dart';
|
||||
import '../services/authentication_manager.dart';
|
||||
import '../services/lastheard_websocket_client.dart';
|
||||
|
||||
class LastHeardView extends StatefulWidget {
|
||||
@@ -36,7 +38,11 @@ class _LastHeardViewState extends State<LastHeardView> {
|
||||
_isConnecting = true;
|
||||
});
|
||||
|
||||
_wsClient = LastHeardWebSocketClient();
|
||||
final authManager = context.read<AuthenticationManager>();
|
||||
final devices = await authManager.getDevices();
|
||||
final radioIds = devices.map((d) => d.id).toList();
|
||||
|
||||
_wsClient = LastHeardWebSocketClient(radioIds: radioIds);
|
||||
await _wsClient!.connect();
|
||||
|
||||
_wsSubscription = _wsClient!.messageStream.listen((message) {
|
||||
@@ -53,7 +59,7 @@ class _LastHeardViewState extends State<LastHeardView> {
|
||||
void _handleMqttMessage(Map<String, dynamic> data) {
|
||||
try {
|
||||
final topic = data['topic'] as String?;
|
||||
if (topic == 'LH') {
|
||||
if (topic == 'LH-Startup') {
|
||||
final payloadStr = data['payload'] as String?;
|
||||
if (payloadStr != null) {
|
||||
final payload = jsonDecode(payloadStr) as Map<String, dynamic>;
|
||||
@@ -84,21 +90,7 @@ class _LastHeardViewState extends State<LastHeardView> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Last Heard'),
|
||||
actions: [
|
||||
if (_items.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 16),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'${_items.length} ${_items.length == 1 ? "entry" : "entries"}',
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
title: const Text('Last Activity'),
|
||||
),
|
||||
body: _buildBody(),
|
||||
);
|
||||
@@ -112,7 +104,7 @@ class _LastHeardViewState extends State<LastHeardView> {
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(height: 16),
|
||||
Text('Connecting to Last Heard...'),
|
||||
Text('Connecting to Last Activity...'),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -135,7 +127,7 @@ class _LastHeardViewState extends State<LastHeardView> {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Waiting for Last Heard data...',
|
||||
'Waiting for Last Activity data...',
|
||||
style: TextStyle(color: Colors.grey[600]),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user