feat(notedeck): add cross-platform URI opener
This commit is contained in:
committed by
William Casarin
parent
ba76b20ad2
commit
f282363748
@@ -28,7 +28,7 @@ impl Support {
|
||||
}
|
||||
|
||||
static MAX_LOG_LINES: usize = 500;
|
||||
static SUPPORT_EMAIL: &str = "support@damus.io";
|
||||
pub static SUPPORT_EMAIL: &str = "support+notedeck@damus.io";
|
||||
static EMAIL_TEMPLATE: &str = concat!("version ", env!("CARGO_PKG_VERSION"), "\nCommit hash: ", env!("GIT_COMMIT_HASH"), "\n\nDescribe the bug you have encountered:\n<-- your statement here -->\n\n===== Paste your log below =====\n\n");
|
||||
|
||||
impl Support {
|
||||
|
||||
@@ -6,6 +6,7 @@ use enostr::Pubkey;
|
||||
use nostrdb::{ProfileRecord, Transaction};
|
||||
use notedeck::{tr, Localization};
|
||||
use notedeck_ui::profile::follow_button;
|
||||
use robius_open::Uri;
|
||||
use tracing::error;
|
||||
|
||||
use crate::{
|
||||
@@ -285,8 +286,8 @@ fn handle_link(ui: &mut egui::Ui, website_url: &str) {
|
||||
.interact(Sense::click())
|
||||
.clicked()
|
||||
{
|
||||
if let Err(e) = open::that(website_url) {
|
||||
error!("Failed to open URL {} because: {}", website_url, e);
|
||||
if let Err(e) = Uri::new(website_url).open() {
|
||||
error!("Failed to open URL {} because: {:?}", website_url, e);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use crate::support::{Support, SUPPORT_EMAIL};
|
||||
use egui::{vec2, Button, Label, Layout, RichText};
|
||||
use notedeck::{tr, Localization, NamedFontFamily, NotedeckTextStyle};
|
||||
use notedeck_ui::{colors::PINK, padding};
|
||||
use robius_open::Uri;
|
||||
use tracing::error;
|
||||
|
||||
use crate::support::Support;
|
||||
|
||||
pub struct SupportView<'a> {
|
||||
support: &'a mut Support,
|
||||
i18n: &'a mut Localization,
|
||||
@@ -44,15 +44,21 @@ impl<'a> SupportView<'a> {
|
||||
"Open your default email client to get help from the Damus team",
|
||||
"Instruction to open email client"
|
||||
));
|
||||
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label(tr!(self.i18n, "Support email:", "Support email address",));
|
||||
ui.label(RichText::new(SUPPORT_EMAIL).color(PINK))
|
||||
});
|
||||
|
||||
let size = vec2(120.0, 40.0);
|
||||
ui.allocate_ui_with_layout(size, Layout::top_down(egui::Align::Center), |ui| {
|
||||
let font_size =
|
||||
notedeck::fonts::get_font_size(ui.ctx(), &NotedeckTextStyle::Body);
|
||||
let button_resp = ui.add(open_email_button(self.i18n, font_size, size));
|
||||
if button_resp.clicked() {
|
||||
if let Err(e) = open::that(self.support.get_mailto_url()) {
|
||||
if let Err(e) = Uri::new(self.support.get_mailto_url()).open() {
|
||||
error!(
|
||||
"Failed to open URL {} because: {}",
|
||||
"Failed to open URL {} because: {:?}",
|
||||
self.support.get_mailto_url(),
|
||||
e
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user