Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions components/chat/ChatLobby.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ import Empty from "~/components/ui/empty/Empty.vue";
:last-read-count="lastReadMessageCount"
:message-room="messageRoom"
:can-moderate="canModerate"
:can-post="canSend"
@bottom-state-change="handleBottomStateChange"
/>
<Empty v-else class="flex-1 text-muted-foreground">
Expand Down Expand Up @@ -282,6 +283,7 @@ import Empty from "~/components/ui/empty/Empty.vue";
:last-read-count="tracksReadPosition ? lastReadMessageCount : 0"
:message-room="messageRoom"
:can-moderate="canModerate"
:can-post="canSend"
@bottom-state-change="handleBottomStateChange"
/>
<Empty v-else key="empty" class="min-h-0 flex-1 text-muted-foreground">
Expand Down
43 changes: 40 additions & 3 deletions components/chat/ChatMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import TimeAgo from "~/components/TimeAgo.vue";
import PlayerDisplay from "~/components/PlayerDisplay.vue";
import ChatMessageActions from "~/components/chat/ChatMessageActions.vue";
import ChatMessageEditor from "~/components/chat/ChatMessageEditor.vue";
import ChatMessageReactions from "~/components/chat/ChatMessageReactions.vue";
import FiveStackToolTip from "~/components/FiveStackToolTip.vue";
</script>

Expand Down Expand Up @@ -105,6 +106,13 @@ import FiveStackToolTip from "~/components/FiveStackToolTip.vue";
{{ $t("chat.edited_at", { time: editedAtLabel }) }}
</FiveStackToolTip>
</p>
<ChatMessageReactions
:message="message"
:room="room"
:permissions="permissions"
:viewer-steam-id="viewerSteamId"
@toggle="toggleReaction"
/>
</div>

<!-- Centred on the first line rather than hung off its top: the trigger is
Expand All @@ -118,17 +126,21 @@ import FiveStackToolTip from "~/components/FiveStackToolTip.vue";
:room="room"
:permissions="permissions"
:own="isOwnMessage"
:viewer-steam-id="viewerSteamId"
@open="recheckPermissions"
@expired="permissionsCheckedAt = Date.now()"
@edit="$emit('edit')"
@react="toggleReaction"
/>
</div>
</template>

<script lang="ts">
import type { PropType } from "vue";
import type { ChatType } from "~/web-sockets/Socket";
import socket, { type ChatType } from "~/web-sockets/Socket";
import type { ChatReaction } from "~/constants/chat";
import { toast } from "@/components/ui/toast";
import { toastChatError, type ChatError } from "~/utilities/chatErrors";
import {
chatMessagePermissions,
hasChatMessageActions,
Expand Down Expand Up @@ -159,6 +171,10 @@ export default {
type: Boolean,
default: false,
},
canPost: {
type: Boolean,
default: false,
},
editing: {
type: Boolean,
default: false,
Expand All @@ -181,6 +197,15 @@ export default {
toast({ title: this.$t("chat.own_message_window_closed") });
}
},
toggleReaction(reaction: ChatReaction) {
if (!this.room || !this.message?.id) {
return;
}

socket
.react(this.room.type, this.room.id, this.message.id, reaction)
.catch((error: ChatError) => toastChatError(error));
},
// Focus goes back to the trigger the edit came from, if the window still
// leaves it anything to offer, rather than falling to the page.
endEdit() {
Expand Down Expand Up @@ -209,6 +234,7 @@ export default {
viewerSteamId: this.viewerSteamId,
viewerGagged: !!useAuthStore().me?.is_gagged,
canModerate: this.canModerate,
canPost: this.canPost,
roomType: this.room?.type ?? "",
now: this.permissionsCheckedAt,
});
Expand All @@ -228,6 +254,17 @@ export default {
hasActions() {
return !!this.room && hasChatMessageActions(this.permissions);
},
// A gagged player's trigger comes and goes with the reactions they hold,
// so the room for it is kept wherever reacting is possible at all.
reservesActions() {
return (
this.hasActions ||
(!!this.room &&
this.canPost &&
!!this.message?.id &&
!!this.viewerSteamId)
);
},
// Stamped by ChatLobby when it merges the match room with a lineup room.
// Absent everywhere else, which is what keeps every other chat surface
// rendering exactly as before.
Expand Down Expand Up @@ -281,7 +318,7 @@ export default {

// Room for the actions trigger kept whether or not it is showing, so a
// hover never rewraps the line under the pointer.
if (this.hasActions) {
if (this.reservesActions) {
classes.push("pr-7");
}

Expand All @@ -293,7 +330,7 @@ export default {
}

classes.push("bg-[hsl(var(--tac-amber)/0.05)]");
if (!this.hasActions) {
if (!this.reservesActions) {
classes.push("pr-2");
}

Expand Down
Loading
Loading