refactor: Move pedantic to dev_dependencies
The unawaited method from the pedantic package was a historic solution for the case that you dont want to await a future in an async function. But now we can do this with just a comment which is the recommended way to do this now. This makes it possible to have pedantic as a dev_dependency which means just one dependency less.
This commit is contained in:
parent
45a2472fcd
commit
69b52ba85b
|
|
@ -19,7 +19,6 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:pedantic/pedantic.dart';
|
|
||||||
import 'package:olm/olm.dart' as olm;
|
import 'package:olm/olm.dart' as olm;
|
||||||
|
|
||||||
import '../matrix.dart';
|
import '../matrix.dart';
|
||||||
|
|
@ -106,26 +105,31 @@ class Encryption {
|
||||||
.contains(event.type)) {
|
.contains(event.type)) {
|
||||||
// "just" room key request things. We don't need these asap, so we handle
|
// "just" room key request things. We don't need these asap, so we handle
|
||||||
// them in the background
|
// them in the background
|
||||||
unawaited(runInRoot(() => keyManager.handleToDeviceEvent(event)));
|
// ignore: unawaited_futures
|
||||||
|
runInRoot(() => keyManager.handleToDeviceEvent(event));
|
||||||
}
|
}
|
||||||
if (event.type == EventTypes.Dummy) {
|
if (event.type == EventTypes.Dummy) {
|
||||||
// the previous device just had to create a new olm session, due to olm session
|
// the previous device just had to create a new olm session, due to olm session
|
||||||
// corruption. We want to try to send it the last message we just sent it, if possible
|
// corruption. We want to try to send it the last message we just sent it, if possible
|
||||||
unawaited(runInRoot(() => olmManager.handleToDeviceEvent(event)));
|
// ignore: unawaited_futures
|
||||||
|
runInRoot(() => olmManager.handleToDeviceEvent(event));
|
||||||
}
|
}
|
||||||
if (event.type.startsWith('m.key.verification.')) {
|
if (event.type.startsWith('m.key.verification.')) {
|
||||||
// some key verification event. No need to handle it now, we can easily
|
// some key verification event. No need to handle it now, we can easily
|
||||||
// do this in the background
|
// do this in the background
|
||||||
unawaited(
|
|
||||||
runInRoot(() => keyVerificationManager.handleToDeviceEvent(event)));
|
// ignore: unawaited_futures
|
||||||
|
runInRoot(() => keyVerificationManager.handleToDeviceEvent(event));
|
||||||
}
|
}
|
||||||
if (event.type.startsWith('m.secret.')) {
|
if (event.type.startsWith('m.secret.')) {
|
||||||
// some ssss thing. We can do this in the background
|
// some ssss thing. We can do this in the background
|
||||||
unawaited(runInRoot(() => ssss.handleToDeviceEvent(event)));
|
// ignore: unawaited_futures
|
||||||
|
runInRoot(() => ssss.handleToDeviceEvent(event));
|
||||||
}
|
}
|
||||||
if (event.sender == client.userID) {
|
if (event.sender == client.userID) {
|
||||||
// maybe we need to re-try SSSS secrets
|
// maybe we need to re-try SSSS secrets
|
||||||
unawaited(runInRoot(() => ssss.periodicallyRequestMissingCache()));
|
// ignore: unawaited_futures
|
||||||
|
runInRoot(() => ssss.periodicallyRequestMissingCache());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,14 +143,16 @@ class Encryption {
|
||||||
update.content['content']['msgtype']
|
update.content['content']['msgtype']
|
||||||
.startsWith('m.key.verification.'))) {
|
.startsWith('m.key.verification.'))) {
|
||||||
// "just" key verification, no need to do this in sync
|
// "just" key verification, no need to do this in sync
|
||||||
unawaited(
|
|
||||||
runInRoot(() => keyVerificationManager.handleEventUpdate(update)));
|
// ignore: unawaited_futures
|
||||||
|
runInRoot(() => keyVerificationManager.handleEventUpdate(update));
|
||||||
}
|
}
|
||||||
if (update.content['sender'] == client.userID &&
|
if (update.content['sender'] == client.userID &&
|
||||||
(!update.content.containsKey('unsigned') ||
|
(!update.content.containsKey('unsigned') ||
|
||||||
!update.content['unsigned'].containsKey('transaction_id'))) {
|
!update.content['unsigned'].containsKey('transaction_id'))) {
|
||||||
// maybe we need to re-try SSSS secrets
|
// maybe we need to re-try SSSS secrets
|
||||||
unawaited(runInRoot(() => ssss.periodicallyRequestMissingCache()));
|
// ignore: unawaited_futures
|
||||||
|
runInRoot(() => ssss.periodicallyRequestMissingCache());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ import 'dart:convert';
|
||||||
import 'package:canonical_json/canonical_json.dart';
|
import 'package:canonical_json/canonical_json.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'package:olm/olm.dart' as olm;
|
import 'package:olm/olm.dart' as olm;
|
||||||
import 'package:pedantic/pedantic.dart';
|
|
||||||
|
|
||||||
import '../encryption/utils/json_signature_check_extension.dart';
|
import '../encryption/utils/json_signature_check_extension.dart';
|
||||||
import 'encryption.dart';
|
import 'encryption.dart';
|
||||||
|
|
@ -502,8 +501,8 @@ class OlmManager {
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// okay, the thing errored while decrypting. It is safe to assume that the olm session is corrupt and we should generate a new one
|
// okay, the thing errored while decrypting. It is safe to assume that the olm session is corrupt and we should generate a new one
|
||||||
if (client.enableE2eeRecovery) {
|
if (client.enableE2eeRecovery) {
|
||||||
unawaited(
|
// ignore: unawaited_futures
|
||||||
runInRoot(() => restoreOlmSession(event.senderId, senderKey)));
|
runInRoot(() => restoreOlmSession(event.senderId, senderKey));
|
||||||
}
|
}
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:canonical_json/canonical_json.dart';
|
import 'package:canonical_json/canonical_json.dart';
|
||||||
import 'package:olm/olm.dart' as olm;
|
import 'package:olm/olm.dart' as olm;
|
||||||
import 'package:pedantic/pedantic.dart';
|
|
||||||
|
|
||||||
import '../../matrix.dart';
|
import '../../matrix.dart';
|
||||||
import '../encryption.dart';
|
import '../encryption.dart';
|
||||||
|
|
@ -457,8 +456,9 @@ class KeyVerification {
|
||||||
// no need to request cache, we already have it
|
// no need to request cache, we already have it
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
unawaited(encryption.ssss
|
// ignore: unawaited_futures
|
||||||
.maybeRequestAll(_verifiedDevices.whereType<DeviceKeys>().toList()));
|
encryption.ssss
|
||||||
|
.maybeRequestAll(_verifiedDevices.whereType<DeviceKeys>().toList());
|
||||||
if (requestInterval.length <= i) {
|
if (requestInterval.length <= i) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -500,7 +500,8 @@ class KeyVerification {
|
||||||
if (verifiedMasterKey && userId == client.userID) {
|
if (verifiedMasterKey && userId == client.userID) {
|
||||||
// it was our own master key, let's request the cross signing keys
|
// it was our own master key, let's request the cross signing keys
|
||||||
// we do it in the background, thus no await needed here
|
// we do it in the background, thus no await needed here
|
||||||
unawaited(maybeRequestSSSSSecrets());
|
// ignore: unawaited_futures
|
||||||
|
maybeRequestSSSSSecrets();
|
||||||
}
|
}
|
||||||
await send(EventTypes.KeyVerificationDone, {});
|
await send(EventTypes.KeyVerificationDone, {});
|
||||||
|
|
||||||
|
|
@ -510,7 +511,8 @@ class KeyVerification {
|
||||||
// these keys can be signed! Let's do so
|
// these keys can be signed! Let's do so
|
||||||
if (await encryption.crossSigning.isCached()) {
|
if (await encryption.crossSigning.isCached()) {
|
||||||
// and now let's sign them all in the background
|
// and now let's sign them all in the background
|
||||||
unawaited(encryption.crossSigning.sign(_verifiedDevices));
|
// ignore: unawaited_futures
|
||||||
|
encryption.crossSigning.sign(_verifiedDevices);
|
||||||
} else if (!wasUnknownSession) {
|
} else if (!wasUnknownSession) {
|
||||||
askingSSSS = true;
|
askingSSSS = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import 'dart:typed_data';
|
||||||
import 'package:matrix/src/utils/run_in_root.dart';
|
import 'package:matrix/src/utils/run_in_root.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:olm/olm.dart' as olm;
|
import 'package:olm/olm.dart' as olm;
|
||||||
import 'package:pedantic/pedantic.dart';
|
|
||||||
|
|
||||||
import '../encryption.dart';
|
import '../encryption.dart';
|
||||||
import '../matrix.dart';
|
import '../matrix.dart';
|
||||||
|
|
@ -677,7 +676,8 @@ class Client extends MatrixApi {
|
||||||
await super.setTyping(userId, roomId, typing, timeout: timeout);
|
await super.setTyping(userId, roomId, typing, timeout: timeout);
|
||||||
final room = getRoomById(roomId);
|
final room = getRoomById(roomId);
|
||||||
if (typing && room != null && encryptionEnabled && room.encrypted) {
|
if (typing && room != null && encryptionEnabled && room.encrypted) {
|
||||||
unawaited(encryption.keyManager.prepareOutboundGroupSession(roomId));
|
// ignore: unawaited_futures
|
||||||
|
encryption.keyManager.prepareOutboundGroupSession(roomId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1890,7 +1890,8 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
|
||||||
}
|
}
|
||||||
// now send out the background chunks
|
// now send out the background chunks
|
||||||
if (i < deviceKeys.length) {
|
if (i < deviceKeys.length) {
|
||||||
unawaited(() async {
|
// ignore: unawaited_futures
|
||||||
|
() async {
|
||||||
for (; i < deviceKeys.length; i += chunkSize) {
|
for (; i < deviceKeys.length; i += chunkSize) {
|
||||||
// wait 50ms to not freeze the UI
|
// wait 50ms to not freeze the UI
|
||||||
await Future.delayed(Duration(milliseconds: 50));
|
await Future.delayed(Duration(milliseconds: 50));
|
||||||
|
|
@ -1901,9 +1902,10 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
|
||||||
? deviceKeys.length
|
? deviceKeys.length
|
||||||
: i + chunkSize);
|
: i + chunkSize);
|
||||||
// and send
|
// and send
|
||||||
unawaited(sendToDeviceEncrypted(chunk, eventType, message));
|
// ignore: unawaited_futures
|
||||||
|
sendToDeviceEncrypted(chunk, eventType, message);
|
||||||
}
|
}
|
||||||
}());
|
}();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@ dependencies:
|
||||||
isolate: ^2.0.3
|
isolate: ^2.0.3
|
||||||
matrix_api_lite: ^0.3.3
|
matrix_api_lite: ^0.3.3
|
||||||
hive: ^2.0.4
|
hive: ^2.0.4
|
||||||
pedantic: ^1.11.0
|
|
||||||
ffi: ^1.0.0
|
ffi: ^1.0.0
|
||||||
js: ^0.6.3
|
js: ^0.6.3
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
pedantic: ^1.11.0
|
||||||
test: ^1.15.7
|
test: ^1.15.7
|
||||||
coverage: ">=0.15.0 <2.0.0"
|
coverage: ">=0.15.0 <2.0.0"
|
||||||
moor_generator: ^4.0.0
|
moor_generator: ^4.0.0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue