From 4556d08a0758a06425ba0ed4ce25a9339e4dfeb2 Mon Sep 17 00:00:00 2001 From: Nutcake Date: Tue, 30 May 2023 15:11:02 +0200 Subject: [PATCH 1/2] Remove debug user-list extension --- lib/widgets/session_view.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widgets/session_view.dart b/lib/widgets/session_view.dart index a31447a..e4f3a10 100644 --- a/lib/widgets/session_view.dart +++ b/lib/widgets/session_view.dart @@ -175,7 +175,7 @@ class SessionView extends StatelessWidget { ), ); }, - childCount: session.sessionUsers.length * 4, + childCount: session.sessionUsers.length, ), ) ], From fd5fa92be2828b6427f9125839251f457d2e7ca4 Mon Sep 17 00:00:00 2001 From: Nutcake Date: Sat, 3 Jun 2023 15:31:15 +0200 Subject: [PATCH 2/2] Add cloud variable api --- lib/apis/cloud_variable_api.dart | 27 ++++++++++++++++++++++++++ lib/models/cloud_variable.dart | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 lib/apis/cloud_variable_api.dart create mode 100644 lib/models/cloud_variable.dart diff --git a/lib/apis/cloud_variable_api.dart b/lib/apis/cloud_variable_api.dart new file mode 100644 index 0000000..d5f6cb7 --- /dev/null +++ b/lib/apis/cloud_variable_api.dart @@ -0,0 +1,27 @@ +import 'dart:convert'; + +import 'package:contacts_plus_plus/clients/api_client.dart'; +import 'package:contacts_plus_plus/models/cloud_variable.dart'; + +class CloudVariableApi { + static Future readCloudVariable(ApiClient client, + {required String ownerId, required String path,}) async { + final response = await client.get("/${ownerId.isEmpty ? "globalvars" : "users/$ownerId/vars"}/$path"); + client.checkResponse(response); + final body = jsonDecode(response.body); + return CloudVariable.fromMap(body); + } + + static Future readGlobalCloudVariable(ApiClient client, {required String path}) async => + await readCloudVariable(client, ownerId: "", path: path); + + static Future deleteCloudVariable(ApiClient client, {required String ownerId, required String path}) async { + final response = await client.delete("/users/vars/$path"); + client.checkResponse(response); + } + + static Future writeCloudVariable(ApiClient client, {required String ownerId, required String path, required String value}) async { + final response = await client.put("/users/$ownerId/vars/$path", body: value); + client.checkResponse(response); + } +} diff --git a/lib/models/cloud_variable.dart b/lib/models/cloud_variable.dart new file mode 100644 index 0000000..39c8901 --- /dev/null +++ b/lib/models/cloud_variable.dart @@ -0,0 +1,33 @@ +import 'package:contacts_plus_plus/auxiliary.dart'; + +class CloudVariable { + final String ownerId; + final String path; + final String value; + final String partitionKey; + final String rowKey; + final DateTime timestamp; + final String eTag; + + const CloudVariable({ + required this.ownerId, + required this.path, + required this.value, + required this.partitionKey, + required this.rowKey, + required this.timestamp, + required this.eTag, + }); + + factory CloudVariable.fromMap(Map map) { + return CloudVariable( + ownerId: map["ownerId"], + path: map["path"], + value: map["value"], + partitionKey: map["partitionKey"], + rowKey: map["rowKey"], + timestamp: DateTime.tryParse(map["timestamp"]) ?? DateTimeX.epoch, + eTag: map["eTag"], + ); + } +}