Skip to content
This repository has been archived by the owner on Oct 29, 2021. It is now read-only.

Commit

Permalink
♻️: refactored redundant jsonDecoding logic in ClipboardValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Pushpavel committed Sep 3, 2021
1 parent 57807ca commit b5d55e3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/logic/models/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ String encodeClipboardValue(ClipboardValue value) {
return jsonEncode(json);
}

ClipboardValue decodeClipboardValue(String jsonString) {
final json = getJsonMessage("ClipboardValue", utf8.encode(jsonString));
ClipboardValue decodeClipboardValue(List<int> bytes) {
final json = getJsonMessage("ClipboardValue", bytes);
return ClipboardValue(json['value'], DateTime.fromMillisecondsSinceEpoch(json['timestamp']));
}

Expand Down
3 changes: 1 addition & 2 deletions lib/logic/network/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ handleClient(Socket socket) async {

socket.listen((event) {
pause = true;
final value = String.fromCharCodes(event);
final clipboardValue = decodeClipboardValue(value);
final clipboardValue = decodeClipboardValue(event);
if (clipboard.value.value != clipboardValue.value &&
clipboardValue.timestamp.compareTo(clipboardValue.timestamp) >= 0) {
clipboard.value = clipboardValue;
Expand Down

0 comments on commit b5d55e3

Please sign in to comment.