Skip to content

Commit

Permalink
improvement to prize winner message (#6784)
Browse files Browse the repository at this point in the history
  • Loading branch information
julianjelfs authored Nov 11, 2024
1 parent a3f87f7 commit f9d99fd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
1 change: 0 additions & 1 deletion frontend/app/src/components/home/ChatMessage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@
blockLevelMarkdown={msg.blockLevelMarkdown}
on:removePreview
on:registerVote={registerVote}
on:goToMessageIndex
on:upgrade
on:startVideoCall
on:expandMessage />
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/components/home/ChatMessageContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
{reply}
{pinned} />
{:else if content.kind === "prize_winner_content"}
<PrizeWinnerContent on:goToMessageIndex {content} />
<PrizeWinnerContent {content} />
{:else if content.kind === "poll_content"}
<PollContent {readonly} {me} {content} {myUserId} {senderId} on:registerVote />
{:else if content.kind === "giphy_content"}
Expand Down
26 changes: 17 additions & 9 deletions frontend/app/src/components/home/PrizeWinnerContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import Markdown from "./Markdown.svelte";
import type { OpenChat, PrizeWinnerContent } from "openchat-client";
import { userStore, currentUser as user, cryptoLookup } from "openchat-client";
import { createEventDispatcher, getContext } from "svelte";
import { getContext } from "svelte";
import { _ } from "svelte-i18n";
import SpinningToken from "../icons/SpinningToken.svelte";
import type { ProfileLinkClickedEvent } from "../web-components/profileLink";
const dispatch = createEventDispatcher();
const client = getContext<OpenChat>("client");
export let content: PrizeWinnerContent;
Expand All @@ -25,14 +25,22 @@
: `${$userStore.get(userId)?.username ?? $_("unknown")}`;
}
function zoomToMessage() {
dispatch("goToMessageIndex", {
index: content.prizeMessageIndex,
});
function openUserProfile(ev: Event) {
ev.target?.dispatchEvent(
new CustomEvent<ProfileLinkClickedEvent>("profile-clicked", {
detail: {
userId: content.transaction.recipient,
chatButton: false,
inGlobalContext: false,
},
bubbles: true,
}),
);
ev.stopPropagation();
}
</script>

<div role="button" tabindex="0" class="msg" on:click={zoomToMessage}>
<div class="msg">
<div class="wrapper" class:other={!me}>
<div class="graphic" class:tiny={!me}>
{#if me}
Expand All @@ -46,7 +54,7 @@
{/if}
</div>
<div class="txt" class:other={!me}>
<div class="label">
<div class="label" on:click={openUserProfile}>
<Markdown
text={$_("prizes.winner", {
values: { recipient: winner, amount, token: symbol },
Expand All @@ -63,7 +71,6 @@

<style lang="scss">
.msg {
cursor: pointer;
text-align: center;
padding-top: $sp2;
}
Expand All @@ -79,6 +86,7 @@
}
.label {
cursor: pointer;
@include font(book, normal, fs-100);
}
Expand Down

0 comments on commit f9d99fd

Please sign in to comment.