Made chat messages deletable
This commit is contained in:
parent
2c10b02e53
commit
0f3fe75bad
22
lib/api/marianumcloud/talk/deleteMessage/deleteMessage.dart
Normal file
22
lib/api/marianumcloud/talk/deleteMessage/deleteMessage.dart
Normal file
@ -0,0 +1,22 @@
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../apiParams.dart';
|
||||
import '../talkApi.dart';
|
||||
|
||||
class DeleteMessage extends TalkApi {
|
||||
String chatToken;
|
||||
int messageId;
|
||||
DeleteMessage(this.chatToken, this.messageId) : super("v1/chat/$chatToken/$messageId", null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
|
||||
return http.delete(uri, headers: headers);
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,9 @@ import 'package:flowder/flowder.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:jiffy/jiffy.dart';
|
||||
import 'package:marianum_mobile/api/marianumcloud/talk/deleteMessage/deleteMessage.dart';
|
||||
import 'package:marianum_mobile/model/chatList/chatProps.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../api/marianumcloud/talk/chat/getChatResponse.dart';
|
||||
import '../../../api/marianumcloud/talk/room/getRoomResponse.dart';
|
||||
@ -184,6 +187,19 @@ class _ChatBubbleState extends State<ChatBubble> {
|
||||
onTap: () => {},
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: widget.isSender,
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.delete_outline),
|
||||
title: const Text("Nachricht löschen"),
|
||||
onTap: () {
|
||||
DeleteMessage(widget.chatData.token, widget.bubbleData.id).run().then((value) {
|
||||
Provider.of<ChatProps>(context, listen: false).run();
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
DebugTile(widget.bubbleData.toJson()).asTile(context),
|
||||
],
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user