Skip to content

Commit

Permalink
fix change group name
Browse files Browse the repository at this point in the history
  • Loading branch information
sunhuachuang committed Dec 25, 2021
1 parent 6493411 commit 68c4477
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
14 changes: 7 additions & 7 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ packages:
name: flutter_quill
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.1"
version: "3.0.1"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -386,7 +386,7 @@ packages:
name: i18n_extension
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.3"
version: "4.2.0"
image:
dependency: transitive
description:
Expand Down Expand Up @@ -524,7 +524,7 @@ packages:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
version: "2.0.11"
path_provider_ios:
dependency: transitive
description:
Expand Down Expand Up @@ -921,21 +921,21 @@ packages:
name: video_player
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.8"
version: "2.2.10"
video_player_platform_interface:
dependency: transitive
description:
name: video_player_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.0"
version: "5.0.0"
video_player_web:
dependency: transitive
description:
name: video_player_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
version: "2.0.5"
vm_service:
dependency: transitive
description:
Expand Down Expand Up @@ -970,7 +970,7 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.1"
version: "2.3.3"
xdg_directories:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Account {

Account {
id: 0,
pub_height: 0,
pub_height: 1,
own_height: 0,
wallet: String::new(),
event: EventId::default(),
Expand Down
6 changes: 5 additions & 1 deletion src/apps/group/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,10 @@ async fn handle_server_event(
// 3. broadcast offline event.
broadcast(&LayerEvent::MemberOffline(gcd, fgid), layer, &gcd, results).await?;
}
LayerEvent::GroupName(_gcd, name) => {
LayerEvent::GroupName(gcd, name) => {
// 1. update group name
let _ = GroupChat::update_name(&db, &id, &name)?;
// 2. UI: update
results.rpcs.push(rpc::group_name(ogid, &id, &name));
if let Ok(sid) = Session::update_name_by_id(
&session_db(&base, &ogid)?,
Expand All @@ -264,6 +266,8 @@ async fn handle_server_event(
) {
results.rpcs.push(session_update_name(ogid, &sid, &name));
}
// 3. broadcast
broadcast(&LayerEvent::GroupName(gcd, name), layer, &gcd, results).await?;
}
LayerEvent::Sync(gcd, _, event) => {
match event {
Expand Down
18 changes: 9 additions & 9 deletions src/apps/group/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,16 @@ pub(crate) fn new_rpc_handler(handler: &mut RpcHandler<RpcState>) {
let g = GroupChat::get(&db, &id)?;
let d = bincode::serialize(&LayerEvent::GroupName(g.g_id, name.to_owned()))?;

if let Ok(sid) = Session::update_name_by_id(
&session_db(&base, &gid)?,
&id,
&SessionType::Group,
&name,
) {
results.rpcs.push(session_update_name(gid, &sid, &name));
}

if g.local {
if let Ok(sid) = Session::update_name_by_id(
&session_db(&base, &gid)?,
&id,
&SessionType::Group,
&name,
) {
results.rpcs.push(session_update_name(gid, &sid, &name));
}

results.rpcs.push(json!([id, name]));
// dissolve group.
for (mgid, maddr) in state.layer.read().await.running(&g.g_id)?.onlines() {
Expand Down

0 comments on commit 68c4477

Please sign in to comment.