mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
31 lines
691 B
Dart
31 lines
691 B
Dart
import 'package:flutter/foundation.dart';
|
|
|
|
import '../../shared/relay/nostr_models.dart';
|
|
|
|
/// A user's NIP-38 status (kind:30315, d=general).
|
|
@immutable
|
|
class UserStatus {
|
|
final String text;
|
|
final String emoji;
|
|
final int updatedAt;
|
|
|
|
const UserStatus({
|
|
required this.text,
|
|
required this.emoji,
|
|
required this.updatedAt,
|
|
});
|
|
|
|
factory UserStatus.fromEvent(NostrEvent event) {
|
|
final emojiTag = event.tags
|
|
.where((t) => t.length >= 2 && t[0] == 'emoji')
|
|
.firstOrNull;
|
|
return UserStatus(
|
|
text: event.content,
|
|
emoji: emojiTag?[1] ?? '',
|
|
updatedAt: event.createdAt,
|
|
);
|
|
}
|
|
|
|
bool get isEmpty => text.isEmpty && emoji.isEmpty;
|
|
}
|