0.2.2: protect create profile with check if one is set as sometimes we still get AppError 0 loaded
This commit is contained in:
parent
0be1b63047
commit
a7fa18b5ff
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "cwtch-imp"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
description = "small demon, a familiar of a witch. imp is a set of bot creating utilities built on top of libcwtch-rs"
|
||||
|
|
17
src/imp.rs
17
src/imp.rs
|
@ -63,15 +63,11 @@ impl Imp {
|
|||
|
||||
match &event {
|
||||
Event::CwtchStarted => {
|
||||
println!("event CwtchStarted!");
|
||||
println!("Cwtch Started");
|
||||
initialized = true;
|
||||
|
||||
match self.profile {
|
||||
None => {
|
||||
println!("Creating bot");
|
||||
self.cwtch.load_profiles(&self.password);
|
||||
}
|
||||
Some(_) => (),
|
||||
if self.profile.is_none() {
|
||||
self.cwtch.load_profiles(&self.password);
|
||||
}
|
||||
}
|
||||
Event::UpdateGlobalSettings { settings } => {
|
||||
|
@ -108,7 +104,6 @@ impl Imp {
|
|||
self.settings = Some(local_settings);
|
||||
}
|
||||
Event::NewPeer { profile_id, tag, created, name, default_picture, picture, online, profile_data} => {
|
||||
|
||||
if let Err(e) = profile_data {
|
||||
panic!("error parsing profile: {}", e);
|
||||
}
|
||||
|
@ -147,8 +142,10 @@ impl Imp {
|
|||
}
|
||||
Event::AppError { error, data } => {
|
||||
if initialized && error == "Loaded 0 profiles" {
|
||||
self.cwtch
|
||||
.create_profile(&self.behaviour.profile_name, &self.password, true);
|
||||
if self.profile.is_none() {
|
||||
self.cwtch
|
||||
.create_profile(&self.behaviour.profile_name, &self.password, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Event::ContactCreated {profile_id, conversation_id, contact_id, nick, status, unread, picture, default_picture, num_messages, accepted, access_control_list, blocked, loading, last_msg_time, .. } => {
|
||||
|
|
Loading…
Reference in New Issue