Implemented room member and room info
In preperation for upcoming room screens. RoomInfo is supposed to be used in conjunction with the Room class. They are not merged (Room as a attribut in RoomInfo), because whilst Room can be stored on disk, RoomInfo can not. This is done to prevent tampering with the data (when offline). This also makes hiding elements easier when the user is offline, as we can just pretend, that they do not have the required permission.
This commit is contained in:
parent
48c15b244a
commit
7b23b12125
1 changed files with 45 additions and 0 deletions
|
@ -262,4 +262,49 @@ class Room {
|
|||
final db = Localstore.instance;
|
||||
await db.collection('rooms').doc('$id@$serverTag').set(toMap());
|
||||
}
|
||||
|
||||
static Future<Room> fromDisk({required String id, required String serverTag}) async {
|
||||
final db = Localstore.instance;
|
||||
final raw = await db.collection('rooms').doc('$id@$serverTag').get();
|
||||
return Room.fromMap(raw!);
|
||||
}
|
||||
}
|
||||
|
||||
class ShoppingListItem {
|
||||
|
||||
}
|
||||
|
||||
class RoomMember {
|
||||
final String id;
|
||||
final String serverTag;
|
||||
final bool isAdmin;
|
||||
|
||||
const RoomMember(
|
||||
{required this.id, required this.serverTag, required this.isAdmin});
|
||||
|
||||
factory RoomMember.fromJSON(dynamic json) {
|
||||
return RoomMember(
|
||||
id: json['name'], serverTag: json['server'], isAdmin: json['admin']);
|
||||
}
|
||||
}
|
||||
|
||||
class RoomInfo {
|
||||
final String owner;
|
||||
final bool isAdmin;
|
||||
final bool isOwner;
|
||||
final int permissions;
|
||||
|
||||
const RoomInfo(
|
||||
{required this.permissions,
|
||||
required this.owner,
|
||||
required this.isAdmin,
|
||||
required this.isOwner});
|
||||
|
||||
factory RoomInfo.fromJSON(dynamic json) {
|
||||
return RoomInfo(
|
||||
permissions: json['rights'],
|
||||
owner: json['owner'],
|
||||
isAdmin: json['isAdmin'],
|
||||
isOwner: json['isOwner']);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue