Skip to content

Commit

Permalink
app: correctly opens pob2 for poe2 pastes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dav1dde committed Jan 18, 2025
1 parent 4e7cf51 commit 2c262be
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/src/components/view_paste.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn ViewPaste<'a, G: Html>(
let since = crate::utils::pretty_date_ts(last_modified);
let date = js_sys::Date::new(&JsValue::from_f64(last_modified as f64)).to_string();

let open_in_pob_url = id.to_pob_open_url();
let open_in_pob_url = id.to_pob_open_url(gv);
let pob_cool_url = format!("https://pob.cool/#build={SELF_URL}{}", id.to_url());

let logo = view_cond!(cx, gv.is_poe2(), {
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn summary_to_view<'a, G: GenericNode + Html>(
let color = crate::meta::get_color(summary.ascendancy_or_class);

let id = summary.id.clone().unwrap_user();
let open_in_pob_url = id.to_pob_open_url();
let open_in_pob_url = id.to_pob_open_url(summary.game_version);

// TODO: this sucks and is annoying
let version = summary.version.clone().unwrap_or_default();
Expand Down
21 changes: 14 additions & 7 deletions shared/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{fmt, str::FromStr};

use serde::{Deserialize, Serialize};

use crate::UrlSafe;
use crate::{GameVersion, UrlSafe};

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Id(String);
Expand Down Expand Up @@ -138,9 +138,13 @@ impl UserPasteId {
.join(&*self.id)
}

pub fn to_pob_open_url(&self) -> UrlSafe<'static> {
UrlSafe::from_static("pob://pobbin/")
.join(UrlSafe::new(&self.user).push(":").push(&*self.id))
pub fn to_pob_open_url(&self, gv: GameVersion) -> UrlSafe<'static> {
let id = UrlSafe::new(&self.user).push(":").push(&*self.id);

match gv {
GameVersion::One => UrlSafe::from_static("pob://pobbin/").join(id),
GameVersion::Two => UrlSafe::from_static("pob2://pobbin/").join(id),
}
}
}

Expand Down Expand Up @@ -199,10 +203,13 @@ impl PasteId {
}
}

pub fn to_pob_open_url(&self) -> UrlSafe<'static> {
pub fn to_pob_open_url(&self, gv: GameVersion) -> UrlSafe<'static> {
match self {
Self::Paste(id) => UrlSafe::from_static("pob://pobbin/").join(id.as_str()),
Self::UserPaste(up) => up.to_pob_open_url(),
Self::Paste(id) => match gv {
GameVersion::One => UrlSafe::from_static("pob://pobbin/").join(id.as_str()),
GameVersion::Two => UrlSafe::from_static("pob2://pobbin/").join(id.as_str()),
},
Self::UserPaste(up) => up.to_pob_open_url(gv),
}
}

Expand Down

0 comments on commit 2c262be

Please sign in to comment.