fix: Hotfix ignored user list
This commit is contained in:
parent
510de05304
commit
864cbfa906
|
@ -1529,9 +1529,9 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
|
||||||
/// A list of mxids of users who are ignored.
|
/// A list of mxids of users who are ignored.
|
||||||
List<String> get ignoredUsers => (accountData
|
List<String> get ignoredUsers => (accountData
|
||||||
.containsKey('m.ignored_user_list') &&
|
.containsKey('m.ignored_user_list') &&
|
||||||
accountData['m.ignored_user_list'].content['ignored_users'] is List)
|
accountData['m.ignored_user_list'].content['ignored_users'] is Map)
|
||||||
? List<String>.from(
|
? List<String>.from(
|
||||||
accountData['m.ignored_user_list'].content['ignored_users'])
|
accountData['m.ignored_user_list'].content['ignored_users'].keys)
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
/// Ignore another user. This will clear the local cached messages to
|
/// Ignore another user. This will clear the local cached messages to
|
||||||
|
@ -1540,11 +1540,10 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
|
||||||
if (!userId.isValidMatrixId) {
|
if (!userId.isValidMatrixId) {
|
||||||
throw Exception('$userId is not a valid mxid!');
|
throw Exception('$userId is not a valid mxid!');
|
||||||
}
|
}
|
||||||
await setAccountData(
|
await setAccountData(userID, 'm.ignored_user_list', {
|
||||||
userID,
|
'ignored_users': Map.fromEntries(
|
||||||
'm.ignored_user_list',
|
(ignoredUsers..add(userId)).map((key) => MapEntry(key, {}))),
|
||||||
{'ignored_users': ignoredUsers..add(userId)},
|
});
|
||||||
);
|
|
||||||
await clearLocalCachedMessages();
|
await clearLocalCachedMessages();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1558,11 +1557,10 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
|
||||||
if (!ignoredUsers.contains(userId)) {
|
if (!ignoredUsers.contains(userId)) {
|
||||||
throw Exception('$userId is not in the ignore list!');
|
throw Exception('$userId is not in the ignore list!');
|
||||||
}
|
}
|
||||||
await setAccountData(
|
await setAccountData(userID, 'm.ignored_user_list', {
|
||||||
userID,
|
'ignored_users': Map.fromEntries(
|
||||||
'm.ignored_user_list',
|
(ignoredUsers..remove(userId)).map((key) => MapEntry(key, {}))),
|
||||||
{'ignored_users': ignoredUsers..remove(userId)},
|
});
|
||||||
);
|
|
||||||
await clearLocalCachedMessages();
|
await clearLocalCachedMessages();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,7 +425,9 @@ void main() {
|
||||||
expect(matrix.ignoredUsers, []);
|
expect(matrix.ignoredUsers, []);
|
||||||
matrix.accountData['m.ignored_user_list'] =
|
matrix.accountData['m.ignored_user_list'] =
|
||||||
BasicEvent(type: 'm.ignored_user_list', content: {
|
BasicEvent(type: 'm.ignored_user_list', content: {
|
||||||
'ignored_users': ['@charley:stupid.abc']
|
'ignored_users': {
|
||||||
|
'@charley:stupid.abc': {},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
expect(matrix.ignoredUsers, ['@charley:stupid.abc']);
|
expect(matrix.ignoredUsers, ['@charley:stupid.abc']);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue