LCOV - code coverage report
Current view: top level - lib/src - event_status.dart (source / functions) Hit Total Coverage
Test: merged.info Lines: 11 12 91.7 %
Date: 2024-05-13 12:56:47 Functions: 0 0 -

          Line data    Source code
       1             : /// Defines event status:
       2             : /// - removed
       3             : /// - error: (http request failed)
       4             : /// - sending: (http request started)
       5             : /// - sent: (http request successful)
       6             : /// - synced: (event came from sync loop)
       7             : /// - roomState
       8             : enum EventStatus {
       9             :   error,
      10             :   sending,
      11             :   sent,
      12             :   synced,
      13             :   roomState,
      14             : }
      15             : 
      16             : /// Returns `EventStatusEnum` value from `intValue`.
      17             : ///
      18             : /// - -2 == removed;
      19             : /// - -1 == error;
      20             : /// -  0 == sending;
      21             : /// -  1 == sent;
      22             : /// -  2 == synced;
      23             : /// -  3 == roomState;
      24          35 : EventStatus eventStatusFromInt(int intValue) =>
      25          70 :     EventStatus.values[intValue + 2];
      26             : 
      27             : /// Takes two [EventStatus] values and returns the one with higher
      28             : /// (better in terms of message sending) status.
      29          11 : EventStatus latestEventStatus(EventStatus status1, EventStatus status2) =>
      30          33 :     status1.intValue > status2.intValue ? status1 : status2;
      31             : 
      32             : extension EventStatusExtension on EventStatus {
      33             :   /// Returns int value of the event status.
      34             :   ///
      35             :   /// - -1 == error;
      36             :   /// -  0 == sending;
      37             :   /// -  1 == sent;
      38             :   /// -  2 == synced;
      39             :   /// -  3 == roomState;
      40         105 :   int get intValue => (index - 2);
      41             : 
      42             :   /// Return `true` if the `EventStatus` equals `error`.
      43          64 :   bool get isError => this == EventStatus.error;
      44             : 
      45             :   /// Return `true` if the `EventStatus` equals `sending`.
      46          70 :   bool get isSending => this == EventStatus.sending;
      47             : 
      48             :   /// Return `true` if the `EventStatus` equals `roomState`.
      49           0 :   bool get isRoomState => this == EventStatus.roomState;
      50             : 
      51             :   /// Returns `true` if the status is sent or later:
      52             :   /// [EventStatus.sent], [EventStatus.synced] or [EventStatus.roomState].
      53          64 :   bool get isSent => [
      54             :         EventStatus.sent,
      55             :         EventStatus.synced,
      56             :         EventStatus.roomState
      57          32 :       ].contains(this);
      58             : 
      59             :   /// Returns `true` if the status is `synced` or `roomState`:
      60             :   /// [EventStatus.synced] or [EventStatus.roomState].
      61          64 :   bool get isSynced => [
      62             :         EventStatus.synced,
      63             :         EventStatus.roomState,
      64          32 :       ].contains(this);
      65             : }

Generated by: LCOV version 1.14