Skip to content

Commit

Permalink
Device transfer (MixinNetwork#1122)
Browse files Browse the repository at this point in the history
* add protocol

* add

* improve crc check

* attachment

* attachment

* fix transfer data

* refactor

* add convert

* fix warning

* add DEVICE_TRANSFER plain

* fix

* fix warning

* link info

* device transfer

* handle received packet

* improve

* add participant and others

* refactor

* refactor

* fix

* folder

* improve ui

* send

* emit event

* improve

* add count support

* add tests

* add ui

* improve ui

* add more test

* fix test run

* fix format

* improve device transfer dialog

* improve style

* fix back button style

* connet command add userId

* improve

* confirm restore

* improve ui

* send participant first

* fix format

* improve

* i10n

* progress

* close server if verification code not match

* fix handle pin message

* improve style

* fix writePacketToSink

* decrease notify duration

* fix re login

* fix ci

* remove about

* add delay

* fix format

* improve test

* test

* improve ui

* add network server permission

* ensure sender progress

* test write file to system temp file

* improve

* fix receive file

* check primary session

* fix media duration type

* bump mixin_logger version

* add type command

* check command version

* replace with asyncListen

* fix process attachment if   message id duplicated

* fix message order

* improve _processPinMessage

* improve update conversation unseen count when insert message

* process transcript message

* fix format

* show device transfer menu bar on macOS in debug mode
  • Loading branch information
boyan01 authored Apr 11, 2023
1 parent 2c9ea0f commit 0617bfb
Show file tree
Hide file tree
Showing 103 changed files with 7,399 additions and 507 deletions.
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ analyzer:
- '**.g.dart'
# - 'editable/**'
- 'third_party/**'
- 'lib/constants/resources.preview.dart'

linter:
rules:
Expand Down
5 changes: 5 additions & 0 deletions assets/images/device_transfer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/images/transfer_from_phone.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/images/transfer_to_phone.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 31 additions & 2 deletions lib/blaze/vo/plain_json_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,34 @@ part 'plain_json_message.g.dart';

@JsonSerializable()
class PlainJsonMessage {
PlainJsonMessage(this.action, this.messages, this.userId, this.messageId,
this.sessionId, this.ackMessages);
PlainJsonMessage(
this.action,
this.messages,
this.userId,
this.messageId,
this.sessionId,
this.ackMessages, {
this.content,
});

factory PlainJsonMessage.create({
required String action,
List<String>? messages,
String? userId,
String? messageId,
String? sessionId,
List<BlazeAckMessage>? ackMessages,
String? content,
}) =>
PlainJsonMessage(
action,
messages,
userId,
messageId,
sessionId,
ackMessages,
content: content,
);

factory PlainJsonMessage.fromJson(Map<String, dynamic> json) =>
_$PlainJsonMessageFromJson(json);
Expand All @@ -24,5 +50,8 @@ class PlainJsonMessage {
@JsonKey(name: 'ack_messages')
List<BlazeAckMessage>? ackMessages;

@JsonKey(name: 'content')
String? content;

Map<String, dynamic> toJson() => _$PlainJsonMessageToJson(this);
}
2 changes: 2 additions & 0 deletions lib/blaze/vo/plain_json_message.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/constants/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const scpFull = 'FULL';

const kAcknowledgeMessageReceipt = 'ACKNOWLEDGE_MESSAGE_RECEIPT';
const kAcknowledgeMessageReceipts = 'ACKNOWLEDGE_MESSAGE_RECEIPTS';
const kDeviceTransfer = 'DEVICE_TRANSFER';
const kSendingMessage = 'SENDING_MESSAGE';
const kRecallMessage = 'RECALL_MESSAGE';
const kPinMessage = 'PIN_MESSAGE';
Expand Down
12 changes: 12 additions & 0 deletions lib/constants/resources.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions lib/db/dao/asset_dao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class AssetDao extends DatabaseAccessor<MixinDatabase> with _$AssetDaoMixin {
Future<int> insertSdkAsset(sdk.Asset asset) =>
into(db.assets).insertOnConflictUpdate(asset.asAssetsCompanion);

Future<int> insertAsset(Asset asset) =>
into(db.assets).insert(asset, mode: InsertMode.insertOrIgnore);

Future deleteAsset(Asset asset) => delete(db.assets).delete(asset);

Future<Asset?> findAssetById(String assetId) =>
Expand All @@ -49,4 +52,6 @@ class AssetDao extends DatabaseAccessor<MixinDatabase> with _$AssetDaoMixin {
select(db.assets)
..where((t) => t.assetId.equals(assetId))
..limit(1);

Future<List<Asset>> getAssets() => (select(db.assets)).get();
}
8 changes: 8 additions & 0 deletions lib/db/dao/asset_dao.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions lib/db/dao/conversation_dao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -501,4 +501,15 @@ class ConversationDao extends DatabaseAccessor<MixinDatabase>
}
return isBotConversation ? EncryptCategory.plain : EncryptCategory.signal;
}

Future<List<Conversation>> getConversations({
required int limit,
required int offset,
}) =>
(select(db.conversations)
..orderBy([
(c) => OrderingTerm.asc(c.rowId),
])
..limit(limit, offset: offset))
.get();
}
5 changes: 4 additions & 1 deletion lib/db/dao/expired_message_dao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:drift/drift.dart';
import '../../constants/constants.dart';
import '../../utils/extension/extension.dart';
import '../database_event_bus.dart';
import '../extension/db.dart';
import '../mixin_database.dart';

part 'expired_message_dao.g.dart';
Expand All @@ -21,13 +22,15 @@ class ExpiredMessageDao extends DatabaseAccessor<MixinDatabase>
required String messageId,
required int expireIn,
int? expireAt,
bool updateIfConflict = true,
}) async {
await into(db.expiredMessages).insertOnConflictUpdate(
await into(db.expiredMessages).simpleInsert(
ExpiredMessagesCompanion.insert(
messageId: messageId,
expireIn: expireIn,
expireAt: Value(expireAt),
),
updateIfConflict: updateIfConflict,
);
DataBaseEventBus.instance.updateExpiredMessageTable();
}
Expand Down
20 changes: 20 additions & 0 deletions lib/db/dao/expired_message_dao.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0617bfb

Please sign in to comment.