fix deletion of reactions by using username as reaction id
This commit is contained in:
Vendored
+31
-22
@@ -1261,8 +1261,11 @@
|
|||||||
if (!checkMatchesObjectStructure(reaction, ChatMessageReactionReference))
|
if (!checkMatchesObjectStructure(reaction, ChatMessageReactionReference))
|
||||||
return;
|
return;
|
||||||
const reactionPath = this.getReactionPath(reaction.fileId);
|
const reactionPath = this.getReactionPath(reaction.fileId);
|
||||||
const action = reaction.isDeleting ? this.storageModel.remove : this.storageModel.writeStringifiable;
|
if (reaction.isDeleting == true) {
|
||||||
action(reactionPath, reaction);
|
this.storageModel.remove(reactionPath);
|
||||||
|
} else {
|
||||||
|
this.storageModel.writeStringifiable(reactionPath, reaction);
|
||||||
|
}
|
||||||
this.reactionHandlerManager.trigger(reaction);
|
this.reactionHandlerManager.trigger(reaction);
|
||||||
};
|
};
|
||||||
this.handleMessageSent = (chatMessage) => {
|
this.handleMessageSent = (chatMessage) => {
|
||||||
@@ -1492,6 +1495,7 @@
|
|||||||
const fileContent = FileModel2.createFileContent(v4_default(), "reaction");
|
const fileContent = FileModel2.createFileContent(v4_default(), "reaction");
|
||||||
const reaction = {
|
const reaction = {
|
||||||
...fileContent,
|
...fileContent,
|
||||||
|
fileId: sender,
|
||||||
messageId,
|
messageId,
|
||||||
sender,
|
sender,
|
||||||
content,
|
content,
|
||||||
@@ -3939,9 +3943,6 @@
|
|||||||
|
|
||||||
// src/View/Components/messageReactionButton.tsx
|
// src/View/Components/messageReactionButton.tsx
|
||||||
function MessageReactionButton(chatMessageViewModel, content) {
|
function MessageReactionButton(chatMessageViewModel, content) {
|
||||||
let audioLabel;
|
|
||||||
let count;
|
|
||||||
let isActive;
|
|
||||||
function sendReaction() {
|
function sendReaction() {
|
||||||
chatMessageViewModel.sendReaction(content, isActive.value);
|
chatMessageViewModel.sendReaction(content, isActive.value);
|
||||||
}
|
}
|
||||||
@@ -3951,6 +3952,9 @@
|
|||||||
function checkIsHighlighted(mapState) {
|
function checkIsHighlighted(mapState) {
|
||||||
return mapState.value.has(getUsername());
|
return mapState.value.has(getUsername());
|
||||||
}
|
}
|
||||||
|
let audioLabel;
|
||||||
|
let count;
|
||||||
|
let isActive;
|
||||||
switch (content) {
|
switch (content) {
|
||||||
case "\u{1F44D}" /* ThumbsUp */: {
|
case "\u{1F44D}" /* ThumbsUp */: {
|
||||||
audioLabel = translations.chatPage.message.thumbsUpReaction;
|
audioLabel = translations.chatPage.message.thumbsUpReaction;
|
||||||
@@ -4013,6 +4017,26 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// src/View/Components/messageReactionButtonRow.tsx
|
||||||
|
function MessageReactionButtonRow(chatMessageViewModel) {
|
||||||
|
return /* @__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 */
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// src/View/Modals/chatMessageInfoModal.tsx
|
// src/View/Modals/chatMessageInfoModal.tsx
|
||||||
function ChatMessageInfoModal(chatMessageViewModel) {
|
function ChatMessageInfoModal(chatMessageViewModel) {
|
||||||
return /* @__PURE__ */ createElement(
|
return /* @__PURE__ */ createElement(
|
||||||
@@ -4027,22 +4051,7 @@
|
|||||||
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("hr", null), /* @__PURE__ */ createElement("div", { class: "flex-row gap" }, MessageReactionButton(
|
)))), /* @__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), MessageReactionButtonRow(chatMessageViewModel)), /* @__PURE__ */ createElement("button", { "on:click": chatMessageViewModel.hideInfoModal }, translations.general.closeButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "close")))
|
||||||
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")))
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4081,7 +4090,7 @@
|
|||||||
class: "icon",
|
class: "icon",
|
||||||
"subscribe:innerText": statusIcon
|
"subscribe:innerText": statusIcon
|
||||||
}
|
}
|
||||||
), chatMessageViewModel.dateSent)), /* @__PURE__ */ createElement("div", { class: "button-container" }, /* @__PURE__ */ createElement(
|
), chatMessageViewModel.dateSent), MessageReactionButtonRow(chatMessageViewModel)), /* @__PURE__ */ createElement("div", { class: "button-container" }, /* @__PURE__ */ createElement(
|
||||||
"button",
|
"button",
|
||||||
{
|
{
|
||||||
"on:click": chatMessageViewModel.showInfoModal,
|
"on:click": chatMessageViewModel.showInfoModal,
|
||||||
|
|||||||
@@ -112,8 +112,12 @@ export default class ChatModel {
|
|||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
const reactionPath: string[] = this.getReactionPath(reaction.fileId);
|
const reactionPath: string[] = this.getReactionPath(reaction.fileId);
|
||||||
const action = reaction.isDeleting ? this.storageModel.remove : this.storageModel.writeStringifiable;
|
|
||||||
action(reactionPath, reaction);
|
if (reaction.isDeleting == true) {
|
||||||
|
this.storageModel.remove(reactionPath);
|
||||||
|
} else {
|
||||||
|
this.storageModel.writeStringifiable(reactionPath, reaction);
|
||||||
|
}
|
||||||
this.reactionHandlerManager.trigger(reaction);
|
this.reactionHandlerManager.trigger(reaction);
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -213,7 +217,7 @@ export default class ChatModel {
|
|||||||
sendReaction = async (
|
sendReaction = async (
|
||||||
messageId: string,
|
messageId: string,
|
||||||
content: ReactionSymbols,
|
content: ReactionSymbols,
|
||||||
isDeleting: boolean,
|
isDeleting?: boolean,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
const nameAndChannel = this.getNameAndChannel();
|
const nameAndChannel = this.getNameAndChannel();
|
||||||
if (nameAndChannel == false) return;
|
if (nameAndChannel == false) return;
|
||||||
@@ -413,6 +417,7 @@ export default class ChatModel {
|
|||||||
const fileContent = FileModel.createFileContent(v4(), "reaction");
|
const fileContent = FileModel.createFileContent(v4(), "reaction");
|
||||||
const reaction: ChatMessageReaction = {
|
const reaction: ChatMessageReaction = {
|
||||||
...fileContent,
|
...fileContent,
|
||||||
|
fileId: sender,
|
||||||
|
|
||||||
messageId,
|
messageId,
|
||||||
sender,
|
sender,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { ChatMessageInfoModal } from "../Modals/chatMessageInfoModal";
|
|||||||
import { ChatMessageStatus } from "../../Model/Chat/chatModel";
|
import { ChatMessageStatus } from "../../Model/Chat/chatModel";
|
||||||
import ChatMessageViewModel from "../../ViewModel/Chat/chatMessageViewModel";
|
import ChatMessageViewModel from "../../ViewModel/Chat/chatMessageViewModel";
|
||||||
import { translations } from "../translations";
|
import { translations } from "../translations";
|
||||||
|
import { MessageReactionButtonRow } from "./messageReactionButtonRow";
|
||||||
|
|
||||||
export function ChatMessage(chatMessageViewModel: ChatMessageViewModel) {
|
export function ChatMessage(chatMessageViewModel: ChatMessageViewModel) {
|
||||||
const statusIcon = React.createProxyState(
|
const statusIcon = React.createProxyState(
|
||||||
@@ -43,6 +44,8 @@ export function ChatMessage(chatMessageViewModel: ChatMessageViewModel) {
|
|||||||
></span>
|
></span>
|
||||||
{chatMessageViewModel.dateSent}
|
{chatMessageViewModel.dateSent}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
{MessageReactionButtonRow(chatMessageViewModel)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="button-container">
|
<div class="button-container">
|
||||||
|
|||||||
@@ -7,10 +7,6 @@ export function MessageReactionButton(
|
|||||||
chatMessageViewModel: ChatMessageViewModel,
|
chatMessageViewModel: ChatMessageViewModel,
|
||||||
content: ReactionSymbols,
|
content: ReactionSymbols,
|
||||||
) {
|
) {
|
||||||
let audioLabel: string;
|
|
||||||
let count: React.State<number>;
|
|
||||||
let isActive: React.State<boolean>;
|
|
||||||
|
|
||||||
function sendReaction() {
|
function sendReaction() {
|
||||||
chatMessageViewModel.sendReaction(content, isActive.value);
|
chatMessageViewModel.sendReaction(content, isActive.value);
|
||||||
}
|
}
|
||||||
@@ -24,6 +20,10 @@ export function MessageReactionButton(
|
|||||||
return mapState.value.has(getUsername());
|
return mapState.value.has(getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let audioLabel: string;
|
||||||
|
let count: React.State<number>;
|
||||||
|
let isActive: React.State<boolean>;
|
||||||
|
|
||||||
switch (content) {
|
switch (content) {
|
||||||
case ReactionSymbols.ThumbsUp: {
|
case ReactionSymbols.ThumbsUp: {
|
||||||
audioLabel = translations.chatPage.message.thumbsUpReaction;
|
audioLabel = translations.chatPage.message.thumbsUpReaction;
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import * as React from "bloatless-react";
|
||||||
|
import { ReactionSymbols } from "../../Model/Chat/chatModel";
|
||||||
|
import ChatMessageViewModel from "../../ViewModel/Chat/chatMessageViewModel";
|
||||||
|
import { translations } from "../translations";
|
||||||
|
import { MessageReactionButton } from "./messageReactionButton";
|
||||||
|
|
||||||
|
export function MessageReactionButtonRow(
|
||||||
|
chatMessageViewModel: ChatMessageViewModel,
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,8 +2,7 @@ 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 { MessageReactionButtonRow } from "../Components/messageReactionButtonRow";
|
||||||
import { MessageReactionButton } from "../Components/messageReactionButton";
|
|
||||||
|
|
||||||
export function ChatMessageInfoModal(
|
export function ChatMessageInfoModal(
|
||||||
chatMessageViewModel: ChatMessageViewModel,
|
chatMessageViewModel: ChatMessageViewModel,
|
||||||
@@ -92,28 +91,7 @@ export function ChatMessageInfoModal(
|
|||||||
|
|
||||||
<hr></hr>
|
<hr></hr>
|
||||||
|
|
||||||
<div class="flex-row gap">
|
{MessageReactionButtonRow(chatMessageViewModel)}
|
||||||
{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}
|
||||||
|
|||||||
Reference in New Issue
Block a user