claude refactorings, flutter best practices, platform dependent changes, general cleanup
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../talk_api.dart';
|
||||
import 'get_participants_response.dart';
|
||||
|
||||
class GetParticipants extends TalkApi<GetParticipantsResponse> {
|
||||
String token;
|
||||
GetParticipants(this.token) : super('v4/room/$token/participants', null);
|
||||
|
||||
@override
|
||||
GetParticipantsResponse assemble(String raw) {
|
||||
final decoded = jsonDecode(raw) as Map<String, dynamic>;
|
||||
return GetParticipantsResponse.fromJson(decoded['ocs'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import '../../../request_cache.dart';
|
||||
import 'get_participants.dart';
|
||||
import 'get_participants_response.dart';
|
||||
|
||||
class GetParticipantsCache extends SimpleCache<GetParticipantsResponse> {
|
||||
GetParticipantsCache({
|
||||
required void Function(GetParticipantsResponse) onUpdate,
|
||||
required String chatToken,
|
||||
}) : super(
|
||||
cacheTime: RequestCache.cacheNothing,
|
||||
loader: () => GetParticipants(chatToken).run(),
|
||||
fromJson: GetParticipantsResponse.fromJson,
|
||||
onUpdate: onUpdate,
|
||||
) {
|
||||
start('nc-chat-participants-$chatToken');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../../../api_response.dart';
|
||||
|
||||
part 'get_participants_response.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class GetParticipantsResponse extends ApiResponse {
|
||||
Set<GetParticipantsResponseObject> data;
|
||||
|
||||
GetParticipantsResponse(this.data);
|
||||
|
||||
factory GetParticipantsResponse.fromJson(Map<String, dynamic> json) => _$GetParticipantsResponseFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetParticipantsResponseToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class GetParticipantsResponseObject {
|
||||
int attendeeId;
|
||||
String actorType;
|
||||
String actorId;
|
||||
String displayName;
|
||||
GetParticipantsResponseObjectParticipantType participantType;
|
||||
int lastPing;
|
||||
GetParticipantsResponseObjectParticipantsInCallFlags inCall;
|
||||
int permissions;
|
||||
int attendeePermissions;
|
||||
String? sessionId;
|
||||
List<String> sessionIds;
|
||||
String? status;
|
||||
String? statusIcon;
|
||||
String? statusMessage;
|
||||
String? roomToken;
|
||||
|
||||
GetParticipantsResponseObject(
|
||||
this.attendeeId,
|
||||
this.actorType,
|
||||
this.actorId,
|
||||
this.displayName,
|
||||
this.participantType,
|
||||
this.lastPing,
|
||||
this.inCall,
|
||||
this.permissions,
|
||||
this.attendeePermissions,
|
||||
this.sessionId,
|
||||
this.sessionIds,
|
||||
this.status,
|
||||
this.statusIcon,
|
||||
this.statusMessage,
|
||||
this.roomToken);
|
||||
|
||||
factory GetParticipantsResponseObject.fromJson(Map<String, dynamic> json) => _$GetParticipantsResponseObjectFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetParticipantsResponseObjectToJson(this);
|
||||
}
|
||||
|
||||
enum GetParticipantsResponseObjectParticipantType {
|
||||
@JsonValue(1) owner('Besitzer'),
|
||||
@JsonValue(2) moderator('Moderator'),
|
||||
@JsonValue(3) user('Teilnehmer'),
|
||||
@JsonValue(4) guest('Gast'),
|
||||
@JsonValue(5) userFollowingPublicLink('Teilnehmer über Link'),
|
||||
@JsonValue(6) guestWithModeratorPermissions('Gast Moderator');
|
||||
|
||||
const GetParticipantsResponseObjectParticipantType(this.prettyName);
|
||||
final String prettyName;
|
||||
}
|
||||
|
||||
enum GetParticipantsResponseObjectParticipantsInCallFlags {
|
||||
@JsonValue(0) disconnected,
|
||||
@JsonValue(1) inCall,
|
||||
@JsonValue(2) providesAudio,
|
||||
@JsonValue(3) providesVideo,
|
||||
@JsonValue(4) usesSipDialIn
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'get_participants_response.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
GetParticipantsResponse _$GetParticipantsResponseFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) =>
|
||||
GetParticipantsResponse(
|
||||
(json['data'] as List<dynamic>)
|
||||
.map(
|
||||
(e) => GetParticipantsResponseObject.fromJson(
|
||||
e as Map<String, dynamic>,
|
||||
),
|
||||
)
|
||||
.toSet(),
|
||||
)
|
||||
..headers = (json['headers'] as Map<String, dynamic>?)?.map(
|
||||
(k, e) => MapEntry(k, e as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetParticipantsResponseToJson(
|
||||
GetParticipantsResponse instance,
|
||||
) => <String, dynamic>{
|
||||
'headers': ?instance.headers,
|
||||
'data': instance.data.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
|
||||
GetParticipantsResponseObject _$GetParticipantsResponseObjectFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => GetParticipantsResponseObject(
|
||||
(json['attendeeId'] as num).toInt(),
|
||||
json['actorType'] as String,
|
||||
json['actorId'] as String,
|
||||
json['displayName'] as String,
|
||||
$enumDecode(
|
||||
_$GetParticipantsResponseObjectParticipantTypeEnumMap,
|
||||
json['participantType'],
|
||||
),
|
||||
(json['lastPing'] as num).toInt(),
|
||||
$enumDecode(
|
||||
_$GetParticipantsResponseObjectParticipantsInCallFlagsEnumMap,
|
||||
json['inCall'],
|
||||
),
|
||||
(json['permissions'] as num).toInt(),
|
||||
(json['attendeePermissions'] as num).toInt(),
|
||||
json['sessionId'] as String?,
|
||||
(json['sessionIds'] as List<dynamic>).map((e) => e as String).toList(),
|
||||
json['status'] as String?,
|
||||
json['statusIcon'] as String?,
|
||||
json['statusMessage'] as String?,
|
||||
json['roomToken'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetParticipantsResponseObjectToJson(
|
||||
GetParticipantsResponseObject instance,
|
||||
) => <String, dynamic>{
|
||||
'attendeeId': instance.attendeeId,
|
||||
'actorType': instance.actorType,
|
||||
'actorId': instance.actorId,
|
||||
'displayName': instance.displayName,
|
||||
'participantType':
|
||||
_$GetParticipantsResponseObjectParticipantTypeEnumMap[instance
|
||||
.participantType]!,
|
||||
'lastPing': instance.lastPing,
|
||||
'inCall':
|
||||
_$GetParticipantsResponseObjectParticipantsInCallFlagsEnumMap[instance
|
||||
.inCall]!,
|
||||
'permissions': instance.permissions,
|
||||
'attendeePermissions': instance.attendeePermissions,
|
||||
'sessionId': instance.sessionId,
|
||||
'sessionIds': instance.sessionIds,
|
||||
'status': instance.status,
|
||||
'statusIcon': instance.statusIcon,
|
||||
'statusMessage': instance.statusMessage,
|
||||
'roomToken': instance.roomToken,
|
||||
};
|
||||
|
||||
const _$GetParticipantsResponseObjectParticipantTypeEnumMap = {
|
||||
GetParticipantsResponseObjectParticipantType.owner: 1,
|
||||
GetParticipantsResponseObjectParticipantType.moderator: 2,
|
||||
GetParticipantsResponseObjectParticipantType.user: 3,
|
||||
GetParticipantsResponseObjectParticipantType.guest: 4,
|
||||
GetParticipantsResponseObjectParticipantType.userFollowingPublicLink: 5,
|
||||
GetParticipantsResponseObjectParticipantType.guestWithModeratorPermissions: 6,
|
||||
};
|
||||
|
||||
const _$GetParticipantsResponseObjectParticipantsInCallFlagsEnumMap = {
|
||||
GetParticipantsResponseObjectParticipantsInCallFlags.disconnected: 0,
|
||||
GetParticipantsResponseObjectParticipantsInCallFlags.inCall: 1,
|
||||
GetParticipantsResponseObjectParticipantsInCallFlags.providesAudio: 2,
|
||||
GetParticipantsResponseObjectParticipantsInCallFlags.providesVideo: 3,
|
||||
GetParticipantsResponseObjectParticipantsInCallFlags.usesSipDialIn: 4,
|
||||
};
|
||||
Reference in New Issue
Block a user