Surface/lib/types/chat.dart

37 lines
1.1 KiB
Dart
Raw Normal View History

2024-11-16 08:55:31 +00:00
import 'package:freezed_annotation/freezed_annotation.dart';
2024-11-16 13:15:55 +00:00
import 'package:hive_flutter/hive_flutter.dart';
2024-11-16 08:55:31 +00:00
import 'package:surface/types/realm.dart';
part 'chat.freezed.dart';
part 'chat.g.dart';
@freezed
class SnChannel with _$SnChannel {
2024-11-16 13:15:55 +00:00
const SnChannel._();
@HiveType(typeId: 2)
2024-11-16 08:55:31 +00:00
const factory SnChannel({
2024-11-16 13:15:55 +00:00
@HiveField(0) required int id,
@HiveField(1) required DateTime createdAt,
@HiveField(2) required DateTime updatedAt,
@HiveField(3) required dynamic deletedAt,
@HiveField(4) required String alias,
@HiveField(5) required String name,
@HiveField(6) required String description,
@HiveField(7) required List<dynamic> members,
dynamic messages,
dynamic calls,
@HiveField(8) required int type,
@HiveField(9) required int accountId,
@HiveField(10) required SnRealm? realm,
@HiveField(11) required int? realmId,
@HiveField(12) required bool isPublic,
@HiveField(13) required bool isCommunity,
2024-11-16 08:55:31 +00:00
}) = _SnChannel;
factory SnChannel.fromJson(Map<String, dynamic> json) =>
_$SnChannelFromJson(json);
2024-11-16 13:15:55 +00:00
String get key => '${realm?.alias ?? 'global'}:$alias';
2024-11-16 08:55:31 +00:00
}