Skip to content

Commit 7186e87

Browse files
Merge pull request #196 from appwrite/dev
Fix for realtime subscriptions
2 parents 9dd03c8 + 17630f8 commit 7186e87

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+205
-155
lines changed

README.md

Lines changed: 1 addition & 1 deletion

lib/appwrite.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
library appwrite;
77

88
import 'dart:async';
9+
import 'dart:math';
910
import 'dart:typed_data';
1011
import 'dart:convert';
1112

lib/id.dart

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,37 @@
1-
part of appwrite;
1+
part of 'appwrite.dart';
22

33
/// Helper class to generate ID strings for resources.
44
class ID {
55
ID._();
66

7-
/// Have Appwrite generate a unique ID for you.
8-
static String unique() {
9-
return 'unique()';
7+
// Generate an hex ID based on timestamp
8+
// Recreated from https://www.php.net/manual/en/function.uniqid.php
9+
static String _hexTimestamp() {
10+
final now = DateTime.now();
11+
final sec = (now.millisecondsSinceEpoch / 1000).floor();
12+
final usec = now.microsecondsSinceEpoch - (sec * 1000000);
13+
return sec.toRadixString(16) +
14+
usec.toRadixString(16).padLeft(5, '0');
15+
}
16+
17+
// Generate a unique ID with padding to have a longer ID
18+
static String unique({int padding = 7}) {
19+
String id = _hexTimestamp();
20+
21+
if (padding > 0) {
22+
StringBuffer sb = StringBuffer();
23+
for (var i = 0; i < padding; i++) {
24+
sb.write(Random().nextInt(16).toRadixString(16));
25+
}
26+
27+
id += sb.toString();
28+
}
29+
30+
return id;
1031
}
1132

1233
/// Uses [id] as the ID for the resource.
1334
static String custom(String id) {
1435
return id;
1536
}
16-
}
37+
}

lib/permission.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
part of appwrite;
1+
part of 'appwrite.dart';
22

33
/// Helper class to generate permission strings for resources.
44
class Permission {

lib/query.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
part of appwrite;
1+
part of 'appwrite.dart';
22

33

44
/// Helper class to generate query strings.

lib/role.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
part of appwrite;
1+
part of 'appwrite.dart';
22

33
/// Helper class to generate role strings for [Permission].
44
class Role {

lib/services/account.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
part of appwrite;
1+
part of '../appwrite.dart';
22

33
/// The Account service allows you to authenticate and manage a user account.
44
class Account extends Service {
@@ -231,7 +231,7 @@ class Account extends Service {
231231
/// Delete Authenticator
232232
///
233233
/// Delete an authenticator for a user by ID.
234-
Future<models.User> deleteMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async {
234+
Future deleteMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async {
235235
final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value);
236236

237237
final Map<String, dynamic> apiParams = {
@@ -244,7 +244,7 @@ class Account extends Service {
244244

245245
final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders);
246246

247-
return models.User.fromMap(res.data);
247+
return res.data;
248248

249249
}
250250

lib/services/avatars.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
part of appwrite;
1+
part of '../appwrite.dart';
22

33
/// The Avatars service aims to help you complete everyday tasks related to
44
/// your app image, icons, and avatars.

lib/services/databases.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
part of appwrite;
1+
part of '../appwrite.dart';
22

33
/// The Databases service allows you to create structured collections of
44
/// documents, query and filter lists of documents

lib/services/functions.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
part of appwrite;
1+
part of '../appwrite.dart';
22

33
/// The Functions Service allows you view, create and manage your Cloud
44
/// Functions.

0 commit comments

Comments
 (0)