diff --git a/crates/app/src/public/css/style.css b/crates/app/src/public/css/style.css
index 5247b17..8abff45 100644
--- a/crates/app/src/public/css/style.css
+++ b/crates/app/src/public/css/style.css
@@ -1048,17 +1048,14 @@ dialog::backdrop {
position: absolute;
left: 0;
top: 0;
- background: linear-gradient(transparent 50%, var(--color-raised));
-}
-
-.hook\:long\.hidden_text\+lowered::before {
- background: linear-gradient(transparent 50%, var(--color-lowered));
+ background: linear-gradient(transparent 20%, var(--color-surface));
+ border-radius: var(--radius);
}
.hook\:long\.hidden_text::after {
position: absolute;
content: "Show full content";
- border-radius: calc(var(--radius) * 4);
+ border-radius: var(--radius);
padding: 0.25rem 0.75rem;
background: var(--color-primary);
font-weight: 600;
diff --git a/crates/app/src/public/html/components.html b/crates/app/src/public/html/components.html
index 07042a2..de42975 100644
--- a/crates/app/src/public/html/components.html
+++ b/crates/app/src/public/html/components.html
@@ -228,9 +228,13 @@ and show_community and community.id != config.town_square or question %}
{% if not post.context.content_warning %}
- {{ post.content|markdown|safe }}
+ {{ post.content|markdown|safe }}
+
{% else %}
{{ post.context.content_warning }}
- {{ post.content|markdown|safe }}
+ {{ post.content|markdown|safe }}
+
{% endif %}
diff --git a/crates/app/src/public/html/root.html b/crates/app/src/public/html/root.html
index 14272c8..291f041 100644
--- a/crates/app/src/public/html/root.html
+++ b/crates/app/src/public/html/root.html
@@ -111,7 +111,6 @@ macros -%}
atto["hooks::ips"]();
atto["hooks::check_reactions"]();
atto["hooks::tabs"]();
- atto["hooks::partial_embeds"]();
atto["hooks::spotify_time_text"](); // spotify durations
if (document.getElementById("tokens")) {
diff --git a/crates/app/src/public/js/atto.js b/crates/app/src/public/js/atto.js
index bc8d0ed..022abb2 100644
--- a/crates/app/src/public/js/atto.js
+++ b/crates/app/src/public/js/atto.js
@@ -349,7 +349,7 @@ media_theme_pref();
for (const element of Array.from(
document.querySelectorAll("[hook=long]") || [],
)) {
- const is_long = element.innerText.length >= 64 * 16;
+ const is_long = element.innerText.length >= 64 * 8;
if (!is_long) {
continue;
@@ -362,12 +362,12 @@ media_theme_pref();
}
const html = element.innerHTML;
- const short = html.slice(0, 64 * 16);
+ const short = html.slice(0, 64 * 8);
element.innerHTML = `${short}...`;
// event
const listener = () => {
- app["hooks::long"](element, html);
+ self["hooks::long"](element, html);
element.removeEventListener("click", listener);
};
@@ -508,7 +508,7 @@ media_theme_pref();
})
.then((res) => res.json())
.then((res) => {
- trigger("app::toast", [
+ trigger("atto::toast", [
res.success ? "success" : "error",
res.message,
]);
@@ -560,7 +560,7 @@ media_theme_pref();
wrapper.scrollTop + wrapper.offsetHeight + 100 >
attach.offsetHeight
) {
- self.debounce("app::partials")
+ self.debounce("atto::partials")
.then(async () => {
if (document.getElementById("initial_loader")) {
console.log("partial blocked");
@@ -570,7 +570,6 @@ media_theme_pref();
// biome-ignore lint/style/noParameterAssign: no it isn't
page += 1;
await load_partial();
- await $["hooks::partial_embeds"]();
})
.catch(() => {
console.log("partial stuck");
@@ -583,25 +582,6 @@ media_theme_pref();
},
);
- self.define("hooks::partial_embeds", (_) => {
- for (const paragraph of Array.from(
- document.querySelectorAll("span[class] p"),
- )) {
- const groups = /(\/\+r\/)([\w]+)/.exec(paragraph.innerText);
-
- if (groups === null) {
- continue;
- }
-
- // add embed
- paragraph.innerText = paragraph.innerText.replace(groups[0], "");
- paragraph.parentElement.innerHTML += ``;
- }
- });
-
self.define("hooks::check_reactions", async ({ $ }) => {
const observer = $.offload_work_to_client_when_in_view(
async (element) => {
diff --git a/crates/app/src/public/js/me.js b/crates/app/src/public/js/me.js
index be5fc3b..d8047fe 100644
--- a/crates/app/src/public/js/me.js
+++ b/crates/app/src/public/js/me.js
@@ -54,6 +54,7 @@
});
self.define("react", async (_, element, asset, asset_type, is_like) => {
+ await trigger("atto::debounce", ["reactions::toggle"]);
fetch("/api/v1/reactions", {
method: "POST",
headers: {
diff --git a/crates/core/src/database/auth.rs b/crates/core/src/database/auth.rs
index 948d673..ec869ff 100644
--- a/crates/core/src/database/auth.rs
+++ b/crates/core/src/database/auth.rs
@@ -653,6 +653,7 @@ impl DataManager {
auto_method!(get_user_by_stripe_id(&str)@get_user_from_row -> "SELECT * FROM users WHERE stripe_id = $1" --name="user" --returns=User);
auto_method!(update_user_stripe_id(&str)@get_user_by_id -> "UPDATE users SET stripe_id = $1 WHERE id = $2" --cache-key-tmpl=cache_clear_user);
+ auto_method!(update_user_notification_count(i32)@get_user_by_id -> "UPDATE users SET notification_count = $1 WHERE id = $2" --cache-key-tmpl=cache_clear_user);
auto_method!(incr_user_notifications()@get_user_by_id -> "UPDATE users SET notification_count = notification_count + 1 WHERE id = $1" --cache-key-tmpl=cache_clear_user --incr);
auto_method!(decr_user_notifications()@get_user_by_id -> "UPDATE users SET notification_count = notification_count - 1 WHERE id = $1" --cache-key-tmpl=cache_clear_user --decr=notification_count);
diff --git a/crates/core/src/database/drivers/sql/create_reactions.sql b/crates/core/src/database/drivers/sql/create_reactions.sql
index 8b4565f..8f95021 100644
--- a/crates/core/src/database/drivers/sql/create_reactions.sql
+++ b/crates/core/src/database/drivers/sql/create_reactions.sql
@@ -4,5 +4,6 @@ CREATE TABLE IF NOT EXISTS reactions (
owner BIGINT NOT NULL,
asset BIGINT NOT NULL,
asset_type TEXT NOT NULL,
- is_like INT NOT NULL
+ is_like INT NOT NULL,
+ UNIQUE (owner, asset)
)
diff --git a/crates/core/src/database/notifications.rs b/crates/core/src/database/notifications.rs
index 14e2806..0a1e146 100644
--- a/crates/core/src/database/notifications.rs
+++ b/crates/core/src/database/notifications.rs
@@ -187,6 +187,8 @@ impl DataManager {
self.delete_notification(notification.id, user).await?
}
+ self.update_user_notification_count(user.id, 0).await?;
+
Ok(())
}
diff --git a/sql_changes/reactions_unique.sql b/sql_changes/reactions_unique.sql
new file mode 100644
index 0000000..0a4ea08
--- /dev/null
+++ b/sql_changes/reactions_unique.sql
@@ -0,0 +1 @@
+ALTER TABLE reactions ADD CONSTRAINT uq_reactions UNIQUE (owner, asset);