LCOV - code coverage report
Current view: top level - lib/models - profilelist.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 17 0.0 %
Date: 2024-09-10 17:47:43 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:flutter/cupertino.dart';
       2             : import 'package:flutter/widgets.dart';
       3             : 
       4             : import 'profile.dart';
       5             : 
       6             : class ProfileListState extends ChangeNotifier {
       7             :   List<ProfileInfoState> _profiles = [];
       8           0 :   int get num => _profiles.length;
       9             : 
      10           0 :   void add(String onion, String name, String privateName, String picture, String defaultPicture, String contactsJson, String serverJson, bool online, bool autostart, bool encrypted, bool appearOffline) {
      11           0 :     var idx = _profiles.indexWhere((element) => element.onion == onion);
      12           0 :     if (idx == -1) {
      13           0 :       _profiles.add(ProfileInfoState(
      14             :           onion: onion,
      15             :           nickname: name,
      16             :           privateName: privateName,
      17             :           imagePath: picture,
      18             :           defaultImagePath: defaultPicture,
      19             :           contactsJson: contactsJson,
      20             :           serversJson: serverJson,
      21             :           online: online,
      22             :           autostart: autostart,
      23             :           encrypted: encrypted,
      24             :           appearOffline: appearOffline));
      25             :     } else {
      26           0 :       _profiles[idx].updateFrom(onion, name, picture, contactsJson, serverJson, online);
      27             :     }
      28           0 :     notifyListeners();
      29             :   }
      30             : 
      31           0 :   List<ProfileInfoState> get profiles => _profiles.sublist(0); //todo: copy?? dont want caller able to bypass changenotifier
      32             : 
      33           0 :   ProfileInfoState? getProfile(String onion) {
      34           0 :     int idx = _profiles.indexWhere((element) => element.onion == onion);
      35           0 :     return idx >= 0 ? _profiles[idx] : null;
      36             :   }
      37             : 
      38           0 :   void delete(String onion) {
      39           0 :     _profiles.removeWhere((element) => element.onion == onion);
      40           0 :     notifyListeners();
      41             :   }
      42             : 
      43           0 :   int generateUnreadCount(String selectedProfile) => _profiles.where((p) => p.onion != selectedProfile).fold(0, (i, p) => i + p.unreadMessages);
      44             : 
      45           0 :   int cacheMemUsage() {
      46           0 :     return _profiles.map((e) => e.cacheMemUsage()).fold(0, (previousValue, element) => previousValue + element);
      47             :   }
      48             : }

Generated by: LCOV version 1.14