port to new cwtch storage API
continuous-integration/drone/pr Build is pending Details

This commit is contained in:
Dan Ballard 2021-12-10 15:37:08 -08:00
parent 3f5428eff8
commit 6180b88172
4 changed files with 15 additions and 5 deletions

View File

@ -292,7 +292,7 @@ class ProfileInfoState extends ChangeNotifier {
List<dynamic> servers = jsonDecode(serversJson);
this._servers.replace(servers.map((server) {
// TODO Keys...
return RemoteServerInfoState(onion: server["onion"], description: server["description"], status: server["status"]);
return RemoteServerInfoState(onion: server["onion"], identifier: server["identifier"], description: server["description"], status: server["status"]);
}));
this._contacts.contacts.forEach((contact) {

View File

@ -67,11 +67,12 @@ class ProfileServerListState extends ChangeNotifier {
class RemoteServerInfoState extends ChangeNotifier {
final String onion;
final int identifier;
String status;
String description;
List<ContactInfoState> _groups = [];
RemoteServerInfoState({required this.onion, required this.description, required this.status});
RemoteServerInfoState({required this.onion, required this.identifier, required this.description, required this.status});
void updateDescription(String newDescription) {
this.description = newDescription;

View File

@ -118,8 +118,17 @@ class _ProfileServersView extends State<ProfileServersView> {
// Wait 500ms and hope the server is imported and add it's description in the UI and as an attribute
Future.delayed(const Duration(milliseconds: 500), () {
var profile = Provider.of<ProfileInfoState>(context);
profile.serverList.getServer(serverHandle)?.updateDescription(serverDesc);
Provider.of<FlwtchState>(context, listen: false).cwtch.SetContactAttribute(profile.onion, serverHandle, "local.server.description", serverDesc);
if (profile.serverList.getServer(serverHandle) != null) {
profile.serverList.getServer(serverHandle)?.updateDescription(
serverDesc);
Provider
.of<FlwtchState>(context, listen: false)
.cwtch
.SetConversationAttribute(profile.onion, profile.serverList
.getServer(serverHandle)
!.identifier, "server.description", serverDesc);
}
});
Navigator.of(context).pop();
});

View File

@ -84,7 +84,7 @@ class _RemoteServerViewState extends State<RemoteServerView> {
labelText: AppLocalizations.of(context)!.fieldDescriptionLabel,
icon: Icon(Icons.save),
onPressed: () {
Provider.of<FlwtchState>(context, listen: false).cwtch.SetContactAttribute(profile.onion, serverInfoState.onion, "local.server.description", ctrlrDesc.text);
Provider.of<FlwtchState>(context, listen: false).cwtch.SetConversationAttribute(profile.onion, serverInfoState.identifier, "server.description", ctrlrDesc.text);
serverInfoState.updateDescription(ctrlrDesc.text);
},
),