mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-02-23 01:30:41 +01:00
Client.setAccountBundle && Client.removeFromAccountBundle && Client.sendPrefix
This commit is contained in:
parent
1278b91eed
commit
7c40f72f55
@ -61,4 +61,37 @@ extension AccountBundlesExtension on Client {
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> setAccountBundle(String name, [int priority]) async {
|
||||||
|
final data = AccountBundles.fromJson(
|
||||||
|
accountData[_accountBundlesType]?.content ?? {});
|
||||||
|
var foundBundle = false;
|
||||||
|
for (final bundle in data.bundles) {
|
||||||
|
if (bundle.name == name) {
|
||||||
|
bundle.priority = priority;
|
||||||
|
foundBundle = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!foundBundle) {
|
||||||
|
data.bundles.add(AccountBundle(name: name, priority: priority));
|
||||||
|
}
|
||||||
|
await setAccountData(userID, _accountBundlesType, data.toJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> removeFromAccountBundle(String name) async {
|
||||||
|
if (!accountData.containsKey(_accountBundlesType)) {
|
||||||
|
return; // nothing to do
|
||||||
|
}
|
||||||
|
final data =
|
||||||
|
AccountBundles.fromJson(accountData[_accountBundlesType].content);
|
||||||
|
data.bundles.removeWhere((b) => b.name == name);
|
||||||
|
await setAccountData(userID, _accountBundlesType, data.toJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
String get sendPrefix {
|
||||||
|
final data = AccountBundles.fromJson(
|
||||||
|
accountData[_accountBundlesType]?.content ?? {});
|
||||||
|
return data.prefix;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user