feat: Help with serializing and deserializing the BTVT manager

This commit is contained in:
2022-09-11 13:33:45 +02:00
parent 12e09947f6
commit ff52c82039
6 changed files with 172 additions and 3 deletions

View File

@@ -4,9 +4,24 @@ import 'package:meta/meta.dart';
class RatchetMapKey {
const RatchetMapKey(this.jid, this.deviceId);
factory RatchetMapKey.fromJsonKey(String key) {
final parts = key.split(':');
final deviceId = int.parse(parts.first);
return RatchetMapKey(
parts.sublist(1).join(':'),
deviceId,
);
}
final String jid;
final int deviceId;
String toJsonKey() {
return '$deviceId:$jid';
}
@override
bool operator ==(Object other) {
return other is RatchetMapKey && jid == other.jid && deviceId == other.deviceId;