Skip to content

Commit c94fe13

Browse files
committed
Replace string foo with Option<String> for titles
1 parent d3af612 commit c94fe13

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/handlers/html/paste.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub(crate) struct Paste {
2626
/// If the paste still in the database and can be fetched with another request.
2727
is_available: bool,
2828
html: String,
29-
title: String,
29+
title: Option<String>,
3030
}
3131

3232
#[expect(clippy::too_many_arguments)]
@@ -63,7 +63,7 @@ pub async fn get(
6363
.zip(data.uid)
6464
.is_some_and(|(Uid(user_uid), owner_uid)| user_uid == owner_uid);
6565

66-
let title = data.title.clone().unwrap_or_default();
66+
let title = data.title.clone();
6767

6868
let html = if let Some(html) = cache.get(&key) {
6969
tracing::trace!(?key, "found cached item");
@@ -103,7 +103,7 @@ impl Paste {
103103
theme: Option<Theme>,
104104
can_delete: bool,
105105
is_available: bool,
106-
title: String,
106+
title: Option<String>,
107107
page: Page,
108108
) -> Self {
109109
let html = html.into_inner();

src/handlers/html/qr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub async fn get(
2626
};
2727

2828
let key: Key = id.parse()?;
29-
let title = db.get_title(key.id).await?.unwrap_or_default();
29+
let title = db.get_title(key.id).await?;
3030

3131
// TODO: fix the bogus hardcoded can_delete and is_deleted fields.
3232
Ok(Qr {
@@ -53,7 +53,7 @@ pub(crate) struct Qr {
5353
can_delete: bool,
5454
is_available: bool,
5555
code: qrcodegen::QrCode,
56-
title: String,
56+
title: Option<String>,
5757
}
5858

5959
impl Qr {

templates/paste.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{% extends "base.html" %}
22

33
{% block title %}
4-
{% if !title.is_empty() %}
4+
{% if let Some(title) = title %}
55
<div class="nav-title">{{ title }}</div>
66
{% endif %}
77
{% endblock %}
88

9-
{% block title_content %}{% if title.len() > 0 %}: {{ title }}{% endif %}{% endblock %}
9+
{% block title_content %}{% if let Some(title) = title %}: {{ title }}{% endif %}{% endblock %}
1010

1111
{% block head %}
1212
<script defer src="{{ page.assets.paste_js.route() }}"></script>

0 commit comments

Comments
 (0)