add frontend interface to send reactions
This commit is contained in:
Vendored
+157
-21
@@ -1258,7 +1258,8 @@
|
|||||||
this.setReadStatus(true);
|
this.setReadStatus(true);
|
||||||
};
|
};
|
||||||
this.handleReaction = (reaction) => {
|
this.handleReaction = (reaction) => {
|
||||||
if (!checkMatchesObjectStructure(reaction, ChatMessageReactionReference)) return;
|
if (!checkMatchesObjectStructure(reaction, ChatMessageReactionReference))
|
||||||
|
return;
|
||||||
this.addReaction(reaction);
|
this.addReaction(reaction);
|
||||||
};
|
};
|
||||||
this.handleMessageSent = (chatMessage) => {
|
this.handleMessageSent = (chatMessage) => {
|
||||||
@@ -2010,6 +2011,26 @@
|
|||||||
this.reactionsAttention = new MapState();
|
this.reactionsAttention = new MapState();
|
||||||
this.reactionsDoubleAttention = new MapState();
|
this.reactionsDoubleAttention = new MapState();
|
||||||
this.reactionsQuestion = new MapState();
|
this.reactionsQuestion = new MapState();
|
||||||
|
this.reactionsThumbsUpCount = createProxyState(
|
||||||
|
[this.reactionsThumbsUp],
|
||||||
|
() => this.reactionsThumbsUp.value.size
|
||||||
|
);
|
||||||
|
this.reactionsCheckCount = createProxyState(
|
||||||
|
[this.reactionsCheck],
|
||||||
|
() => this.reactionsCheck.value.size
|
||||||
|
);
|
||||||
|
this.reactionsAttentionCount = createProxyState(
|
||||||
|
[this.reactionsAttention],
|
||||||
|
() => this.reactionsAttention.value.size
|
||||||
|
);
|
||||||
|
this.reactionsDoubleAttentionCount = createProxyState(
|
||||||
|
[this.reactionsDoubleAttention],
|
||||||
|
() => this.reactionsDoubleAttention.value.size
|
||||||
|
);
|
||||||
|
this.reactionsQuestionCount = createProxyState(
|
||||||
|
[this.reactionsQuestion],
|
||||||
|
() => this.reactionsQuestion.value.size
|
||||||
|
);
|
||||||
// state
|
// state
|
||||||
this.isPresentingInfoModal = new State(false);
|
this.isPresentingInfoModal = new State(false);
|
||||||
// methods
|
// methods
|
||||||
@@ -2032,18 +2053,24 @@
|
|||||||
// reactions
|
// reactions
|
||||||
this.addReaction = (reaction) => {
|
this.addReaction = (reaction) => {
|
||||||
switch (reaction.content) {
|
switch (reaction.content) {
|
||||||
case "\u{1F44D}":
|
case "\u{1F44D}" /* ThumbsUp */:
|
||||||
return this.reactionsThumbsUp.set(reaction.fileId, reaction);
|
return this.reactionsThumbsUp.set(reaction.sender, reaction);
|
||||||
case "\u2705":
|
case "\u2705" /* Check */:
|
||||||
return this.reactionsCheck.set(reaction.fileId, reaction);
|
return this.reactionsCheck.set(reaction.sender, reaction);
|
||||||
case "\u2757\uFE0F":
|
case "\u2757\uFE0F" /* Attention */:
|
||||||
return this.reactionsAttention.set(reaction.fileId, reaction);
|
return this.reactionsAttention.set(reaction.sender, reaction);
|
||||||
case "\u203C\uFE0F":
|
case "\u203C\uFE0F" /* DoubleAttention */:
|
||||||
return this.reactionsDoubleAttention.set(reaction.fileId, reaction);
|
return this.reactionsDoubleAttention.set(
|
||||||
case "\u2753":
|
reaction.sender,
|
||||||
return this.reactionsQuestion.set(reaction.fileId, reaction);
|
reaction
|
||||||
|
);
|
||||||
|
case "\u2753" /* Question */:
|
||||||
|
return this.reactionsQuestion.set(reaction.sender, reaction);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
this.sendReaction = (content) => {
|
||||||
|
this.messagePageViewModel.sendReaction(this.chatMessage.id, content);
|
||||||
|
};
|
||||||
// load
|
// load
|
||||||
this.loadData = () => {
|
this.loadData = () => {
|
||||||
this.channel = this.chatMessage.channel;
|
this.channel = this.chatMessage.channel;
|
||||||
@@ -2746,7 +2773,13 @@
|
|||||||
copyMessageButton: "Copy message",
|
copyMessageButton: "Copy message",
|
||||||
resendMessageButton: "Resend message",
|
resendMessageButton: "Resend message",
|
||||||
decryptMessageButton: "Decrypt message",
|
decryptMessageButton: "Decrypt message",
|
||||||
deleteMessageButton: "Delete message"
|
deleteMessageButton: "Delete message",
|
||||||
|
//
|
||||||
|
thumbsUpReaction: "Reaction: thumbs up",
|
||||||
|
checkReaction: "Reaction: check",
|
||||||
|
attentionReaction: "Reaction: exclamation mark",
|
||||||
|
doubleAttentionReaction: "Reaction: double exclamation mark",
|
||||||
|
questionReaction: "Reaction: question mark"
|
||||||
},
|
},
|
||||||
task: {
|
task: {
|
||||||
newBoardNamePlaceholder: "Create a board",
|
newBoardNamePlaceholder: "Create a board",
|
||||||
@@ -2927,7 +2960,13 @@
|
|||||||
copyMessageButton: "Nachricht kopieren",
|
copyMessageButton: "Nachricht kopieren",
|
||||||
resendMessageButton: "Nachricht erneut senden",
|
resendMessageButton: "Nachricht erneut senden",
|
||||||
decryptMessageButton: "Nachricht entschl\xFCsseln",
|
decryptMessageButton: "Nachricht entschl\xFCsseln",
|
||||||
deleteMessageButton: "Nachricht l\xF6schen"
|
deleteMessageButton: "Nachricht l\xF6schen",
|
||||||
|
//
|
||||||
|
thumbsUpReaction: "Reaktion: Daumen hoch",
|
||||||
|
checkReaction: "Reaktion: Haken",
|
||||||
|
attentionReaction: "Reaktion: Ausrufezeichen",
|
||||||
|
doubleAttentionReaction: "Reaktion: doppeltes Ausrufezeichen",
|
||||||
|
questionReaction: "Reaktion: Fragezeichen"
|
||||||
},
|
},
|
||||||
task: {
|
task: {
|
||||||
newBoardNamePlaceholder: "Board erstellen",
|
newBoardNamePlaceholder: "Board erstellen",
|
||||||
@@ -3098,7 +3137,13 @@
|
|||||||
copyMessageButton: "Copiar mensaje",
|
copyMessageButton: "Copiar mensaje",
|
||||||
resendMessageButton: "Reenviar mensaje",
|
resendMessageButton: "Reenviar mensaje",
|
||||||
decryptMessageButton: "Desencriptar mensaje",
|
decryptMessageButton: "Desencriptar mensaje",
|
||||||
deleteMessageButton: "Eliminar mensaje"
|
deleteMessageButton: "Eliminar mensaje",
|
||||||
|
//
|
||||||
|
thumbsUpReaction: "Reacci\xF3n: pulgar hacia arriba",
|
||||||
|
checkReaction: "Reacci\xF3n: marca de verificaci\xF3n",
|
||||||
|
attentionReaction: "Reaccion: signo de atenci\xF3n",
|
||||||
|
doubleAttentionReaction: "Reaccion: signo de atenci\xF3n doble",
|
||||||
|
questionReaction: "Reaccion: signo de interrogaci\xF3n"
|
||||||
},
|
},
|
||||||
task: {
|
task: {
|
||||||
newBoardNamePlaceholder: "Crear un tablero",
|
newBoardNamePlaceholder: "Crear un tablero",
|
||||||
@@ -3262,9 +3307,11 @@
|
|||||||
this.notificationViewModel.showNotification(chatMessage);
|
this.notificationViewModel.showNotification(chatMessage);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
chatModel.reactionHandlerManager.addHandler((reaction) => {
|
chatModel.reactionHandlerManager.addHandler(
|
||||||
|
(reaction) => {
|
||||||
this.messagePageViewModel.showReaction(reaction);
|
this.messagePageViewModel.showReaction(reaction);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
this.loadPageSelection();
|
this.loadPageSelection();
|
||||||
this.resetColor();
|
this.resetColor();
|
||||||
this.loadInfo();
|
this.loadInfo();
|
||||||
@@ -3885,6 +3932,80 @@
|
|||||||
return RibbonButton(label, icon, isSelected, select, isHighlighted);
|
return RibbonButton(label, icon, isSelected, select, isHighlighted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// src/View/Components/messageReactionButton.tsx
|
||||||
|
function MessageReactionButton(chatMessageViewModel, content) {
|
||||||
|
function sendReaction() {
|
||||||
|
chatMessageViewModel.sendReaction(content);
|
||||||
|
}
|
||||||
|
function getUsername() {
|
||||||
|
return chatMessageViewModel.messagePageViewModel.chatViewModel.settingsViewModel.username.value;
|
||||||
|
}
|
||||||
|
function checkIsHighlighted(mapState) {
|
||||||
|
return mapState.value.has(getUsername());
|
||||||
|
}
|
||||||
|
let audioLabel;
|
||||||
|
let count;
|
||||||
|
let isActive;
|
||||||
|
switch (content) {
|
||||||
|
case "\u{1F44D}" /* ThumbsUp */: {
|
||||||
|
audioLabel = translations.chatPage.message.thumbsUpReaction;
|
||||||
|
count = chatMessageViewModel.reactionsThumbsUpCount;
|
||||||
|
isActive = createProxyState(
|
||||||
|
[chatMessageViewModel.reactionsThumbsUp],
|
||||||
|
() => checkIsHighlighted(chatMessageViewModel.reactionsThumbsUp)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "\u2705" /* Check */: {
|
||||||
|
audioLabel = translations.chatPage.message.checkReaction;
|
||||||
|
count = chatMessageViewModel.reactionsCheckCount;
|
||||||
|
isActive = createProxyState(
|
||||||
|
[chatMessageViewModel.reactionsCheck],
|
||||||
|
() => checkIsHighlighted(chatMessageViewModel.reactionsCheck)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "\u2757\uFE0F" /* Attention */: {
|
||||||
|
audioLabel = translations.chatPage.message.attentionReaction;
|
||||||
|
count = chatMessageViewModel.reactionsAttentionCount;
|
||||||
|
isActive = createProxyState(
|
||||||
|
[chatMessageViewModel.reactionsAttention],
|
||||||
|
() => checkIsHighlighted(chatMessageViewModel.reactionsAttention)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "\u203C\uFE0F" /* DoubleAttention */: {
|
||||||
|
audioLabel = translations.chatPage.message.doubleAttentionReaction;
|
||||||
|
count = chatMessageViewModel.reactionsDoubleAttentionCount;
|
||||||
|
isActive = createProxyState(
|
||||||
|
[chatMessageViewModel.reactionsDoubleAttention],
|
||||||
|
() => checkIsHighlighted(chatMessageViewModel.reactionsDoubleAttention)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "\u2753" /* Question */: {
|
||||||
|
audioLabel = translations.chatPage.message.questionReaction;
|
||||||
|
count = chatMessageViewModel.reactionsQuestionCount;
|
||||||
|
isActive = createProxyState(
|
||||||
|
[chatMessageViewModel.reactionsQuestion],
|
||||||
|
() => checkIsHighlighted(chatMessageViewModel.reactionsQuestion)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return /* @__PURE__ */ createElement(
|
||||||
|
"button",
|
||||||
|
{
|
||||||
|
class: "flex",
|
||||||
|
"on:click": sendReaction,
|
||||||
|
"aria-label": audioLabel,
|
||||||
|
"toggle:selected": isActive
|
||||||
|
},
|
||||||
|
content,
|
||||||
|
/* @__PURE__ */ createElement("span", { "subscribe:innerText": count })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// src/View/Modals/chatMessageInfoModal.tsx
|
// src/View/Modals/chatMessageInfoModal.tsx
|
||||||
function ChatMessageInfoModal(chatMessageViewModel) {
|
function ChatMessageInfoModal(chatMessageViewModel) {
|
||||||
return /* @__PURE__ */ createElement(
|
return /* @__PURE__ */ createElement(
|
||||||
@@ -3899,12 +4020,27 @@
|
|||||||
class: "break-word",
|
class: "break-word",
|
||||||
"subscribe:innerText": chatMessageViewModel.body
|
"subscribe:innerText": chatMessageViewModel.body
|
||||||
}
|
}
|
||||||
)))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("div", { class: "flex-column gap" }, /* @__PURE__ */ createElement("button", { "on:click": chatMessageViewModel.copyMessage }, translations.chatPage.message.copyMessageButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "content_copy")), /* @__PURE__ */ createElement("button", { "on:click": chatMessageViewModel.resendMessage }, translations.chatPage.message.resendMessageButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "redo")), /* @__PURE__ */ createElement("button", { "on:click": chatMessageViewModel.decryptMessage }, translations.chatPage.message.decryptMessageButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "key")))), /* @__PURE__ */ createElement("button", { "on:click": chatMessageViewModel.hideInfoModal }, translations.general.closeButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "close")))
|
)))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("div", { class: "flex-column gap" }, /* @__PURE__ */ createElement("button", { "on:click": chatMessageViewModel.copyMessage }, translations.chatPage.message.copyMessageButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "content_copy")), /* @__PURE__ */ createElement("button", { "on:click": chatMessageViewModel.resendMessage }, translations.chatPage.message.resendMessageButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "redo")), /* @__PURE__ */ createElement("button", { "on:click": chatMessageViewModel.decryptMessage }, translations.chatPage.message.decryptMessageButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "key"))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("div", { class: "flex-row gap" }, MessageReactionButton(
|
||||||
|
chatMessageViewModel,
|
||||||
|
"\u{1F44D}" /* ThumbsUp */
|
||||||
|
), MessageReactionButton(
|
||||||
|
chatMessageViewModel,
|
||||||
|
"\u2705" /* Check */
|
||||||
|
), MessageReactionButton(
|
||||||
|
chatMessageViewModel,
|
||||||
|
"\u2757\uFE0F" /* Attention */
|
||||||
|
), MessageReactionButton(
|
||||||
|
chatMessageViewModel,
|
||||||
|
"\u203C\uFE0F" /* DoubleAttention */
|
||||||
|
), MessageReactionButton(
|
||||||
|
chatMessageViewModel,
|
||||||
|
"\u2753" /* Question */
|
||||||
|
))), /* @__PURE__ */ createElement("button", { "on:click": chatMessageViewModel.hideInfoModal }, translations.general.closeButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "close")))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/View/Components/chatMessage.tsx
|
// src/View/Components/chatMessage.tsx
|
||||||
function ChatMessage3(chatMessageViewModel) {
|
function ChatMessage4(chatMessageViewModel) {
|
||||||
const statusIcon = createProxyState(
|
const statusIcon = createProxyState(
|
||||||
[chatMessageViewModel.status],
|
[chatMessageViewModel.status],
|
||||||
() => {
|
() => {
|
||||||
@@ -3950,7 +4086,7 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
var ChatMessageViewModelToView = (chatMessageViewModel) => {
|
var ChatMessageViewModelToView = (chatMessageViewModel) => {
|
||||||
return ChatMessage3(chatMessageViewModel);
|
return ChatMessage4(chatMessageViewModel);
|
||||||
};
|
};
|
||||||
|
|
||||||
// src/View/ChatPages/messagePage.tsx
|
// src/View/ChatPages/messagePage.tsx
|
||||||
@@ -5039,21 +5175,21 @@
|
|||||||
this.storeAddress(this.address);
|
this.storeAddress(this.address);
|
||||||
this.sendSubscriptionRequest();
|
this.sendSubscriptionRequest();
|
||||||
this.sendMessagesInOutbox();
|
this.sendMessagesInOutbox();
|
||||||
this.shouldAttemptReconnect = true;
|
|
||||||
};
|
};
|
||||||
// connection
|
// connection
|
||||||
this.connect = (address) => {
|
this.connect = (address) => {
|
||||||
console.log("connecting...", address);
|
console.log("connecting...", address);
|
||||||
|
this.shouldAttemptReconnect = true;
|
||||||
this.udn.connect(address);
|
this.udn.connect(address);
|
||||||
};
|
};
|
||||||
this.disconnect = () => {
|
this.disconnect = () => {
|
||||||
|
this.shouldAttemptReconnect = false;
|
||||||
this.udn.disconnect();
|
this.udn.disconnect();
|
||||||
const reconnectAddressPath = StorageModel.getPath(
|
const reconnectAddressPath = StorageModel.getPath(
|
||||||
"connection" /* ConnectionModel */,
|
"connection" /* ConnectionModel */,
|
||||||
filePaths.connectionModel.reconnectAddress
|
filePaths.connectionModel.reconnectAddress
|
||||||
);
|
);
|
||||||
this.storageModel.remove(reconnectAddressPath);
|
this.storageModel.remove(reconnectAddressPath);
|
||||||
this.shouldAttemptReconnect = false;
|
|
||||||
};
|
};
|
||||||
this.reconnect = () => {
|
this.reconnect = () => {
|
||||||
const reconnectAddressPath = this.getReconnectAddressPath();
|
const reconnectAddressPath = this.getReconnectAddressPath();
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ export default class ChatModel {
|
|||||||
|
|
||||||
sendReaction = async (
|
sendReaction = async (
|
||||||
messageId: string,
|
messageId: string,
|
||||||
content: ReactionSymbol,
|
content: ReactionSymbols,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
const nameAndChannel = this.getNameAndChannel();
|
const nameAndChannel = this.getNameAndChannel();
|
||||||
if (nameAndChannel == false) return;
|
if (nameAndChannel == false) return;
|
||||||
@@ -407,7 +407,7 @@ export default class ChatModel {
|
|||||||
static createMessageReaction = (
|
static createMessageReaction = (
|
||||||
messageId: string,
|
messageId: string,
|
||||||
sender: string,
|
sender: string,
|
||||||
content: ReactionSymbol,
|
content: ReactionSymbols,
|
||||||
): ChatMessageReaction => {
|
): ChatMessageReaction => {
|
||||||
const fileContent = FileModel.createFileContent(v4(), "reaction");
|
const fileContent = FileModel.createFileContent(v4(), "reaction");
|
||||||
const reaction: ChatMessageReaction = {
|
const reaction: ChatMessageReaction = {
|
||||||
@@ -422,7 +422,13 @@ export default class ChatModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// types
|
// types
|
||||||
export type ReactionSymbol = "👍" | "✅" | "❗️" | "‼️" | "❓";
|
export enum ReactionSymbols {
|
||||||
|
ThumbsUp = "👍",
|
||||||
|
Check = "✅",
|
||||||
|
Attention = "❗️",
|
||||||
|
DoubleAttention = "‼️",
|
||||||
|
Question = "❓",
|
||||||
|
}
|
||||||
|
|
||||||
export interface ChatInfo extends ValidObject {
|
export interface ChatInfo extends ValidObject {
|
||||||
primaryChannel: string;
|
primaryChannel: string;
|
||||||
@@ -456,7 +462,7 @@ export interface ChatMessageReaction
|
|||||||
extends ValidObject, FileContent<"reaction"> {
|
extends ValidObject, FileContent<"reaction"> {
|
||||||
messageId: string;
|
messageId: string;
|
||||||
sender: string;
|
sender: string;
|
||||||
content: ReactionSymbol | string;
|
content: ReactionSymbols | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// references
|
// references
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
import * as React from "bloatless-react";
|
||||||
|
import { ReactionSymbols } from "../../Model/Chat/chatModel";
|
||||||
|
import ChatMessageViewModel from "../../ViewModel/Chat/chatMessageViewModel";
|
||||||
|
import { translations } from "../translations";
|
||||||
|
|
||||||
|
export function MessageReactionButton(
|
||||||
|
chatMessageViewModel: ChatMessageViewModel,
|
||||||
|
content: ReactionSymbols,
|
||||||
|
) {
|
||||||
|
function sendReaction() {
|
||||||
|
chatMessageViewModel.sendReaction(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getUsername(): string {
|
||||||
|
return chatMessageViewModel.messagePageViewModel.chatViewModel
|
||||||
|
.settingsViewModel.username.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkIsHighlighted(mapState: React.MapState<any>): boolean {
|
||||||
|
return mapState.value.has(getUsername());
|
||||||
|
}
|
||||||
|
|
||||||
|
let audioLabel: string;
|
||||||
|
let count: React.State<number>;
|
||||||
|
let isActive: React.State<boolean>;
|
||||||
|
|
||||||
|
switch (content) {
|
||||||
|
case ReactionSymbols.ThumbsUp: {
|
||||||
|
audioLabel = translations.chatPage.message.thumbsUpReaction;
|
||||||
|
count = chatMessageViewModel.reactionsThumbsUpCount;
|
||||||
|
isActive = React.createProxyState(
|
||||||
|
[chatMessageViewModel.reactionsThumbsUp],
|
||||||
|
() =>
|
||||||
|
checkIsHighlighted(chatMessageViewModel.reactionsThumbsUp),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ReactionSymbols.Check: {
|
||||||
|
audioLabel = translations.chatPage.message.checkReaction;
|
||||||
|
count = chatMessageViewModel.reactionsCheckCount;
|
||||||
|
isActive = React.createProxyState(
|
||||||
|
[chatMessageViewModel.reactionsCheck],
|
||||||
|
() => checkIsHighlighted(chatMessageViewModel.reactionsCheck),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ReactionSymbols.Attention: {
|
||||||
|
audioLabel = translations.chatPage.message.attentionReaction;
|
||||||
|
count = chatMessageViewModel.reactionsAttentionCount;
|
||||||
|
isActive = React.createProxyState(
|
||||||
|
[chatMessageViewModel.reactionsAttention],
|
||||||
|
() =>
|
||||||
|
checkIsHighlighted(chatMessageViewModel.reactionsAttention),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ReactionSymbols.DoubleAttention: {
|
||||||
|
audioLabel = translations.chatPage.message.doubleAttentionReaction;
|
||||||
|
count = chatMessageViewModel.reactionsDoubleAttentionCount;
|
||||||
|
isActive = React.createProxyState(
|
||||||
|
[chatMessageViewModel.reactionsDoubleAttention],
|
||||||
|
() =>
|
||||||
|
checkIsHighlighted(
|
||||||
|
chatMessageViewModel.reactionsDoubleAttention,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ReactionSymbols.Question: {
|
||||||
|
audioLabel = translations.chatPage.message.questionReaction;
|
||||||
|
count = chatMessageViewModel.reactionsQuestionCount;
|
||||||
|
isActive = React.createProxyState(
|
||||||
|
[chatMessageViewModel.reactionsQuestion],
|
||||||
|
() =>
|
||||||
|
checkIsHighlighted(chatMessageViewModel.reactionsQuestion),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
class="flex"
|
||||||
|
on:click={sendReaction}
|
||||||
|
aria-label={audioLabel}
|
||||||
|
toggle:selected={isActive}
|
||||||
|
>
|
||||||
|
{content}
|
||||||
|
<span subscribe:innerText={count}></span>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@ import * as React from "bloatless-react";
|
|||||||
|
|
||||||
import ChatMessageViewModel from "../../ViewModel/Chat/chatMessageViewModel";
|
import ChatMessageViewModel from "../../ViewModel/Chat/chatMessageViewModel";
|
||||||
import { translations } from "../translations";
|
import { translations } from "../translations";
|
||||||
|
import { ReactionSymbols } from "../../Model/Chat/chatModel";
|
||||||
|
import { MessageReactionButton } from "../Components/messageReactionButton";
|
||||||
|
|
||||||
export function ChatMessageInfoModal(
|
export function ChatMessageInfoModal(
|
||||||
chatMessageViewModel: ChatMessageViewModel,
|
chatMessageViewModel: ChatMessageViewModel,
|
||||||
@@ -87,6 +89,31 @@ export function ChatMessageInfoModal(
|
|||||||
<span class="icon">key</span>
|
<span class="icon">key</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr></hr>
|
||||||
|
|
||||||
|
<div class="flex-row gap">
|
||||||
|
{MessageReactionButton(
|
||||||
|
chatMessageViewModel,
|
||||||
|
ReactionSymbols.ThumbsUp,
|
||||||
|
)}
|
||||||
|
{MessageReactionButton(
|
||||||
|
chatMessageViewModel,
|
||||||
|
ReactionSymbols.Check,
|
||||||
|
)}
|
||||||
|
{MessageReactionButton(
|
||||||
|
chatMessageViewModel,
|
||||||
|
ReactionSymbols.Attention,
|
||||||
|
)}
|
||||||
|
{MessageReactionButton(
|
||||||
|
chatMessageViewModel,
|
||||||
|
ReactionSymbols.DoubleAttention,
|
||||||
|
)}
|
||||||
|
{MessageReactionButton(
|
||||||
|
chatMessageViewModel,
|
||||||
|
ReactionSymbols.Question,
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<button on:click={chatMessageViewModel.hideInfoModal}>
|
<button on:click={chatMessageViewModel.hideInfoModal}>
|
||||||
{translations.general.closeButton}
|
{translations.general.closeButton}
|
||||||
|
|||||||
@@ -186,6 +186,14 @@ const englishTranslations = {
|
|||||||
resendMessageButton: "Resend message",
|
resendMessageButton: "Resend message",
|
||||||
decryptMessageButton: "Decrypt message",
|
decryptMessageButton: "Decrypt message",
|
||||||
deleteMessageButton: "Delete message",
|
deleteMessageButton: "Delete message",
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
thumbsUpReaction: "Reaction: thumbs up",
|
||||||
|
checkReaction: "Reaction: check",
|
||||||
|
attentionReaction: "Reaction: exclamation mark",
|
||||||
|
doubleAttentionReaction: "Reaction: double exclamation mark",
|
||||||
|
questionReaction: "Reaction: question mark",
|
||||||
},
|
},
|
||||||
|
|
||||||
task: {
|
task: {
|
||||||
@@ -449,6 +457,14 @@ const allTranslations: { [language: string]: typeof englishTranslations } = {
|
|||||||
resendMessageButton: "Nachricht erneut senden",
|
resendMessageButton: "Nachricht erneut senden",
|
||||||
decryptMessageButton: "Nachricht entschlüsseln",
|
decryptMessageButton: "Nachricht entschlüsseln",
|
||||||
deleteMessageButton: "Nachricht löschen",
|
deleteMessageButton: "Nachricht löschen",
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
thumbsUpReaction: "Reaktion: Daumen hoch",
|
||||||
|
checkReaction: "Reaktion: Haken",
|
||||||
|
attentionReaction: "Reaktion: Ausrufezeichen",
|
||||||
|
doubleAttentionReaction: "Reaktion: doppeltes Ausrufezeichen",
|
||||||
|
questionReaction: "Reaktion: Fragezeichen",
|
||||||
},
|
},
|
||||||
|
|
||||||
task: {
|
task: {
|
||||||
@@ -694,6 +710,14 @@ const allTranslations: { [language: string]: typeof englishTranslations } = {
|
|||||||
resendMessageButton: "Reenviar mensaje",
|
resendMessageButton: "Reenviar mensaje",
|
||||||
decryptMessageButton: "Desencriptar mensaje",
|
decryptMessageButton: "Desencriptar mensaje",
|
||||||
deleteMessageButton: "Eliminar mensaje",
|
deleteMessageButton: "Eliminar mensaje",
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
thumbsUpReaction: "Reacción: pulgar hacia arriba",
|
||||||
|
checkReaction: "Reacción: marca de verificación",
|
||||||
|
attentionReaction: "Reaccion: signo de atención",
|
||||||
|
doubleAttentionReaction: "Reaccion: signo de atención doble",
|
||||||
|
questionReaction: "Reaccion: signo de interrogación",
|
||||||
},
|
},
|
||||||
|
|
||||||
task: {
|
task: {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
ChatMessageReaction,
|
ChatMessageReaction,
|
||||||
ChatMessageReactionReference,
|
ChatMessageReactionReference,
|
||||||
ChatMessageStatus,
|
ChatMessageStatus,
|
||||||
ReactionSymbol,
|
ReactionSymbols,
|
||||||
} from "../../Model/Chat/chatModel";
|
} from "../../Model/Chat/chatModel";
|
||||||
|
|
||||||
import CoreViewModel from "../Global/coreViewModel";
|
import CoreViewModel from "../Global/coreViewModel";
|
||||||
@@ -31,6 +31,27 @@ export default class ChatMessageViewModel {
|
|||||||
reactionsDoubleAttention = new React.MapState<ChatMessageReaction>();
|
reactionsDoubleAttention = new React.MapState<ChatMessageReaction>();
|
||||||
reactionsQuestion = new React.MapState<ChatMessageReaction>();
|
reactionsQuestion = new React.MapState<ChatMessageReaction>();
|
||||||
|
|
||||||
|
reactionsThumbsUpCount = React.createProxyState(
|
||||||
|
[this.reactionsThumbsUp],
|
||||||
|
() => this.reactionsThumbsUp.value.size,
|
||||||
|
);
|
||||||
|
reactionsCheckCount = React.createProxyState(
|
||||||
|
[this.reactionsCheck],
|
||||||
|
() => this.reactionsCheck.value.size,
|
||||||
|
);
|
||||||
|
reactionsAttentionCount = React.createProxyState(
|
||||||
|
[this.reactionsAttention],
|
||||||
|
() => this.reactionsAttention.value.size,
|
||||||
|
);
|
||||||
|
reactionsDoubleAttentionCount = React.createProxyState(
|
||||||
|
[this.reactionsDoubleAttention],
|
||||||
|
() => this.reactionsDoubleAttention.value.size,
|
||||||
|
);
|
||||||
|
reactionsQuestionCount = React.createProxyState(
|
||||||
|
[this.reactionsQuestion],
|
||||||
|
() => this.reactionsQuestion.value.size,
|
||||||
|
);
|
||||||
|
|
||||||
// state
|
// state
|
||||||
isPresentingInfoModal: React.State<boolean> = new React.State(false);
|
isPresentingInfoModal: React.State<boolean> = new React.State(false);
|
||||||
|
|
||||||
@@ -57,22 +78,26 @@ export default class ChatMessageViewModel {
|
|||||||
// reactions
|
// reactions
|
||||||
addReaction = (reaction: ChatMessageReaction): void => {
|
addReaction = (reaction: ChatMessageReaction): void => {
|
||||||
switch (reaction.content) {
|
switch (reaction.content) {
|
||||||
case "👍":
|
case ReactionSymbols.ThumbsUp:
|
||||||
return this.reactionsThumbsUp.set(reaction.fileId, reaction);
|
return this.reactionsThumbsUp.set(reaction.sender, reaction);
|
||||||
case "✅":
|
case ReactionSymbols.Check:
|
||||||
return this.reactionsCheck.set(reaction.fileId, reaction);
|
return this.reactionsCheck.set(reaction.sender, reaction);
|
||||||
case "❗️":
|
case ReactionSymbols.Attention:
|
||||||
return this.reactionsAttention.set(reaction.fileId, reaction);
|
return this.reactionsAttention.set(reaction.sender, reaction);
|
||||||
case "‼️":
|
case ReactionSymbols.DoubleAttention:
|
||||||
return this.reactionsDoubleAttention.set(
|
return this.reactionsDoubleAttention.set(
|
||||||
reaction.fileId,
|
reaction.sender,
|
||||||
reaction,
|
reaction,
|
||||||
);
|
);
|
||||||
case "❓":
|
case ReactionSymbols.Question:
|
||||||
return this.reactionsQuestion.set(reaction.fileId, reaction);
|
return this.reactionsQuestion.set(reaction.sender, reaction);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sendReaction = (content: ReactionSymbols): void => {
|
||||||
|
this.messagePageViewModel.sendReaction(this.chatMessage.id, content);
|
||||||
|
};
|
||||||
|
|
||||||
// load
|
// load
|
||||||
loadData = (): void => {
|
loadData = (): void => {
|
||||||
this.channel = this.chatMessage.channel;
|
this.channel = this.chatMessage.channel;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import * as React from "bloatless-react";
|
|||||||
import {
|
import {
|
||||||
ChatMessage,
|
ChatMessage,
|
||||||
ChatMessageReaction,
|
ChatMessageReaction,
|
||||||
ReactionSymbol,
|
ReactionSymbols,
|
||||||
} from "../../Model/Chat/chatModel";
|
} from "../../Model/Chat/chatModel";
|
||||||
import ChatMessageViewModel from "../Chat/chatMessageViewModel";
|
import ChatMessageViewModel from "../Chat/chatMessageViewModel";
|
||||||
import ChatViewModel from "../Chat/chatViewModel";
|
import ChatViewModel from "../Chat/chatViewModel";
|
||||||
@@ -41,7 +41,7 @@ export default class MessagePageViewModel {
|
|||||||
messageViewModel.loadData();
|
messageViewModel.loadData();
|
||||||
};
|
};
|
||||||
|
|
||||||
sendReaction = (messageId: string, content: ReactionSymbol): void => {
|
sendReaction = (messageId: string, content: ReactionSymbols): void => {
|
||||||
this.chatViewModel.chatModel.sendReaction(messageId, content);
|
this.chatViewModel.chatModel.sendReaction(messageId, content);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user