Skip to content

Commit

Permalink
fixup! TW-1690: Add public room interactor
Browse files Browse the repository at this point in the history
  • Loading branch information
hieutbui committed May 3, 2024
1 parent ab96a3e commit c43ecb2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 20 deletions.
15 changes: 0 additions & 15 deletions lib/data/model/search/public_room_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,18 @@ class PublicRoomRequest with EquatableMixin {
@JsonKey(name: 'filter')
final PublicRoomQueryFilter? filter;

@JsonKey(name: 'include_all_networks')
final bool? includeAllNetworks;

@JsonKey(name: 'limit')
final int? limit;

@JsonKey(name: 'since')
final String? since;

@JsonKey(name: 'third_party_instance_id')
final String? thirdPartyInstanceId;

PublicRoomRequest({
this.filter,
this.includeAllNetworks = false,
this.limit,
this.since,
this.thirdPartyInstanceId,
});

@override
List<Object?> get props => [
filter,
includeAllNetworks,
limit,
since,
thirdPartyInstanceId,
];

factory PublicRoomRequest.fromJson(Map<String, dynamic> json) =>
Expand Down
2 changes: 1 addition & 1 deletion lib/data/model/search/public_room_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ part 'public_room_response.g.dart';
@JsonSerializable()
class PublicRoomResponse with EquatableMixin {
@JsonKey(name: 'chunk')
final PublicRoomsChunk chunk;
final List<PublicRoomsChunk> chunk;

@JsonKey(name: 'next_batch')
final String? nextBatch;
Expand Down
4 changes: 3 additions & 1 deletion lib/di/global/get_it_initializer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,9 @@ class GetItInitializer {
DownloadMediaFileInteractor(),
);

getIt.registerSingleton<PublicRoomInteractor>(PublicRoomInteractor());
getIt.registerFactory<PublicRoomInteractor>(
() => PublicRoomInteractor(),
);
}

void _bindingControllers() {
Expand Down
2 changes: 1 addition & 1 deletion lib/domain/app_state/search/public_room_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:fluffychat/app_state/success.dart';
import 'package:matrix/matrix.dart';

class PublicRoomSuccess extends Success {
final PublicRoomsChunk? publicRoomsChunk;
final List<PublicRoomsChunk>? publicRoomsChunk;

const PublicRoomSuccess({this.publicRoomsChunk});

Expand Down
7 changes: 5 additions & 2 deletions lib/domain/usecase/search/public_room_interactor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ class PublicRoomInteractor {
final PublicRoomRepository _publicRoomRepository =
getIt.get<PublicRoomRepository>();

Stream<Either<Failure, Success>> execute(
{PublicRoomQueryFilter? filter, String? server, int? limit}) async* {
Stream<Either<Failure, Success>> execute({
PublicRoomQueryFilter? filter,
String? server,
int? limit,
}) async* {
try {
final response = await _publicRoomRepository.search(
filter: filter,
Expand Down

0 comments on commit c43ecb2

Please sign in to comment.