Added Chat context menu for chat 'mark as read', 'mark as unread', 'add to favorites', 'remove from favorites', 'leave conversation'
added Chat favorite badge and mark chat as read when entering it
This commit is contained in:
1 parent
16c251e4b1
commit
4ef21a362b
7 files changed
+239
-24
No files matched your search
@@ -0,0 +1,19 @@
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../talkApi.dart';
|
||||
class LeaveRoom extends TalkApi<void> {
|
||||
String chatToken;
|
||||
|
||||
LeaveRoom(this.chatToken) : super("v4/room/$chatToken/participants/self", null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
return http.delete(uri, headers: headers);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../talkApi.dart';
|
||||
|
||||
class SetFavorite extends TalkApi<void> {
|
||||
String chatToken;
|
||||
bool favoriteState;
|
||||
|
||||
SetFavorite(this.chatToken, this.favoriteState) : super("v4/room/$chatToken/favorite", null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
if(favoriteState) {
|
||||
return http.post(uri, headers: headers);
|
||||
} else {
|
||||
return http.delete(uri, headers: headers);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/http.dart';
|
||||
import 'package:marianum_mobile/api/marianumcloud/talk/setReadMarker/setReadMarkerParams.dart';
|
||||
|
||||
import '../talkApi.dart';
|
||||
|
||||
class SetReadMarker extends TalkApi<void> {
|
||||
String chatToken;
|
||||
bool readState;
|
||||
SetReadMarkerParams? setReadMarkerParams;
|
||||
|
||||
SetReadMarker(this.chatToken, this.readState, {this.setReadMarkerParams}) : super("v1/chat/$chatToken/read", null, getParameters: setReadMarkerParams?.toJson()) {
|
||||
if(readState) assert(setReadMarkerParams?.lastReadMessage != null);
|
||||
}
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
if(readState) {
|
||||
|
||||
return http.post(uri, headers: headers);
|
||||
} else {
|
||||
return http.delete(uri, headers: headers);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:marianum_mobile/api/apiParams.dart';
|
||||
|
||||
part 'setReadMarkerParams.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class SetReadMarkerParams extends ApiParams {
|
||||
int? lastReadMessage;
|
||||
|
||||
SetReadMarkerParams({
|
||||
this.lastReadMessage
|
||||
});
|
||||
|
||||
factory SetReadMarkerParams.fromJson(Map<String, dynamic> json) => _$SetReadMarkerParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$SetReadMarkerParamsToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'setReadMarkerParams.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
SetReadMarkerParams _$SetReadMarkerParamsFromJson(Map<String, dynamic> json) =>
|
||||
SetReadMarkerParams(
|
||||
lastReadMessage: json['lastReadMessage'] as int?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$SetReadMarkerParamsToJson(
|
||||
SetReadMarkerParams instance) =>
|
||||
<String, dynamic>{
|
||||
'lastReadMessage': instance.lastReadMessage,
|
||||
};
|
||||
Reference in new issue
Block a user