[READ ONLY MIRROR] Open Source TikTok alternative built on AT Protocol github.com/sprksocial/client
flutter atproto video dart
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: error handling and null safety pass

+31 -7
+11 -3
lib/src/core/auth/data/repositories/auth_repository_impl.dart
··· 139 139 ); 140 140 141 141 // Parse expiresAt, default to epoch if not found (will trigger refresh) 142 - final expiresAt = account.expiresAt != null 143 - ? DateTime.parse(account.expiresAt!) 144 - : DateTime.fromMillisecondsSinceEpoch(0); 142 + DateTime expiresAt; 143 + try { 144 + expiresAt = account.expiresAt != null 145 + ? DateTime.parse(account.expiresAt!) 146 + : DateTime.fromMillisecondsSinceEpoch(0); 147 + } catch (e) { 148 + _logger.w( 149 + 'Failed to parse expiresAt "${account.expiresAt}", defaulting to epoch', 150 + ); 151 + expiresAt = DateTime.fromMillisecondsSinceEpoch(0); 152 + } 145 153 146 154 _did = account.did; 147 155 _handle = account.handle;
+14 -4
lib/src/core/network/atproto/data/repositories/feed_repository_impl.dart
··· 67 67 68 68 for (final rawPost in rawPosts) { 69 69 try { 70 - final postData = rawPost is Map<String, dynamic> 71 - ? rawPost 72 - : rawPost.toJson(); 70 + final Map<String, dynamic> postData; 71 + if (rawPost is Map<String, dynamic>) { 72 + postData = rawPost; 73 + } else { 74 + final json = rawPost.toJson(); 75 + if (json is! Map<String, dynamic>) { 76 + _logger.w( 77 + 'Unexpected post data type: ${json.runtimeType}, skipping', 78 + ); 79 + continue; 80 + } 81 + postData = json; 82 + } 73 83 74 84 // Fix missing $type field for FeedViewPost union type 75 85 if ((postData[r'$type'] as String?) == null) { ··· 80 90 } 81 91 } 82 92 83 - final parsedPost = fromJson(postData as Map<String, dynamic>); 93 + final parsedPost = fromJson(postData); 84 94 85 95 if (hasMedia(parsedPost)) { 86 96 posts.add(parsedPost);
+6
lib/src/features/messages/providers/conversation_provider.dart
··· 18 18 // Load conversation and initial messages 19 19 final convo = await repo.getConversation(convoId); 20 20 final meDid = GetIt.I<AuthRepository>().did; 21 + 22 + // Handle edge case where conversation has no members 23 + if (convo.members.isEmpty) { 24 + throw StateError('Conversation $convoId has no members'); 25 + } 26 + 21 27 final other = convo.members.firstWhere( 22 28 (member) => member.did != meDid, 23 29 orElse: () => convo.members.first,