forked from Nexus/nexus
add invite blocking support plus msc4494 support
To accomplish this I also reworked how account data is stored and added a method to fetch capabilities, and another method to set account data
This commit is contained in:
parent
115bec5f05
commit
f97c5548a3
11 changed files with 176 additions and 24 deletions
|
|
@ -1,16 +1,22 @@
|
|||
import "dart:convert";
|
||||
|
||||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||
import "package:nexus/models/account_data.dart";
|
||||
|
||||
class AccountDataController extends Notifier<IMap<String, AccountData>> {
|
||||
class AccountDataController extends Notifier<AccountData> {
|
||||
@override
|
||||
IMap<String, AccountData> build() => .new();
|
||||
AccountData build() => .new();
|
||||
|
||||
void update(IMap<String, AccountData> newData) =>
|
||||
state = .new({...state.unlock, ...newData.unlock});
|
||||
void update(IMap<String, IMap<String, dynamic>> newAccountData) =>
|
||||
state = .fromJson({
|
||||
...json.decode(json.encode(state.toJson())),
|
||||
...newAccountData
|
||||
.map((key, value) => MapEntry(key, value["content"]))
|
||||
.unlock,
|
||||
});
|
||||
|
||||
static final provider =
|
||||
NotifierProvider<AccountDataController, IMap<String, AccountData>>(
|
||||
AccountDataController.new,
|
||||
);
|
||||
static final provider = NotifierProvider<AccountDataController, AccountData>(
|
||||
AccountDataController.new,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue