[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.

rm weird comment error handling

+17 -58
+1 -3
lib/src/core/network/atproto/data/adapters/bsky/feed_adapter.dart
··· 694 694 }).toList(); 695 695 696 696 // Convert each post 697 - for (final rawPost in rawPostsJson) { 698 - convertPostViewJson(rawPost); 699 - } 697 + rawPostsJson.forEach(convertPostViewJson); 700 698 701 699 // Parse and convert to Spark format 702 700 final parsedPosts = rawPostsJson.map(PostView.fromJson).toList();
+1 -1
lib/src/core/network/atproto/data/repositories/feed_repository_impl.dart
··· 262 262 return bskyFeedAdapter.processBskyAuthorFeed( 263 263 rawFeed: resultBsky.data.feed, 264 264 cursor: resultBsky.data.cursor, 265 - onError: (message, {error, stackTrace}) => _logger.e(message, error: error, stackTrace: stackTrace), 265 + onError: _logger.e, 266 266 ); 267 267 } catch (e) { 268 268 _logger.e('Error getting author feed from Bsky', error: e);
+15 -54
lib/src/features/comments/providers/comments_page_provider.dart
··· 17 17 final isBlueskyPost = postUri.collection.toString().startsWith('app.bsky.feed.post'); 18 18 const timeoutDuration = Duration(seconds: 30); 19 19 20 - // First attempt to get the thread directly with timeout 21 - try { 22 - final thread = await feedRepository 23 - .getThread(postUri, bluesky: isBlueskyPost, depth: 1) 24 - .timeout( 25 - timeoutDuration, 26 - onTimeout: () { 27 - throw Exception('Request timed out while loading thread for $postUri'); 28 - }, 29 - ); 30 - switch (thread) { 31 - case ThreadViewPost(): 32 - return CommentsPageState(thread: thread); 33 - case NotFoundPost(): 34 - throw Exception('Post not found'); 35 - case BlockedPost(): 36 - throw Exception('Post is blocked'); 37 - } 38 - } catch (firstError) { 39 - // If getThread fails, verify the post exists and retry once with timeout 40 - try { 41 - final networkPost = await feedRepository 42 - .getPosts([postUri], bluesky: isBlueskyPost, filter: false) 43 - .timeout( 44 - timeoutDuration, 45 - onTimeout: () { 46 - throw Exception('Request timed out while verifying post exists'); 47 - }, 48 - ); 49 - if (networkPost.isEmpty) { 50 - throw Exception('No posts found at $postUri'); 51 - } 52 - 53 - // Retry getThread once after confirming post exists 54 - final thread = await feedRepository 55 - .getThread(postUri, bluesky: isBlueskyPost, depth: 1) 56 - .timeout( 57 - timeoutDuration, 58 - onTimeout: () { 59 - throw Exception('Request timed out while retrying thread load for $postUri'); 60 - }, 61 - ); 62 - switch (thread) { 63 - case ThreadViewPost(): 64 - return CommentsPageState(thread: thread); 65 - case NotFoundPost(): 66 - throw Exception('Post not found'); 67 - case BlockedPost(): 68 - throw Exception('Post is blocked'); 69 - } 70 - } catch (_) { 71 - // Re-throw the original error to prevent infinite retry loops 72 - throw firstError; 73 - } 20 + final thread = await feedRepository 21 + .getThread(postUri, bluesky: isBlueskyPost, depth: 1) 22 + .timeout( 23 + timeoutDuration, 24 + onTimeout: () { 25 + throw Exception('Request timed out while loading thread for $postUri'); 26 + }, 27 + ); 28 + switch (thread) { 29 + case ThreadViewPost(): 30 + return CommentsPageState(thread: thread); 31 + case NotFoundPost(): 32 + throw Exception('Post not found'); 33 + case BlockedPost(): 34 + throw Exception('Post is blocked'); 74 35 } 75 36 } 76 37