From 5144a8341aabf1d5f943cc821ea80ea720df9e7f Mon Sep 17 00:00:00 2001 From: QuickMythril Date: Mon, 2 Dec 2024 19:01:00 -0500 Subject: [PATCH 01/12] Add ADMIN_ACTION types to manage peers and minting accounts --- src/qortalRequests/get.ts | 59 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/src/qortalRequests/get.ts b/src/qortalRequests/get.ts index fa59def..c7f7046 100644 --- a/src/qortalRequests/get.ts +++ b/src/qortalRequests/get.ts @@ -3169,6 +3169,20 @@ export const adminAction = async (data, isFromExtension) => { missingFields.push(field); } }); + // For actions that require a value, check for 'value' field + const actionsRequiringValue = [ + "addpeer", + "removepeer", + "forcesync", + "addmintingaccount", + "removemintingaccount", + ]; + if ( + actionsRequiringValue.includes(data.type.toLowerCase()) && + !data.value + ) { + missingFields.push("value"); + } if (missingFields.length > 0) { const missingFieldsString = missingFields.join(", "); const errorMsg = `Missing fields: ${missingFieldsString}`; @@ -3180,6 +3194,8 @@ export const adminAction = async (data, isFromExtension) => { } let apiEndpoint = ""; + let method = "GET"; // Default method + let includeValueInBody = false; switch (data.type.toLowerCase()) { case "stop": apiEndpoint = await createEndpoint("/admin/stop"); @@ -3190,19 +3206,58 @@ export const adminAction = async (data, isFromExtension) => { case "bootstrap": apiEndpoint = await createEndpoint("/admin/bootstrap"); break; + case "addmintingaccount": + apiEndpoint = await createEndpoint("/admin/mintingaccounts"); + method = "POST"; + includeValueInBody = true; + break; + case "removemintingaccount": + apiEndpoint = await createEndpoint("/admin/mintingaccounts"); + method = "DELETE"; + includeValueInBody = true; + break; + case "forcesync": + apiEndpoint = await createEndpoint("/admin/forcesync"); + method = "POST"; + includeValueInBody = true; + break; + case "addpeer": + apiEndpoint = await createEndpoint("/peers"); + method = "POST"; + includeValueInBody = true; + break; + case "removepeer": + apiEndpoint = await createEndpoint("/peers"); + method = "DELETE"; + includeValueInBody = true; + break; default: throw new Error(`Unknown admin action type: ${data.type}`); } + // Prepare the permission prompt text + let permissionText = `Do you give this application permission to perform the admin action: ${data.type}`; + if (data.value) { + permissionText += ` with value: ${data.value}`; + } const resPermission = await getUserPermission( { - text1: `Do you give this application permission to perform a node ${data.type}?`, + text1: permissionText, }, isFromExtension ); const { accepted } = resPermission; if (accepted) { - const response = await fetch(apiEndpoint); + // Set up options for the API call + const options: RequestInit = { + method: method, + headers: {}, + }; + if (includeValueInBody) { + options.headers["Content-Type"] = "text/plain"; + options.body = data.value; + } + const response = await fetch(apiEndpoint, options); if (!response.ok) throw new Error("Failed to perform request"); let res; From f9f25f962743c12ea3b0464c6e8555a0ceecc718 Mon Sep 17 00:00:00 2001 From: QuickMythril Date: Tue, 3 Dec 2024 03:05:38 -0500 Subject: [PATCH 02/12] added popover for reactions --- src/components/Chat/MessageItem.tsx | 81 +++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 9 deletions(-) diff --git a/src/components/Chat/MessageItem.tsx b/src/components/Chat/MessageItem.tsx index 47d4417..507fc12 100644 --- a/src/components/Chat/MessageItem.tsx +++ b/src/components/Chat/MessageItem.tsx @@ -1,8 +1,8 @@ import { Message } from "@chatscope/chat-ui-kit-react"; -import React, { useEffect } from "react"; +import React, { useEffect, useState } from "react"; import { useInView } from "react-intersection-observer"; import { MessageDisplay } from "./MessageDisplay"; -import { Avatar, Box, ButtonBase, Typography } from "@mui/material"; +import { Avatar, Box, Button, ButtonBase, List, ListItem, ListItemText, Popover, Typography } from "@mui/material"; import { formatTimestamp } from "../../utils/time"; import { getBaseApi } from "../../background"; import { getBaseApiReact } from "../../App"; @@ -40,6 +40,8 @@ export const MessageItem = ({ triggerOnce: false, // Only trigger once when it becomes visible }); + const [anchorEl, setAnchorEl] = useState(null); + const [selectedReaction, setSelectedReaction] = useState(null); useEffect(() => { @@ -246,17 +248,15 @@ export const MessageItem = ({ // const myReaction = reactions if(numberOfReactions === 0) return null return ( - { - if(reactions[reaction] && reactions[reaction]?.find((item)=> item?.sender === myAddress)){ - handleReaction(reaction, message, false) - } else { - handleReaction(reaction, message, true) - } + }} onClick={(event) => { + event.stopPropagation(); // Prevent event bubbling + setAnchorEl(event.currentTarget); + setSelectedReaction(reaction); }}>
+ {selectedReaction && ( + { + setAnchorEl(null); + setSelectedReaction(null); + }} + anchorOrigin={{ + vertical: "top", + horizontal: "center", + }} + transformOrigin={{ + vertical: "bottom", + horizontal: "center", + }} + PaperProps={{ + style: { + backgroundColor: "#232428", + color: "white", + }, + }} + > + + + People who reacted with {selectedReaction} + + + {reactions[selectedReaction]?.map((reactionItem) => ( + + + + ))} + + + + + )} Date: Tue, 3 Dec 2024 04:08:59 -0500 Subject: [PATCH 03/12] show group chats without secret key --- src/components/Chat/ChatGroup.tsx | 1 - src/components/Group/Group.tsx | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/Chat/ChatGroup.tsx b/src/components/Chat/ChatGroup.tsx index 9d38ce8..f5039c0 100644 --- a/src/components/Chat/ChatGroup.tsx +++ b/src/components/Chat/ChatGroup.tsx @@ -182,7 +182,6 @@ const [messageSize, setMessageSize] = useState(0) try { if(!secretKeyRef.current){ checkForFirstSecretKeyNotification(encryptedMessages) - return } return new Promise((res, rej)=> { window.sendMessage("decryptSingle", { diff --git a/src/components/Group/Group.tsx b/src/components/Group/Group.tsx index df1f0c3..5cf00ef 100644 --- a/src/components/Group/Group.tsx +++ b/src/components/Group/Group.tsx @@ -2487,8 +2487,7 @@ export const Group = ({ handleNewEncryptionNotification={ setNewEncryptionNotification } - hide={groupSection !== "chat" || !secretKey || selectedDirect || newChat} - hideView={!(desktopViewMode === 'chat' && selectedGroup)} + hide={groupSection !== "chat" || selectedDirect || newChat} handleSecretKeyCreationInProgress={ handleSecretKeyCreationInProgress } @@ -2542,6 +2541,10 @@ export const Group = ({ Wait until an admin re-encrypts the keys. + + Only unencrypted messages will be displayed. + + Try notifying an admin from the list of admins below: From 6cf438708093b6a70580bd8c804001fd49936738 Mon Sep 17 00:00:00 2001 From: QuickMythril Date: Tue, 3 Dec 2024 04:14:01 -0500 Subject: [PATCH 04/12] restore unintentionally removed code --- src/components/Group/Group.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Group/Group.tsx b/src/components/Group/Group.tsx index 5cf00ef..51cdc76 100644 --- a/src/components/Group/Group.tsx +++ b/src/components/Group/Group.tsx @@ -2488,6 +2488,7 @@ export const Group = ({ setNewEncryptionNotification } hide={groupSection !== "chat" || selectedDirect || newChat} + hideView={!(desktopViewMode === 'chat' && selectedGroup)} handleSecretKeyCreationInProgress={ handleSecretKeyCreationInProgress } From 6eb7250c5328ada78dd8a135f76803f1eb589ad8 Mon Sep 17 00:00:00 2001 From: PhilReact Date: Tue, 3 Dec 2024 12:46:20 +0200 Subject: [PATCH 05/12] added max width and height to reaction list --- src/components/Chat/MessageItem.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Chat/MessageItem.tsx b/src/components/Chat/MessageItem.tsx index 507fc12..bd2d86c 100644 --- a/src/components/Chat/MessageItem.tsx +++ b/src/components/Chat/MessageItem.tsx @@ -296,7 +296,11 @@ export const MessageItem = ({ People who reacted with {selectedReaction} - + {reactions[selectedReaction]?.map((reactionItem) => ( Date: Tue, 3 Dec 2024 13:00:59 +0200 Subject: [PATCH 06/12] hide chat options and editor if no secretKey --- src/components/Chat/ChatGroup.tsx | 8 +++++--- src/components/Chat/ChatList.tsx | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/Chat/ChatGroup.tsx b/src/components/Chat/ChatGroup.tsx index f5039c0..4ff4f94 100644 --- a/src/components/Chat/ChatGroup.tsx +++ b/src/components/Chat/ChatGroup.tsx @@ -746,9 +746,9 @@ const clearEditorContent = () => { left: hide && '-100000px', }}> - + - + {!!secretKey && (
{ )} - + +
{messageSize > 750 && ( { {/* */}
+ )} {isOpenQManager !== null && ( { const parentRef = useRef(); const [messages, setMessages] = useState(initialMessages); @@ -406,7 +407,7 @@ export const ChatList = ({ )} - {enableMentions && ( + {enableMentions && hasSecretKey && ( Date: Tue, 3 Dec 2024 14:01:07 +0200 Subject: [PATCH 07/12] move send btn to the side, changed add group label --- src/components/Chat/ChatDirect.tsx | 39 +++++++++--------------------- src/components/Chat/ChatGroup.tsx | 37 ++++++++-------------------- src/components/Group/AddGroup.tsx | 2 +- src/components/Group/Group.tsx | 2 +- 4 files changed, 24 insertions(+), 56 deletions(-) diff --git a/src/components/Chat/ChatDirect.tsx b/src/components/Chat/ChatDirect.tsx index cbd5b6e..cb40066 100644 --- a/src/components/Chat/ChatDirect.tsx +++ b/src/components/Chat/ChatDirect.tsx @@ -580,7 +580,7 @@ useEffect(() => { backgroundColor: "#232428", minHeight: isMobile ? '0px' : '150px', display: 'flex', - flexDirection: 'column', + flexDirection: 'row', overflow: 'hidden', width: '100%', boxSizing: 'border-box', @@ -596,14 +596,17 @@ useEffect(() => { flexDirection: 'column', flexGrow: isMobile && 1, overflow: !isMobile && "auto", - flexShrink: 0 + flexShrink: 0, + width: 'calc(100% - 100px)', + justifyContent: 'flex-end' }}> {replyMessage && ( @@ -660,34 +663,14 @@ useEffect(() => { )} - {isFocusedParent && ( - { - if(isSending) return - setIsFocusedParent(false) - clearEditorContent() - // Unfocus the editor - }} - style={{ - marginTop: 'auto', - alignSelf: 'center', - cursor: isSending ? 'default' : 'pointer', - background: 'red', - flexShrink: 0, - padding: isMobile && '5px' - }} - > - - {` Close`} - - - )} + { if(messageSize > 4000) return @@ -701,7 +684,9 @@ useEffect(() => { cursor: isSending ? 'default' : 'pointer', background: isSending && 'rgba(0, 0, 0, 0.8)', flexShrink: 0, - padding: isMobile && '5px' + padding: '5px', + width: '100px', + minWidth: 'auto' }} > {isSending && ( diff --git a/src/components/Chat/ChatGroup.tsx b/src/components/Chat/ChatGroup.tsx index 4ff4f94..b7e15d8 100644 --- a/src/components/Chat/ChatGroup.tsx +++ b/src/components/Chat/ChatGroup.tsx @@ -755,7 +755,7 @@ const clearEditorContent = () => { backgroundColor: "#232428", minHeight: isMobile ? '0px' : '150px', display: 'flex', - flexDirection: 'column', + flexDirection: 'row', overflow: 'hidden', width: '100%', boxSizing: 'border-box', @@ -766,12 +766,15 @@ const clearEditorContent = () => { zIndex: isFocusedParent ? 5 : 'unset', flexShrink: 0 }}> +
{replyMessage && ( { )} - {isFocusedParent && ( - { - if(isSending) return - setIsFocusedParent(false) - clearEditorContent() - // Unfocus the editor - }} - style={{ - marginTop: 'auto', - alignSelf: 'center', - cursor: isSending ? 'default' : 'pointer', - background: 'red', - flexShrink: 0, - padding: isMobile && '5px' - }} - > - - {` Close`} - - - )} + { if(messageSize > 4000) return @@ -877,7 +859,9 @@ const clearEditorContent = () => { cursor: isSending ? 'default' : 'pointer', background: isSending && 'rgba(0, 0, 0, 0.8)', flexShrink: 0, - padding: isMobile && '5px', + padding: '5px', + width: '100px', + minWidth: 'auto' }} > @@ -898,7 +882,6 @@ const clearEditorContent = () => { - {/* */}
)} {isOpenQManager !== null && ( diff --git a/src/components/Group/AddGroup.tsx b/src/components/Group/AddGroup.tsx index f4c6e6d..ed90c8c 100644 --- a/src/components/Group/AddGroup.tsx +++ b/src/components/Group/AddGroup.tsx @@ -194,7 +194,7 @@ export const AddGroup = ({ address, open, setOpen }) => { - Add Group + Group Mgmt - Add Group + Group Mgmt
)} {chatMode === "directs" && ( From 1587d093ea6457dc2c42b3ebf6f2e8d3ed50060f Mon Sep 17 00:00:00 2001 From: PhilReact Date: Tue, 3 Dec 2024 15:21:42 +0200 Subject: [PATCH 08/12] added input for qortallinks --- src/components/Apps/AppsHomeDesktop.tsx | 80 ++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/src/components/Apps/AppsHomeDesktop.tsx b/src/components/Apps/AppsHomeDesktop.tsx index 6481871..ebae36a 100644 --- a/src/components/Apps/AppsHomeDesktop.tsx +++ b/src/components/Apps/AppsHomeDesktop.tsx @@ -7,20 +7,37 @@ import { AppsContainer, AppsParent, } from "./Apps-styles"; -import { Avatar, ButtonBase } from "@mui/material"; +import { Avatar, Box, ButtonBase, Input } from "@mui/material"; import { Add } from "@mui/icons-material"; import { getBaseApiReact, isMobile } from "../../App"; import LogoSelected from "../../assets/svgs/LogoSelected.svg"; import { executeEvent } from "../../utils/events"; import { Spacer } from "../../common/Spacer"; import { SortablePinnedApps } from "./SortablePinnedApps"; - +import { extractComponents } from "../Chat/MessageDisplay"; +import ArrowOutwardIcon from '@mui/icons-material/ArrowOutward'; export const AppsHomeDesktop = ({ setMode, myApp, myWebsite, availableQapps, }) => { + const [qortalUrl, setQortalUrl] = useState('') + + const openQortalUrl = ()=> { + try { + if(!qortalUrl) return + const res = extractComponents(qortalUrl); + if (res) { + const { service, name, identifier, path } = res; + executeEvent("addTab", { data: { service, name, identifier, path } }); + executeEvent("open-apps-mode", { }); + setQortalUrl('qortal://') + } + } catch (error) { + + } + } return ( <> + + + + { + setQortalUrl(e.target.value) + }} + disableUnderline + autoComplete='off' + autoCorrect='off' + placeholder="qortal://" + sx={{ + width: '100%', + color: 'white', + '& .MuiInput-input::placeholder': { + color: 'rgba(84, 84, 84, 0.70) !important', + fontSize: '20px', + fontStyle: 'normal', + fontWeight: 400, + lineHeight: '120%', // 24px + letterSpacing: '0.15px', + opacity: 1 + }, + '&:focus': { + outline: 'none', + }, + // Add any additional styles for the input here + }} + onKeyDown={(e) => { + if (e.key === 'Enter' && qortalUrl) { + console.log('hello') + openQortalUrl(); + } + }} + /> + openQortalUrl()}> + + + + Date: Wed, 4 Dec 2024 09:43:44 +0200 Subject: [PATCH 09/12] fix typo --- src/components/Chat/CreateCommonSecret.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Chat/CreateCommonSecret.tsx b/src/components/Chat/CreateCommonSecret.tsx index 2e2088a..c371c55 100644 --- a/src/components/Chat/CreateCommonSecret.tsx +++ b/src/components/Chat/CreateCommonSecret.tsx @@ -152,7 +152,7 @@ export const CreateCommonSecret = ({groupId, secretKey, isOwner, myAddress, sec maxWidth: '350px', background: '#444444' }}> - Re-encyrpt key + Re-encrypt key {noSecretKey ? ( There is no group secret key. Be the first admin to publish one! From b8d715594e3cb4693c9111537cb66a47317943aa Mon Sep 17 00:00:00 2001 From: PhilReact Date: Thu, 5 Dec 2024 14:11:29 +0200 Subject: [PATCH 10/12] fix scrolldown when new msg --- src/components/Chat/ChatList.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/Chat/ChatList.tsx b/src/components/Chat/ChatList.tsx index 8c16c93..3cae591 100644 --- a/src/components/Chat/ChatList.tsx +++ b/src/components/Chat/ChatList.tsx @@ -37,6 +37,7 @@ export const ChatList = ({ const hasLoadedInitialRef = useRef(false); const scrollingIntervalRef = useRef(null); + const lastSeenUnreadMessageTimestamp = useRef(null); // Initialize the virtualizer @@ -108,7 +109,7 @@ export const ChatList = ({ setTimeout(() => { const hasUnreadMessages = totalMessages.some( - (msg) => msg.unread && !msg?.chatReference && !msg?.isTemp + (msg) => msg.unread && !msg?.chatReference && !msg?.isTemp && (!msg?.chatReference && msg?.timestamp > lastSeenUnreadMessageTimestamp.current || 0) ); if (parentRef.current) { const { scrollTop, scrollHeight, clientHeight } = parentRef.current; @@ -152,6 +153,7 @@ export const ChatList = ({ })) ); setShowScrollButton(false); + lastSeenUnreadMessageTimestamp.current = Date.now() }, []); const sentNewMessageGroupFunc = useCallback(() => { @@ -385,7 +387,7 @@ export const ChatList = ({ Scroll to Unread Messages )} - {showScrollDownButton && ( + {showScrollDownButton && !showScrollButton && (