Skip to content

Commit

Permalink
Refactor SpinifyImpl to update JSON codec support in SpinifySubscript…
Browse files Browse the repository at this point in the history
…ionMixin
  • Loading branch information
PlugFox committed Jun 13, 2024
1 parent e5b1593 commit d15c375
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions lib/src/model/state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ sealed class SpinifyState extends _$SpinifyStateBase {
};

@override
String toString() => 'SpinifyState\$$type{}';
String toString() => type;
}

/// Disconnected
Expand All @@ -137,7 +137,7 @@ final class SpinifyState$Disconnected extends SpinifyState {
}) : super(timestamp ?? DateTime.now());

@override
String get type => 'Disconnected';
String get type => 'disconnected';

@override
String? get url => null;
Expand Down Expand Up @@ -191,7 +191,7 @@ final class SpinifyState$Connecting extends SpinifyState {
: super(timestamp ?? DateTime.now());

@override
String get type => 'Connecting';
String get type => 'connecting';

@override
final String url;
Expand Down Expand Up @@ -251,7 +251,7 @@ final class SpinifyState$Connected extends SpinifyState {
}) : super(timestamp ?? DateTime.now());

@override
String get type => 'Connected';
String get type => 'connected';

@override
final String url;
Expand Down Expand Up @@ -344,7 +344,7 @@ final class SpinifyState$Closed extends SpinifyState {
: super(timestamp ?? DateTime.now());

@override
String get type => 'Closed';
String get type => 'closed';

@override
String? get url => null;
Expand Down
26 changes: 13 additions & 13 deletions lib/src/model/subscription_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ sealed class SpinifySubscriptionState extends _$SpinifySubscriptionStateBase {
required List<int>? data,
DateTime? timestamp,
}) = SpinifySubscriptionState$Subscribed;

@override
String toString() => type;
}

/// Unsubscribed state
Expand Down Expand Up @@ -79,10 +82,9 @@ final class SpinifySubscriptionState$Unsubscribed

@override
bool operator ==(Object other) =>
identical(this, other) || other is SpinifySubscriptionState$Unsubscribed;

@override
String toString() => r'SpinifySubscriptionState$Unsubscribed{}';
identical(this, other) ||
other is SpinifySubscriptionState$Unsubscribed &&
other.timestamp.isAtSameMomentAs(timestamp);
}

/// Subscribing state
Expand Down Expand Up @@ -128,10 +130,9 @@ final class SpinifySubscriptionState$Subscribing

@override
bool operator ==(Object other) =>
identical(this, other) || other is SpinifySubscriptionState$Subscribing;

@override
String toString() => r'SpinifySubscriptionState$Subscribing{}';
identical(this, other) ||
other is SpinifySubscriptionState$Subscribing &&
other.timestamp.isAtSameMomentAs(timestamp);
}

/// Subscribed state
Expand All @@ -147,7 +148,7 @@ final class SpinifySubscriptionState$Subscribed
DateTime? timestamp,
}) : super(timestamp: timestamp ?? DateTime.now());

/// Data
/// Data attached to current subscription.
final List<int>? data;

@override
Expand Down Expand Up @@ -181,10 +182,9 @@ final class SpinifySubscriptionState$Subscribed

@override
bool operator ==(Object other) =>
identical(this, other) || other is SpinifySubscriptionState$Subscribed;

@override
String toString() => r'SpinifySubscriptionState$Subscribed{}';
identical(this, other) ||
other is SpinifySubscriptionState$Subscribed &&
other.timestamp.isAtSameMomentAs(timestamp);
}

/// Pattern matching for [SpinifySubscriptionState].
Expand Down

0 comments on commit d15c375

Please sign in to comment.