Skip to content

Commit

Permalink
Fix crashing issue for some users. Improve error logging. Update vers…
Browse files Browse the repository at this point in the history
…ion number.

* Fix parsing exception for chirp.social communities.
* Improve panic error logging.
* Update version number
  • Loading branch information
CMahaff committed Aug 12, 2023
1 parent 81a5ea9 commit 6dbdb99
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "lasim"
authors = ["Connor Mahaffey"]
version = "0.2.1"
version = "0.2.2"
edition = "2021"
license = "MIT"
publish = false
Expand Down
11 changes: 10 additions & 1 deletion src/lemmy/typecast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,18 @@ pub struct FromAPI {}

impl FromAPI {
fn parse_url(actor_id: String) -> String {
// Parse Actor IDs such as:
// https://lemmy.world/c/fakecommunity
// https://kbin.social/m/fakecommunity
// https://chirp.social/@fakecommunity
// Into:
// fakecommunity@the.url
let removed_begin = actor_id.strip_prefix("https://").unwrap_or(&actor_id);
let split_url: Vec<&str> = removed_begin.split('/').collect();
return format!("{}@{}", split_url.get(2).unwrap(), split_url.first().unwrap());

let site = split_url.first().unwrap();
let community_name = split_url.last().unwrap().trim_matches('@');
return format!("{}@{}", community_name, site);
}

fn construct_blocked_users(original_profile: &site::GetSiteResponse) -> Vec<String> {
Expand Down
6 changes: 1 addition & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,7 @@ fn main() {
// Setup some kind of logging for if we crash
let panic_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |panic_info| {
if let Some(s) = panic_info.payload().downcast_ref::<&str>() {
write_panic_info(&format!("Unexpected Error Occurred: {s:?}"));
} else {
write_panic_info(&"Unknown Error Occurred!".to_string());
}
write_panic_info(&format!("Unexpected Error Occurred: {}", panic_info));
panic_hook(panic_info);
std::process::exit(1);
}));
Expand Down
2 changes: 1 addition & 1 deletion src/ui/app.slint
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export component App inherits Window {
Text {
font-size: 20px;
font-weight: 900;
text: "LASIM 0.2.1";
text: "LASIM 0.2.2";
}
Text {
text: "Lemmy BE API Version 0.18.3";
Expand Down

0 comments on commit 6dbdb99

Please sign in to comment.