Merge branch 'user-enhance-add-powerlevel' into 'master'
[User] Add powerLevel See merge request famedly/famedlysdk!73
This commit is contained in:
commit
055830fd78
|
@ -70,7 +70,9 @@ class Room {
|
||||||
Map<String, RoomAccountData> roomAccountData = {};
|
Map<String, RoomAccountData> roomAccountData = {};
|
||||||
|
|
||||||
/// ID of the fully read marker event.
|
/// 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.
|
/// If something changes, this callback will be triggered.
|
||||||
onRoomUpdate onUpdate;
|
onRoomUpdate onUpdate;
|
||||||
|
@ -579,7 +581,7 @@ class Room {
|
||||||
return Event.fromJson(resp, this);
|
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 getPowerLevelByUserId(String userId) {
|
||||||
int powerLevel = 0;
|
int powerLevel = 0;
|
||||||
RoomState powerLevelState = states["m.room.power_levels"];
|
RoomState powerLevelState = states["m.room.power_levels"];
|
||||||
|
|
|
@ -83,6 +83,9 @@ class User extends RoomState {
|
||||||
/// The displayname of the user if the user has set one.
|
/// The displayname of the user if the user has set one.
|
||||||
String get displayName => content != null ? content["displayname"] : null;
|
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:
|
/// The membership status of the user. One of:
|
||||||
/// join
|
/// join
|
||||||
/// invite
|
/// invite
|
||||||
|
|
Loading…
Reference in a new issue