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

refactor(messages): lexicon overhaul

+20 -24
+2 -1
lib/src/core/network/messages/data/models/message_models.dart
··· 1 1 import 'package:freezed_annotation/freezed_annotation.dart'; 2 + import 'package:spark/src/core/network/atproto/data/models/models.dart'; 2 3 3 4 part 'message_models.freezed.dart'; 4 5 part 'message_models.g.dart'; ··· 99 100 const factory ConvoView({ 100 101 required String id, 101 102 required String rev, 102 - required List<String> members, 103 + required List<ProfileViewBasic> members, 103 104 MessageView? lastMessage, 104 105 @Default('accepted') String status, 105 106 @Default(false) bool muted,
+9 -9
lib/src/core/network/messages/data/repository/messages_repository_xrpc.dart
··· 102 102 'readState': ?readState, 103 103 }; 104 104 105 - final data = await _callQuery('so.sprk.chat.convo.listConvos', params); 105 + final data = await _callQuery('so.sprk.chat.listConvos', params); 106 106 107 107 final convos = 108 108 (data['convos'] as List<dynamic>?) ··· 116 116 @override 117 117 Future<ConvoView> getConversation(String convoId) async { 118 118 final data = await _callQuery( 119 - 'so.sprk.chat.convo.getConvo', 119 + 'so.sprk.chat.getConvo', 120 120 {'convoId': convoId}, 121 121 ); 122 122 ··· 128 128 // Build URL with repeated members parameters 129 129 // Need to manually construct query string for repeated params 130 130 final baseUri = Uri.parse( 131 - '$_baseUrl/xrpc/so.sprk.chat.convo.getConvoForMembers', 131 + '$_baseUrl/xrpc/so.sprk.chat.getConvoForMembers', 132 132 ); 133 133 final queryParts = members 134 134 .map((m) => 'members=${Uri.encodeComponent(m)}') ··· 136 136 final url = Uri.parse('$baseUri?$queryParts'); 137 137 138 138 final token = await _serviceAuthHelper.getServiceToken( 139 - 'so.sprk.chat.convo.getConvoForMembers', 139 + 'so.sprk.chat.getConvoForMembers', 140 140 ); 141 141 142 142 final response = await http.get( ··· 169 169 'cursor': ?cursor, 170 170 }; 171 171 172 - final data = await _callQuery('so.sprk.chat.convo.getMessages', params); 172 + final data = await _callQuery('so.sprk.chat.getMessages', params); 173 173 174 174 final messages = 175 175 (data['messages'] as List<dynamic>?) ··· 196 196 }, 197 197 }; 198 198 199 - final data = await _callProcedure('so.sprk.chat.convo.sendMessage', body); 199 + final data = await _callProcedure('so.sprk.chat.sendMessage', body); 200 200 201 201 return MessageView.fromJson(data); 202 202 } ··· 213 213 'value': value, 214 214 }; 215 215 216 - final data = await _callProcedure('so.sprk.chat.convo.addReaction', body); 216 + final data = await _callProcedure('so.sprk.chat.addReaction', body); 217 217 218 218 return MessageView.fromJson(data); 219 219 } ··· 231 231 }; 232 232 233 233 final data = await _callProcedure( 234 - 'so.sprk.chat.convo.removeReaction', 234 + 'so.sprk.chat.removeReaction', 235 235 body, 236 236 ); 237 237 ··· 245 245 'messageId': messageId, 246 246 }; 247 247 248 - final data = await _callProcedure('so.sprk.chat.convo.updateRead', body); 248 + final data = await _callProcedure('so.sprk.chat.updateRead', body); 249 249 250 250 return ConvoView.fromJson(data['convo'] as Map<String, dynamic>); 251 251 }
+2 -5
lib/src/features/messages/providers/conversation_provider.dart
··· 1 1 import 'package:get_it/get_it.dart'; 2 2 import 'package:riverpod_annotation/riverpod_annotation.dart'; 3 3 import 'package:spark/src/core/auth/data/repositories/auth_repository.dart'; 4 - import 'package:spark/src/core/network/atproto/atproto.dart'; 5 4 import 'package:spark/src/core/network/messages/data/models/message_models.dart'; 6 5 import 'package:spark/src/core/network/messages/data/repository/messages_repository.dart'; 7 6 import 'package:spark/src/features/messages/providers/conversation_state.dart'; ··· 15 14 @override 16 15 FutureOr<ConversationState> build(String convoId) async { 17 16 final repo = GetIt.I<MessagesRepository>(); 18 - final sprk = GetIt.I<SprkRepository>(); 19 17 20 18 // Load conversation and initial messages 21 19 final convo = await repo.getConversation(convoId); 22 20 final meDid = GetIt.I<AuthRepository>().did; 23 - final otherDid = convo.members.firstWhere( 24 - (d) => d != meDid, 21 + final other = convo.members.firstWhere( 22 + (member) => member.did != meDid, 25 23 orElse: () => convo.members.first, 26 24 ); 27 - final other = await sprk.actor.getProfile(otherDid); 28 25 29 26 final result = await repo.getMessages(convoId, limit: 50); 30 27 _oldestCursor = result.cursor;
+1 -1
lib/src/features/messages/providers/conversation_state.dart
··· 8 8 abstract class ConversationState with _$ConversationState { 9 9 factory ConversationState({ 10 10 required ConvoView convo, 11 - required ProfileViewDetailed other, 11 + required ProfileViewBasic other, 12 12 required List<MessageView> messages, 13 13 String? cursor, 14 14 }) = _ConversationState;
+1 -1
lib/src/features/messages/providers/conversations._state.dart
··· 7 7 @freezed 8 8 abstract class ConversationsState with _$ConversationsState { 9 9 factory ConversationsState( 10 - List<(ProfileViewDetailed, ConvoView)> conversations, 10 + List<(ProfileViewBasic, ConvoView)> conversations, 11 11 ) = _ConversationsState; 12 12 }
+5 -7
lib/src/features/messages/providers/conversations_provider.dart
··· 1 1 import 'package:get_it/get_it.dart'; 2 2 import 'package:riverpod_annotation/riverpod_annotation.dart'; 3 3 import 'package:spark/src/core/auth/data/repositories/auth_repository.dart'; 4 - import 'package:spark/src/core/network/atproto/atproto.dart'; 4 + import 'package:spark/src/core/network/atproto/data/models/models.dart'; 5 5 import 'package:spark/src/core/network/messages/data/models/message_models.dart'; 6 6 import 'package:spark/src/core/network/messages/data/repository/messages_repository.dart'; 7 7 import 'package:spark/src/features/messages/providers/conversations._state.dart'; ··· 15 15 @override 16 16 FutureOr<ConversationsState> build() async { 17 17 final repo = GetIt.I<MessagesRepository>(); 18 - final sprk = GetIt.I<SprkRepository>(); 19 18 20 19 final res = await repo.listConversations(limit: 50); 21 20 cursor = res.cursor; 22 21 23 - // Resolve profiles for the counterpart in each convo 22 + // Pick counterpart profile from hydrated conversation members 24 23 final meDid = GetIt.I<AuthRepository>().did; 25 - final items = <(ProfileViewDetailed, ConvoView)>[]; 24 + final items = <(ProfileViewBasic, ConvoView)>[]; 26 25 for (final convo in res.conversations) { 27 - final otherDid = convo.members.firstWhere( 28 - (d) => d != meDid, 26 + final profile = convo.members.firstWhere( 27 + (member) => member.did != meDid, 29 28 orElse: () => convo.members.first, 30 29 ); 31 - final profile = await sprk.actor.getProfile(otherDid); 32 30 items.add((profile, convo)); 33 31 } 34 32