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-04-05 23:55:39 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 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             :           imagePath: picture,
      17             :           defaultImagePath: defaultPicture,
      18             :           contactsJson: contactsJson,
      19             :           serversJson: serverJson,
      20             :           online: online,
      21             :           autostart: autostart,
      22             :           encrypted: encrypted,
      23             :           appearOffline: appearOffline));
      24             :     } else {
      25           0 :       _profiles[idx].updateFrom(onion, name, picture, contactsJson, serverJson, online);
      26             :     }
      27           0 :     notifyListeners();
      28             :   }
      29             : 
      30           0 :   List<ProfileInfoState> get profiles => _profiles.sublist(0); //todo: copy?? dont want caller able to bypass changenotifier
      31             : 
      32           0 :   ProfileInfoState? getProfile(String onion) {
      33           0 :     int idx = _profiles.indexWhere((element) => element.onion == onion);
      34           0 :     return idx >= 0 ? _profiles[idx] : null;
      35             :   }
      36             : 
      37           0 :   void delete(String onion) {
      38           0 :     _profiles.removeWhere((element) => element.onion == onion);
      39           0 :     notifyListeners();
      40             :   }
      41             : 
      42           0 :   int generateUnreadCount(String selectedProfile) => _profiles.where((p) => p.onion != selectedProfile).fold(0, (i, p) => i + p.unreadMessages);
      43             : 
      44           0 :   int cacheMemUsage() {
      45           0 :     return _profiles.map((e) => e.cacheMemUsage()).fold(0, (previousValue, element) => previousValue + element);
      46             :   }
      47             : }

Generated by: LCOV version 1.14