relatica/lib/models/user_notification.dart

52 lines
1,013 B
Dart
Raw Normal View History

enum NotificationType {
favorite,
follow,
follow_request,
mention,
reshare,
status,
unknown;
static NotificationType parse(String? text) {
if (text == null) {
return unknown;
}
return NotificationType.values.firstWhere(
(e) => e.name == text,
orElse: () => unknown,
);
}
}
class UserNotification {
final String id;
final NotificationType type;
final String fromId;
final String fromName;
final String fromUrl;
final int timestamp;
final String iid;
final bool dismissed;
final String content;
final String link;
UserNotification({
required this.id,
required this.type,
required this.fromId,
required this.fromName,
required this.fromUrl,
required this.timestamp,
required this.iid,
required this.dismissed,
required this.content,
required this.link,
});
@override
String toString() {
return 'UserNotification{id: $id, seen: $dismissed, fromName: $fromName, content: $content}';
}
}