hotfix: notifications do not understand reactions

This commit is contained in:
ari melody 2024-07-02 21:13:01 +01:00
parent f5676f5b7a
commit 22feedaff5
Signed by: ari
GPG key ID: CF99829C92678188

View file

@ -1,5 +1,6 @@
<script> <script>
import * as api from '$lib/client/api.js'; import * as api from '$lib/client/api.js';
import { goto } from '$app/navigation';
import ReplyIcon from '$lib/../img/icons/reply.svg'; import ReplyIcon from '$lib/../img/icons/reply.svg';
import RepostIcon from '$lib/../img/icons/repost.svg'; import RepostIcon from '$lib/../img/icons/repost.svg';
@ -22,6 +23,8 @@
return `%1 mentioned you.`; return `%1 mentioned you.`;
case "reblog": case "reblog":
return `%1 boosted your post.`; return `%1 boosted your post.`;
case "reaction":
return `%1 reacted to your post.`;
case "follow": case "follow":
return `%1 followed you.`; return `%1 followed you.`;
case "follow_request": case "follow_request":
@ -40,6 +43,20 @@
let account = data.accounts[0]; let account = data.accounts[0];
$: accounts_short = data.accounts.slice(0, 3).reverse(); $: accounts_short = data.accounts.slice(0, 3).reverse();
let mouse_pos = { top: 0, left: 0 };
function gotoPost(event) {
if (!data.status) return;
if (event) {
if (event.type == "mouseup" && (
event.button !== 0 ||
event.shiftKey ||
event.ctrlKey)) return;
if (event.key && event.key !== "Enter") return;
}
goto(`/post/${data.status.id}`);
}
let aria_label = function () { let aria_label = function () {
if (accounts.length == 1) if (accounts.length == 1)
return activity_text.replace("%1", account.username) + ' ' + new Date(data.created_at); return activity_text.replace("%1", account.username) + ' ' + new Date(data.created_at);
@ -48,14 +65,19 @@
} }
</script> </script>
<a class="notification" href={data.status ? `/post/${data.status.id}` : null} aria-label={aria_label}> <article
class="notification"
aria-label={aria_label}
on:mousedown={e => {mouse_pos.left = e.pageX; mouse_pos.top = e.pageY}}
on:mouseup={e => {if (e.pageX == mouse_pos.left && e.pageY == mouse_pos.top) gotoPost(e)}}
on:keydown={gotoPost}>
<header aria-hidden> <header aria-hidden>
<span class="notif-icon"> <span class="notif-icon">
{#if data.type === "favourite"} {#if data.type === "favourite"}
<FavouriteIcon /> <FavouriteIcon />
{:else if data.type === "reblog"} {:else if data.type === "reblog"}
<RepostIcon /> <RepostIcon />
{:else if data.type === "react"} {:else if data.type === "reaction"}
<ReactIcon /> <ReactIcon />
{:else if data.type === "mention"} {:else if data.type === "mention"}
<ReplyIcon /> <ReplyIcon />
@ -88,7 +110,7 @@
<ActionBar post={data.status} /> <ActionBar post={data.status} />
{/if} {/if}
{/if} {/if}
</a> </article>
<style> <style>
.notification { .notification {