dart format

This commit is contained in:
2026-05-08 20:12:40 +02:00
parent 9e139b5704
commit 3b8da1d3d6
295 changed files with 6404 additions and 4161 deletions
@@ -6,13 +6,10 @@ import '../talk_api.dart';
import 'get_room_params.dart';
import 'get_room_response.dart';
class GetRoom extends TalkApi<GetRoomResponse> {
GetRoomParams params;
GetRoom(this.params) : super('v4/room', null, getParameters: params.toJson());
@override
GetRoomResponse assemble(String raw) {
final decoded = jsonDecode(raw) as Map<String, dynamic>;
@@ -20,6 +17,9 @@ class GetRoom extends TalkApi<GetRoomResponse> {
}
@override
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
Future<http.Response> request(
Uri uri,
Object? body,
Map<String, String>? headers,
) => http.get(uri, headers: headers);
}
@@ -5,11 +5,11 @@ import 'get_room_response.dart';
class GetRoomCache extends SimpleCache<GetRoomResponse> {
GetRoomCache({super.onUpdate, super.onError, super.renew})
: super(
cacheTime: RequestCache.cacheMinute,
loader: () => GetRoom(GetRoomParams(includeStatus: true)).run(),
fromJson: GetRoomResponse.fromJson,
) {
: super(
cacheTime: RequestCache.cacheMinute,
loader: () => GetRoom(GetRoomParams(includeStatus: true)).run(),
fromJson: GetRoomResponse.fromJson,
) {
start('nc-rooms');
}
}
@@ -1,4 +1,3 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../api_params.dart';
@@ -8,18 +7,22 @@ part 'get_room_params.g.dart';
@JsonSerializable(explicitToJson: true)
class GetRoomParams extends ApiParams {
GetRoomParamsStatusUpdate? noStatusUpdate;
@JsonKey(toJson: _format) bool? includeStatus;
@JsonKey(toJson: _format)
bool? includeStatus;
int? modifiedSince;
GetRoomParams({this.noStatusUpdate, this.includeStatus, this.modifiedSince});
factory GetRoomParams.fromJson(Map<String, dynamic> json) => _$GetRoomParamsFromJson(json);
factory GetRoomParams.fromJson(Map<String, dynamic> json) =>
_$GetRoomParamsFromJson(json);
Map<String, dynamic> toJson() => _$GetRoomParamsToJson(this);
static String _format(bool? v) => v.toString();
}
enum GetRoomParamsStatusUpdate {
@JsonValue(0) defaults,
@JsonValue(1) keepAlive,
@JsonValue(0)
defaults,
@JsonValue(1)
keepAlive,
}
@@ -11,17 +11,22 @@ class GetRoomResponse extends ApiResponse {
GetRoomResponse(this.data);
factory GetRoomResponse.fromJson(Map<String, dynamic> json) => _$GetRoomResponseFromJson(json);
factory GetRoomResponse.fromJson(Map<String, dynamic> json) =>
_$GetRoomResponseFromJson(json);
Map<String, dynamic> toJson() => _$GetRoomResponseToJson(this);
List<GetRoomResponseObject> sortBy({bool lastActivity = true, required bool favoritesToTop, required bool unreadToTop}) {
List<GetRoomResponseObject> sortBy({
bool lastActivity = true,
required bool favoritesToTop,
required bool unreadToTop,
}) {
for (var chat in data) {
final buffer = StringBuffer();
if(favoritesToTop) {
if (favoritesToTop) {
buffer.write(chat.isFavorite ? 'b' : 'a');
}
if(unreadToTop) {
if (unreadToTop) {
buffer.write(chat.unreadMessages > 0 ? 'b' : 'a');
}
@@ -69,69 +74,91 @@ class GetRoomResponseObject {
String? sort;
GetRoomResponseObject(
this.id,
this.token,
this.type,
this.name,
this.displayName,
this.description,
this.participantType,
this.participantFlags,
this.readOnly,
this.listable,
this.lastPing,
this.sessionId,
this.hasPassword,
this.hasCall,
this.callFlag,
this.canStartCall,
this.canDeleteConversation,
this.canLeaveConversation,
this.lastActivity,
this.isFavorite,
this.notificationLevel,
this.unreadMessages,
this.unreadMention,
this.unreadMentionDirect,
this.lastReadMessage,
this.lastCommonReadMessage,
this.lastMessage,
this.status,
this.statusIcon,
this.statusMessage);
this.id,
this.token,
this.type,
this.name,
this.displayName,
this.description,
this.participantType,
this.participantFlags,
this.readOnly,
this.listable,
this.lastPing,
this.sessionId,
this.hasPassword,
this.hasCall,
this.callFlag,
this.canStartCall,
this.canDeleteConversation,
this.canLeaveConversation,
this.lastActivity,
this.isFavorite,
this.notificationLevel,
this.unreadMessages,
this.unreadMention,
this.unreadMentionDirect,
this.lastReadMessage,
this.lastCommonReadMessage,
this.lastMessage,
this.status,
this.statusIcon,
this.statusMessage,
);
factory GetRoomResponseObject.fromJson(Map<String, dynamic> json) => _$GetRoomResponseObjectFromJson(json);
factory GetRoomResponseObject.fromJson(Map<String, dynamic> json) =>
_$GetRoomResponseObjectFromJson(json);
Map<String, dynamic> toJson() => _$GetRoomResponseObjectToJson(this);
}
enum GetRoomResponseObjectConversationType {
@JsonValue(1) oneToOne,
@JsonValue(2) group,
@JsonValue(3) public,
@JsonValue(4) changelog,
@JsonValue(5) deleted,
@JsonValue(6) noteToSelf,
@JsonValue(1)
oneToOne,
@JsonValue(2)
group,
@JsonValue(3)
public,
@JsonValue(4)
changelog,
@JsonValue(5)
deleted,
@JsonValue(6)
noteToSelf,
}
enum GetRoomResponseObjectParticipantNotificationLevel {
@JsonValue(0) defaultLevel,
@JsonValue(1) alwaysNotify,
@JsonValue(2) notifyOnMention,
@JsonValue(3) neverNotify,
@JsonValue(0)
defaultLevel,
@JsonValue(1)
alwaysNotify,
@JsonValue(2)
notifyOnMention,
@JsonValue(3)
neverNotify,
}
enum GetRoomResponseObjectMessageActorType {
@JsonValue('deleted_users') deletedUsers,
@JsonValue('users') user,
@JsonValue('guests') guest,
@JsonValue('bots') bot,
@JsonValue('bridged') bridge,
@JsonValue('deleted_users')
deletedUsers,
@JsonValue('users')
user,
@JsonValue('guests')
guest,
@JsonValue('bots')
bot,
@JsonValue('bridged')
bridge,
}
enum GetRoomResponseObjectMessageType {
@JsonValue('comment') comment,
@JsonValue('voice-message') voiceMessage,
@JsonValue('comment_deleted') deletedComment,
@JsonValue('system') system,
@JsonValue('command') command,
@JsonValue('comment')
comment,
@JsonValue('voice-message')
voiceMessage,
@JsonValue('comment_deleted')
deletedComment,
@JsonValue('system')
system,
@JsonValue('command')
command,
}