mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-29 08:16:28 +00:00
30 lines
647 B
Dart
30 lines
647 B
Dart
import 'package:comunic/enums/likes_type.dart';
|
|
import 'package:comunic/helpers/websocket_helper.dart';
|
|
import 'package:meta/meta.dart';
|
|
|
|
/// Likes helper
|
|
///
|
|
/// @author Pierre HUBERT
|
|
|
|
const LikesAPIMap = {
|
|
LikesType.USER: "user",
|
|
LikesType.POST: "post",
|
|
LikesType.COMMENT: "comment",
|
|
LikesType.GROUP: "group",
|
|
};
|
|
|
|
class LikesHelper {
|
|
/// Update liking status of an element
|
|
Future<void> setLiking({
|
|
@required LikesType type,
|
|
@required bool like,
|
|
@required int id,
|
|
}) async {
|
|
return (await ws("likes/update", {
|
|
"type": LikesAPIMap[type],
|
|
"like": like.toString(),
|
|
"id": id.toString(),
|
|
}));
|
|
}
|
|
}
|