Skip to content

Commit 6493411

Browse files
committed
fix create group in mobile
1 parent a3ddf7b commit 6493411

File tree

9 files changed

+44
-22
lines changed

9 files changed

+44
-22
lines changed

lib/apps/group/add.dart

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,24 @@ class _GroupAddScreenState extends State<GroupAddScreen> {
3838
_send(String name, bool isDesktop) async {
3939
final res = await httpPost('group-create', [name]);
4040
if (res.isOk) {
41-
print(res.params);
42-
final id = res.params[0];
43-
final w = GroupChatDetail(id: id);
44-
if (w != null) {
45-
if (isDesktop) {
46-
Provider.of<AccountProvider>(context, listen: false).updateActivedWidget(w);
47-
rpc.send('group-member-join', [id, widget.fid]);
48-
} else {
49-
Navigator.push(context, MaterialPageRoute(builder: (_) => w));
50-
}
51-
}
52-
Navigator.pop(context);
41+
// use delayed because waiting this session added.
42+
Future.delayed(Duration(seconds: 1), () async {
43+
final fid = widget.fid;
44+
Navigator.pop(context);
45+
final sid = res.params[0];
46+
final id = res.params[1];
47+
final w = GroupChatDetail(id: id);
48+
rpc.send('group-member-join', [id, fid]);
49+
Provider.of<AccountProvider>(context, listen: false).updateActivedSession(sid);
50+
if (w != null) {
51+
if (isDesktop) {
52+
Provider.of<AccountProvider>(context, listen: false).updateActivedWidget(w);
53+
} else {
54+
Navigator.pop(context);
55+
Navigator.push(context, MaterialPageRoute(builder: (_) => w));
56+
}
57+
}
58+
});
5359
} else {
5460
setState(() {
5561
this._error = res.error;

lib/apps/group/detail.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ class _GroupChatDetailState extends State<GroupChatDetail> {
289289
final msg = this._messages[recentMessageKeys[index]]!;
290290
return ChatMessage(
291291
avatar: this._members[msg.mid]!.showAvatar(isOnline: false),
292-
fgid: this._group.gid,
293-
name: this._group.name,
292+
fgid: this._members[msg.mid]!.mid,
293+
name: this._members[msg.mid]!.name,
294294
message: msg,
295295
);
296296
}

lib/apps/wallet/page.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class _WalletDetailState extends State<WalletDetail> with SingleTickerProviderSt
211211
children: [
212212
const Icon(Icons.lock),
213213
const SizedBox(width: 8.0),
214-
const Text('生成以太坊地址'),
214+
Text(lang.walletGenerate),
215215
]
216216
)
217217
)
@@ -478,7 +478,7 @@ class _WalletDetailState extends State<WalletDetail> with SingleTickerProviderSt
478478
unselectedLabelColor: color.onSurface,
479479
labelColor: Color(0xFF6174FF),
480480
tabs: [
481-
Tab(text: 'Assets'),
481+
Tab(text: 'Tokens'),
482482
Tab(text: 'Activity'),
483483
],
484484
controller: _tabController!,
@@ -496,7 +496,7 @@ class _WalletDetailState extends State<WalletDetail> with SingleTickerProviderSt
496496
return TextButton(
497497
child: Padding(
498498
padding: const EdgeInsets.symmetric(vertical: 10.0),
499-
child: Text('Add new Token' + ' ( ERC20 / ERC721 )')
499+
child: Text('Add Token' + ' ( ERC20 / ERC721 )')
500500
),
501501
onPressed: () => showShadowDialog(
502502
context, Icons.paid, 'Token', _ImportToken(
@@ -982,7 +982,7 @@ class _TransferTokenState extends State<_TransferToken> {
982982
children: [
983983
const SizedBox(width: 10.0),
984984
TextButton(child: Text(
985-
this._myAccount ? 'Input Account' : 'Between Accounts'
985+
this._myAccount ? lang.walletInputAccount: lang.walletBetweenAccount,
986986
), onPressed: () => setState(() {
987987
this._myAccount = !this._myAccount;
988988
if (this._selectAddress.length == 0) {

lib/l10n/localizations.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ abstract class AppLocalizations {
267267

268268
String get wallet;
269269
String get walletIntro;
270+
String get walletGenerate;
271+
String get walletInputAccount;
272+
String get walletBetweenAccount;
270273
String get secretKey;
271274
String get contract;
272275
String get main;

lib/l10n/localizations_en.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,12 @@ class AppLocalizationsEn extends AppLocalizations {
438438
@override
439439
String get walletIntro => 'Manage your own cryptocurrency.';
440440
@override
441+
String get walletGenerate => 'Generate ETH account';
442+
@override
443+
String get walletInputAccount => 'Input Account';
444+
@override
445+
String get walletBetweenAccount => 'Between Accounts';
446+
@override
441447
String get secretKey => 'Secret Key';
442448
@override
443449
String get contract => 'Contract Address';

lib/l10n/localizations_zh.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,12 @@ class AppLocalizationsZh extends AppLocalizations {
438438
@override
439439
String get walletIntro => '管理自己的加密货币。';
440440
@override
441+
String get walletGenerate => '生成以太坊地址';
442+
@override
443+
String get walletInputAccount => '输入对方账号';
444+
@override
445+
String get walletBetweenAccount => '自己账户之间';
446+
@override
441447
String get secretKey => '私钥';
442448
@override
443449
String get contract => '合约地址';

lib/widgets/chat_message.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ class ChatMessage extends StatelessWidget {
323323
if (message.isMe) Spacer(),
324324
if (isAvatar)
325325
Container(
326-
width: 50.0,
326+
width: 60.0,
327327
child: Text(name, maxLines: 1, overflow: TextOverflow.ellipsis,
328328
style: TextStyle(color: color.onPrimary.withOpacity(0.5), fontSize: 10.0)
329329
)),

src/apps/group/rpc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ pub(crate) fn new_rpc_handler(handler: &mut RpcHandler<RpcState>) {
124124

125125
let mut results = HandleResult::new();
126126

127-
// add to rpcs.
128-
results.rpcs.push(json!(gc.to_rpc()));
129-
130127
let mut m = Member::new(gheight, gc.id, gid, me.addr, me.name);
131128
m.insert(&db)?;
132129
let mid = m.id;
@@ -143,6 +140,9 @@ pub(crate) fn new_rpc_handler(handler: &mut RpcHandler<RpcState>) {
143140
.await;
144141
});
145142

143+
// add to rpcs.
144+
results.rpcs.push(json!([sid, gdid]));
145+
146146
// Add frist member join.
147147
let mut layer_lock = state.layer.write().await;
148148
layer_lock.add_running(&gcd, gid, gdid, gheight)?;

src/primitives.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub(crate) fn network_seeds() -> Vec<Peer> {
55
#[rustfmt::skip]
66
let seeds: Vec<(&str, &str)> = vec![
77
("1.15.156.199:7364", "quic"),
8+
("184.170.220.231:7364", "quic"),
89
];
910

1011
seeds

0 commit comments

Comments
 (0)