feat: Help with serializing and deserializing the BTVT manager
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user