Files
Client/lib/share_intent/pending_share.dart
T

29 lines
947 B
Dart

class PendingShare {
final List<String> filePaths;
final String? text;
final DateTime receivedAt;
const PendingShare({
required this.filePaths,
required this.text,
required this.receivedAt,
});
bool get hasFiles => filePaths.isNotEmpty;
bool get hasText => text != null && text!.isNotEmpty;
bool get isEmpty => !hasFiles && !hasText;
/// True when [other] carries the same payload. The iOS Share Extension
/// fires two `open(url)` requests per share (see ShareViewController), so
/// the same share can arrive twice on the media stream — receivedAt is
/// deliberately ignored here so such duplicates compare equal.
bool contentEquals(PendingShare other) {
if (text != other.text) return false;
if (filePaths.length != other.filePaths.length) return false;
for (var i = 0; i < filePaths.length; i++) {
if (filePaths[i] != other.filePaths[i]) return false;
}
return true;
}
}