2019-05-11 13:35:07 +00:00
|
|
|
import 'package:comunic/enums/likes_type.dart';
|
2020-04-18 13:24:57 +00:00
|
|
|
import 'package:comunic/helpers/websocket_helper.dart';
|
2019-05-11 13:35:07 +00:00
|
|
|
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
|
2020-04-18 13:24:57 +00:00
|
|
|
Future<void> setLiking({
|
2019-05-11 13:35:07 +00:00
|
|
|
@required LikesType type,
|
|
|
|
@required bool like,
|
|
|
|
@required int id,
|
|
|
|
}) async {
|
2020-04-18 13:24:57 +00:00
|
|
|
return (await ws("likes/update", {
|
|
|
|
"type": LikesAPIMap[type],
|
|
|
|
"like": like.toString(),
|
|
|
|
"id": id.toString(),
|
|
|
|
}));
|
2019-05-11 13:35:07 +00:00
|
|
|
}
|
|
|
|
}
|