diff --git a/src/components/Apps/AppsDesktop.tsx b/src/components/Apps/AppsDesktop.tsx index 0b50a94..121dd6e 100644 --- a/src/components/Apps/AppsDesktop.tsx +++ b/src/components/Apps/AppsDesktop.tsx @@ -301,7 +301,6 @@ export const AppsDesktop = ({ mode, setMode, show , myName, goToHome, setDesktop }; }, [tabs]); - return ( )} {mode !== 'home' && ( - + )} diff --git a/src/components/Apps/AppsNavBarDesktop.tsx b/src/components/Apps/AppsNavBarDesktop.tsx index 480436b..f42e45b 100644 --- a/src/components/Apps/AppsNavBarDesktop.tsx +++ b/src/components/Apps/AppsNavBarDesktop.tsx @@ -63,7 +63,7 @@ export function saveToLocalStorage(key, subKey, newValue) { } } -export const AppsNavBarDesktop = () => { +export const AppsNavBarDesktop = ({disableBack}) => { const [tabs, setTabs] = useState([]); const [selectedTab, setSelectedTab] = useState(null); const [navigationController, setNavigationController] = useRecoilState(navigationControllerAtom) @@ -107,10 +107,11 @@ export const AppsNavBarDesktop = () => { const isDisableBackButton = useMemo(()=> { + if(disableBack) return true if(selectedTab && navigationController[selectedTab?.tabId]?.hasBack) return false if(selectedTab && !navigationController[selectedTab?.tabId]?.hasBack) return true return false - }, [navigationController, selectedTab]) + }, [navigationController, selectedTab, disableBack]) diff --git a/src/components/Apps/useQortalMessageListener.tsx b/src/components/Apps/useQortalMessageListener.tsx index 631eaa6..00bff36 100644 --- a/src/components/Apps/useQortalMessageListener.tsx +++ b/src/components/Apps/useQortalMessageListener.tsx @@ -481,7 +481,7 @@ isDOMContentLoaded: false } else if ( event?.data?.action === 'PUBLISH_MULTIPLE_QDN_RESOURCES' || event?.data?.action === 'PUBLISH_QDN_RESOURCE' || - event?.data?.action === 'ENCRYPT_DATA' || event?.data?.action === 'ENCRYPT_DATA_WITH_SHARING_KEY' || 'ENCRYPT_QORTAL_GROUP_DATA' + event?.data?.action === 'ENCRYPT_DATA' || event?.data?.action === 'ENCRYPT_DATA_WITH_SHARING_KEY' || event?.data?.action === 'ENCRYPT_QORTAL_GROUP_DATA' ) { let data; diff --git a/src/components/Embeds/AttachmentEmbed.tsx b/src/components/Embeds/AttachmentEmbed.tsx index 1ca14f0..3b78d74 100644 --- a/src/components/Embeds/AttachmentEmbed.tsx +++ b/src/components/Embeds/AttachmentEmbed.tsx @@ -28,6 +28,7 @@ import DownloadIcon from "@mui/icons-material/Download"; import SaveIcon from '@mui/icons-material/Save'; import { useSetRecoilState } from "recoil"; import { blobControllerAtom } from "../../atoms/global"; +import { decodeIfEncoded } from "../../utils/decode"; export const AttachmentCard = ({ @@ -181,7 +182,7 @@ export const AttachmentCard = ({ color: "white", }} > - Created by {owner} + Created by {decodeIfEncoded(owner)} { const pollName = name; diff --git a/src/components/Embeds/ImageEmbed.tsx b/src/components/Embeds/ImageEmbed.tsx index d54e836..0ac1a7c 100644 --- a/src/components/Embeds/ImageEmbed.tsx +++ b/src/components/Embeds/ImageEmbed.tsx @@ -17,6 +17,7 @@ import OpenInNewIcon from "@mui/icons-material/OpenInNew"; import { CustomLoader } from "../../common/CustomLoader"; import ImageIcon from "@mui/icons-material/Image"; import CloseIcon from "@mui/icons-material/Close"; +import { decodeIfEncoded } from "../../utils/decode"; export const ImageCard = ({ image, @@ -37,11 +38,11 @@ export const ImageCard = ({ } }, [isOpen]); - useEffect(()=> { - if(errorMsg){ - setHeight('300px') - } - }, [errorMsg]) + // useEffect(()=> { + // if(errorMsg){ + // setHeight('300px') + // } + // }, [errorMsg]) return ( - Created by {owner} + Created by {decodeIfEncoded(owner)} { + const now = Date.now(); // Current timestamp in milliseconds + const fifteenMinutes = 15 * 60 * 1000; // 15 minutes in milliseconds + + return now - timestamp < fifteenMinutes; +}; + export const getPublishesFromAdmins = async (admins: string[], groupId) => { // const validApi = await findUsableApi(); const queryString = admins.map((name) => `name=${name}`).join("&"); @@ -909,7 +917,7 @@ export const Group = ({ if (message?.action === "SET_GROUPS") { // Update the component state with the received 'sendqort' state - setGroups(message.payload); + setGroups(sortArrayByTimestampAndGroupName(message.payload)); getLatestRegularChat(message.payload); setMemberGroups(message.payload); diff --git a/src/utils/decode.ts b/src/utils/decode.ts new file mode 100644 index 0000000..3123810 --- /dev/null +++ b/src/utils/decode.ts @@ -0,0 +1,16 @@ +export function decodeIfEncoded(input) { + try { + // Check if input is URI-encoded by encoding and decoding + const encoded = encodeURIComponent(decodeURIComponent(input)); + if (encoded === input) { + // Input is URI-encoded, so decode it + return decodeURIComponent(input); + } + } catch (e) { + // decodeURIComponent throws an error if input is not encoded + console.error("Error decoding URI:", e); + } + + // Return input as-is if not URI-encoded + return input; + } \ No newline at end of file diff --git a/src/utils/time.ts b/src/utils/time.ts index 77a0daf..b0a27cf 100644 --- a/src/utils/time.ts +++ b/src/utils/time.ts @@ -35,4 +35,22 @@ export function formatTimestamp(timestamp: number): string { const date = moment(unixTimestamp, 'x').fromNow() return date + } + + export function sortArrayByTimestampAndGroupName(array) { + return array.sort((a, b) => { + if (a.timestamp && b.timestamp) { + // Both have timestamp, sort by timestamp descending + return b.timestamp - a.timestamp; + } else if (a.timestamp) { + // Only `a` has timestamp, it comes first + return -1; + } else if (b.timestamp) { + // Only `b` has timestamp, it comes first + return 1; + } else { + // Neither has timestamp, sort alphabetically by groupName + return a.groupName.localeCompare(b.groupName); + } + }); } \ No newline at end of file