Merge branch 'user-enhance-add-powerlevel' into 'master'

[User] Add powerLevel

See merge request famedly/famedlysdk!73
This commit is contained in:
Marcel 2019-09-03 16:02:13 +00:00
commit 055830fd78
2 changed files with 7 additions and 2 deletions

View file

@ -70,7 +70,9 @@ class Room {
Map<String, RoomAccountData> roomAccountData = {};
/// ID of the fully read marker event.
String get fullyRead => roomAccountData["m.fully_read"] != null ? roomAccountData["m.fully_read"].content["event_id"] : "";
String get fullyRead => roomAccountData["m.fully_read"] != null
? roomAccountData["m.fully_read"].content["event_id"]
: "";
/// If something changes, this callback will be triggered.
onRoomUpdate onUpdate;
@ -579,7 +581,7 @@ class Room {
return Event.fromJson(resp, this);
}
/// Returns the user's own power level.
/// Returns the power level of the given user ID.
int getPowerLevelByUserId(String userId) {
int powerLevel = 0;
RoomState powerLevelState = states["m.room.power_levels"];

View file

@ -83,6 +83,9 @@ class User extends RoomState {
/// The displayname of the user if the user has set one.
String get displayName => content != null ? content["displayname"] : null;
/// Returns the power level of this user.
int get powerLevel => room?.getPowerLevelByUserId(id);
/// The membership status of the user. One of:
/// join
/// invite