insertClient method
Future<int>
insertClient(
- String name,
- String homeserverUrl,
- String token,
- DateTime? tokenExpiresAt,
- String? refreshToken,
- String userId,
- String? deviceId,
- String? deviceName,
- String? prevBatch,
- String? olmAccount,
override
Implementation
@override
Future<int> insertClient(
String name,
String homeserverUrl,
String token,
DateTime? tokenExpiresAt,
String? refreshToken,
String userId,
String? deviceId,
String? deviceName,
String? prevBatch,
String? olmAccount) async {
await transaction(() async {
await _clientBox.put('homeserver_url', homeserverUrl);
await _clientBox.put('token', token);
if (tokenExpiresAt == null) {
await _clientBox.delete('token_expires_at');
} else {
await _clientBox.put('token_expires_at',
tokenExpiresAt.millisecondsSinceEpoch.toString());
}
if (refreshToken == null) {
await _clientBox.delete('refresh_token');
} else {
await _clientBox.put('refresh_token', refreshToken);
}
await _clientBox.put('user_id', userId);
if (deviceId == null) {
await _clientBox.delete('device_id');
} else {
await _clientBox.put('device_id', deviceId);
}
if (deviceName == null) {
await _clientBox.delete('device_name');
} else {
await _clientBox.put('device_name', deviceName);
}
if (prevBatch == null) {
await _clientBox.delete('prev_batch');
} else {
await _clientBox.put('prev_batch', prevBatch);
}
if (olmAccount == null) {
await _clientBox.delete('olm_account');
} else {
await _clientBox.put('olm_account', olmAccount);
}
await _clientBox.delete('sync_filter_id');
});
return 0;
}