updated project style guidelines

This commit is contained in:
2024-04-03 19:18:17 +02:00
parent 27618f4404
commit 4c7f53e309
185 changed files with 505 additions and 873 deletions

View File

@ -14,13 +14,9 @@ class GetChat extends TalkApi<GetChatResponse> {
GetChat(this.chatToken, this.params) : super('v1/chat/$chatToken', null, getParameters: params.toJson());
@override
assemble(String raw) {
return GetChatResponse.fromJson(jsonDecode(raw)['ocs']);
}
assemble(String raw) => GetChatResponse.fromJson(jsonDecode(raw)['ocs']);
@override
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
return http.get(uri, headers: headers);
}
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
}
}

View File

@ -13,8 +13,7 @@ class GetChatCache extends RequestCache<GetChatResponse> {
}
@override
Future<GetChatResponse> onLoad() {
return GetChat(
Future<GetChatResponse> onLoad() => GetChat(
chatToken,
GetChatParams(
lookIntoFuture: GetChatParamsSwitch.off,
@ -22,11 +21,8 @@ class GetChatCache extends RequestCache<GetChatResponse> {
limit: 200,
)
).run();
}
@override
GetChatResponse onLocalData(String json) {
return GetChatResponse.fromJson(jsonDecode(json));
}
GetChatResponse onLocalData(String json) => GetChatResponse.fromJson(jsonDecode(json));
}
}

View File

@ -31,4 +31,4 @@ class GetChatParams extends ApiParams {
enum GetChatParamsSwitch {
@JsonValue(1) on,
@JsonValue(0) off,
}
}

View File

@ -16,7 +16,7 @@ class GetChatResponse extends ApiResponse {
Map<String, dynamic> toJson() => _$GetChatResponseToJson(this);
List<GetChatResponseObject> sortByTimestamp() {
List<GetChatResponseObject> sorted = data.toList();
var sorted = data.toList();
sorted.sort((a, b) => a.timestamp.compareTo(b.timestamp));
return sorted;
}
@ -60,12 +60,11 @@ class GetChatResponseObject {
Map<String, dynamic> toJson() => _$GetChatResponseObjectToJson(this);
static GetChatResponseObject getDateDummy(int timestamp) {
DateTime elementDate = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
var elementDate = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
return getTextDummy(Jiffy.parseFromDateTime(elementDate).format(pattern: 'dd.MM.yyyy'));
}
static GetChatResponseObject getTextDummy(String text) {
return GetChatResponseObject(
static GetChatResponseObject getTextDummy(String text) => GetChatResponseObject(
0,
'',
GetRoomResponseObjectMessageActorType.user,
@ -81,13 +80,12 @@ class GetChatResponseObject {
null,
null
);
}
}
Map<String, RichObjectString>? _fromJson(json) {
if(json is Map<String, dynamic>) {
Map<String, RichObjectString> data = {};
var data = <String, RichObjectString>{};
for (var element in json.keys) {
data.putIfAbsent(element, () => RichObjectString.fromJson(json[element]));
}
@ -119,4 +117,4 @@ enum RichObjectStringObjectType {
@JsonValue('guest') guest,
@JsonValue('highlight') highlight,
@JsonValue('talk-poll') talkPoll,
}
}

View File

@ -11,4 +11,4 @@ class RichObjectStringProcessor {
return message;
}
}
}