Hide markAsNsfw and markAsAd if user do not have permissions

This commit is contained in:
2024-02-08 09:55:06 +08:00
parent 04e73abe47
commit 91144bf8f1
5 changed files with 57 additions and 26 deletions

View File

@@ -6,9 +6,11 @@ part 'user.g.dart';
enum UserPermission with EnumFlag {
readGallery,
editGallery,
deleteGallery,
manageTasks,
}
const userPermissionAll = 3;
const userPermissionAll = 15;
class UserPermissions {
const UserPermissions(this.code);
@@ -25,7 +27,7 @@ class UserPermissions {
@override
String toString() {
if (code & userPermissionAll != 0) return "all";
if (code & userPermissionAll == userPermissionAll) return "all";
final set = code.getFlags(UserPermission.values).toSet();
if (set.isEmpty) return "none";
return set.map((e) => e.name).join("|");