🐛 Fixes and optimzation on post

♻️ Replace freezed abstract classes with sealed
This commit is contained in:
2025-05-24 22:38:07 +08:00
parent 81103ba8b6
commit a2053aa772
19 changed files with 315 additions and 134 deletions

View File

@ -5,7 +5,7 @@ part 'activity.freezed.dart';
part 'activity.g.dart';
@freezed
abstract class SnActivity with _$SnActivity {
sealed class SnActivity with _$SnActivity {
const factory SnActivity({
required String id,
required String type,
@ -24,7 +24,7 @@ abstract class SnActivity with _$SnActivity {
}
@freezed
abstract class SnCheckInResult with _$SnCheckInResult {
sealed class SnCheckInResult with _$SnCheckInResult {
const factory SnCheckInResult({
required String id,
required int level,
@ -41,7 +41,7 @@ abstract class SnCheckInResult with _$SnCheckInResult {
}
@freezed
abstract class SnFortuneTip with _$SnFortuneTip {
sealed class SnFortuneTip with _$SnFortuneTip {
const factory SnFortuneTip({
required bool isPositive,
required String title,
@ -53,7 +53,7 @@ abstract class SnFortuneTip with _$SnFortuneTip {
}
@freezed
abstract class SnEventCalendarEntry with _$SnEventCalendarEntry {
sealed class SnEventCalendarEntry with _$SnEventCalendarEntry {
const factory SnEventCalendarEntry({
required DateTime date,
required SnCheckInResult? checkInResult,

View File

@ -4,7 +4,7 @@ part 'auth.freezed.dart';
part 'auth.g.dart';
@freezed
abstract class AppTokenPair with _$AppTokenPair {
sealed class AppTokenPair with _$AppTokenPair {
const factory AppTokenPair({
required String accessToken,
required String refreshToken,
@ -15,7 +15,7 @@ abstract class AppTokenPair with _$AppTokenPair {
}
@freezed
abstract class SnAuthChallenge with _$SnAuthChallenge {
sealed class SnAuthChallenge with _$SnAuthChallenge {
const factory SnAuthChallenge({
required String id,
required DateTime expiredAt,
@ -38,7 +38,7 @@ abstract class SnAuthChallenge with _$SnAuthChallenge {
}
@freezed
abstract class SnAuthFactor with _$SnAuthFactor {
sealed class SnAuthFactor with _$SnAuthFactor {
const factory SnAuthFactor({
required String id,
required int type,

View File

@ -7,7 +7,7 @@ part 'chat.freezed.dart';
part 'chat.g.dart';
@freezed
abstract class SnChatRoom with _$SnChatRoom {
sealed class SnChatRoom with _$SnChatRoom {
const factory SnChatRoom({
required String id,
required String? name,
@ -31,7 +31,7 @@ abstract class SnChatRoom with _$SnChatRoom {
}
@freezed
abstract class SnChatMessage with _$SnChatMessage {
sealed class SnChatMessage with _$SnChatMessage {
const factory SnChatMessage({
required DateTime createdAt,
required DateTime updatedAt,
@ -56,7 +56,7 @@ abstract class SnChatMessage with _$SnChatMessage {
}
@freezed
abstract class SnChatReaction with _$SnChatReaction {
sealed class SnChatReaction with _$SnChatReaction {
const factory SnChatReaction({
required DateTime createdAt,
required DateTime updatedAt,
@ -74,7 +74,7 @@ abstract class SnChatReaction with _$SnChatReaction {
}
@freezed
abstract class SnChatMember with _$SnChatMember {
sealed class SnChatMember with _$SnChatMember {
const factory SnChatMember({
required DateTime createdAt,
required DateTime updatedAt,
@ -96,7 +96,7 @@ abstract class SnChatMember with _$SnChatMember {
}
@freezed
abstract class SnChatSummary with _$SnChatSummary {
sealed class SnChatSummary with _$SnChatSummary {
const factory SnChatSummary({
required int unreadCount,
required SnChatMessage lastMessage,
@ -113,7 +113,7 @@ class MessageChangeAction {
}
@freezed
abstract class MessageChange with _$MessageChange {
sealed class MessageChange with _$MessageChange {
const factory MessageChange({
required String messageId,
required String action,
@ -126,7 +126,7 @@ abstract class MessageChange with _$MessageChange {
}
@freezed
abstract class MessageSyncResponse with _$MessageSyncResponse {
sealed class MessageSyncResponse with _$MessageSyncResponse {
const factory MessageSyncResponse({
@Default([]) List<MessageChange> changes,
required DateTime currentTimestamp,
@ -137,7 +137,7 @@ abstract class MessageSyncResponse with _$MessageSyncResponse {
}
@freezed
abstract class ChatRealtimeJoinResponse with _$ChatRealtimeJoinResponse {
sealed class ChatRealtimeJoinResponse with _$ChatRealtimeJoinResponse {
const factory ChatRealtimeJoinResponse({
required String token,
required Map<String, dynamic> config,

View File

@ -6,7 +6,7 @@ part 'file.g.dart';
enum UniversalFileType { image, video, audio, file }
@freezed
abstract class UniversalFile with _$UniversalFile {
sealed class UniversalFile with _$UniversalFile {
const UniversalFile._();
const factory UniversalFile({
@ -31,7 +31,7 @@ abstract class UniversalFile with _$UniversalFile {
}
@freezed
abstract class SnCloudFile with _$SnCloudFile {
sealed class SnCloudFile with _$SnCloudFile {
const factory SnCloudFile({
required String id,
required String name,

View File

@ -5,7 +5,7 @@ part 'post.freezed.dart';
part 'post.g.dart';
@freezed
abstract class SnPost with _$SnPost {
sealed class SnPost with _$SnPost {
const factory SnPost({
required String id,
required String? title,
@ -43,7 +43,7 @@ abstract class SnPost with _$SnPost {
}
@freezed
abstract class SnPublisher with _$SnPublisher {
sealed class SnPublisher with _$SnPublisher {
const factory SnPublisher({
required String id,
required int type,
@ -66,7 +66,7 @@ abstract class SnPublisher with _$SnPublisher {
}
@freezed
abstract class SnPublisherStats with _$SnPublisherStats {
sealed class SnPublisherStats with _$SnPublisherStats {
const factory SnPublisherStats({
required int postsCreated,
required int stickerPacksCreated,
@ -80,7 +80,7 @@ abstract class SnPublisherStats with _$SnPublisherStats {
}
@freezed
abstract class SnSubscriptionStatus with _$SnSubscriptionStatus {
sealed class SnSubscriptionStatus with _$SnSubscriptionStatus {
const factory SnSubscriptionStatus({
required bool isSubscribed,
required int publisherId,
@ -92,7 +92,7 @@ abstract class SnSubscriptionStatus with _$SnSubscriptionStatus {
}
@freezed
abstract class ReactInfo with _$ReactInfo {
sealed class ReactInfo with _$ReactInfo {
const factory ReactInfo({required String icon, required int attitude}) =
_ReactInfo;
}

View File

@ -6,7 +6,7 @@ part 'realm.freezed.dart';
part 'realm.g.dart';
@freezed
abstract class SnRealm with _$SnRealm {
sealed class SnRealm with _$SnRealm {
const factory SnRealm({
required String id,
required String slug,
@ -31,7 +31,7 @@ abstract class SnRealm with _$SnRealm {
}
@freezed
abstract class SnRealmMember with _$SnRealmMember {
sealed class SnRealmMember with _$SnRealmMember {
const factory SnRealmMember({
required String realmId,
required SnRealm? realm,

View File

@ -6,7 +6,7 @@ part 'relationship.freezed.dart';
part 'relationship.g.dart';
@freezed
abstract class SnRelationship with _$SnRelationship {
sealed class SnRelationship with _$SnRelationship {
const factory SnRelationship({
required DateTime? createdAt,
required DateTime? updatedAt,

View File

@ -6,7 +6,7 @@ part 'sticker.freezed.dart';
part 'sticker.g.dart';
@freezed
abstract class SnSticker with _$SnSticker {
sealed class SnSticker with _$SnSticker {
const factory SnSticker({
required String id,
required String slug,
@ -24,7 +24,7 @@ abstract class SnSticker with _$SnSticker {
}
@freezed
abstract class SnStickerPack with _$SnStickerPack {
sealed class SnStickerPack with _$SnStickerPack {
const factory SnStickerPack({
required String id,
required String name,

View File

@ -5,7 +5,7 @@ part 'user.freezed.dart';
part 'user.g.dart';
@freezed
abstract class SnAccount with _$SnAccount {
sealed class SnAccount with _$SnAccount {
const factory SnAccount({
required String id,
required String name,
@ -24,7 +24,7 @@ abstract class SnAccount with _$SnAccount {
}
@freezed
abstract class SnAccountProfile with _$SnAccountProfile {
sealed class SnAccountProfile with _$SnAccountProfile {
const factory SnAccountProfile({
required String id,
required String? firstName,
@ -48,7 +48,7 @@ abstract class SnAccountProfile with _$SnAccountProfile {
}
@freezed
abstract class SnAccountStatus with _$SnAccountStatus {
sealed class SnAccountStatus with _$SnAccountStatus {
const factory SnAccountStatus({
required String id,
required int attitude,
@ -69,7 +69,7 @@ abstract class SnAccountStatus with _$SnAccountStatus {
}
@freezed
abstract class SnAccountBadge with _$SnAccountBadge {
sealed class SnAccountBadge with _$SnAccountBadge {
const factory SnAccountBadge({
required String id,
required String type,
@ -88,7 +88,7 @@ abstract class SnAccountBadge with _$SnAccountBadge {
}
@freezed
abstract class SnNotification with _$SnNotification {
sealed class SnNotification with _$SnNotification {
const factory SnNotification({
required DateTime createdAt,
required DateTime updatedAt,

View File

@ -5,7 +5,7 @@ part 'wallet.freezed.dart';
part 'wallet.g.dart';
@freezed
abstract class SnWallet with _$SnWallet {
sealed class SnWallet with _$SnWallet {
const factory SnWallet({
required String id,
required List<SnWalletPocket> pockets,
@ -21,7 +21,7 @@ abstract class SnWallet with _$SnWallet {
}
@freezed
abstract class SnWalletPocket with _$SnWalletPocket {
sealed class SnWalletPocket with _$SnWalletPocket {
const factory SnWalletPocket({
required String id,
required String currency,
@ -37,7 +37,7 @@ abstract class SnWalletPocket with _$SnWalletPocket {
}
@freezed
abstract class SnTransaction with _$SnTransaction {
sealed class SnTransaction with _$SnTransaction {
const factory SnTransaction({
required String id,
required String currency,