mirror of
https://github.com/Qortal/qortal-mobile.git
synced 2025-03-14 20:02:33 +00:00
fixes
This commit is contained in:
parent
e22072db72
commit
03d0bf0177
@ -64,7 +64,7 @@ export function saveToLocalStorage(key, subKey, newValue) {
|
||||
}
|
||||
}
|
||||
|
||||
export const AppsNavBar = () => {
|
||||
export const AppsNavBar = ({appsMode}) => {
|
||||
const [tabs, setTabs] = useState([]);
|
||||
const [selectedTab, setSelectedTab] = useState(null);
|
||||
const [isNewTabWindow, setIsNewTabWindow] = useState(false);
|
||||
@ -77,10 +77,11 @@ export const AppsNavBar = () => {
|
||||
const [navigationController, setNavigationController] = useRecoilState(navigationControllerAtom)
|
||||
|
||||
const isDisableBackButton = useMemo(()=> {
|
||||
if(isNewTabWindow && appsMode === 'viewer') return true
|
||||
if(selectedTab && navigationController[selectedTab?.tabId]?.hasBack) return false
|
||||
if(selectedTab && !navigationController[selectedTab?.tabId]?.hasBack) return true
|
||||
return false
|
||||
}, [navigationController, selectedTab])
|
||||
}, [navigationController, selectedTab, isNewTabWindow, appsMode])
|
||||
|
||||
const setSettingsLocalLastUpdated = useSetRecoilState(
|
||||
settingsLocalLastUpdatedAtom
|
||||
|
@ -479,7 +479,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;
|
||||
|
@ -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 = ({
|
||||
@ -206,7 +207,7 @@ export const AttachmentCard = ({
|
||||
color: "white",
|
||||
}}
|
||||
>
|
||||
Created by {owner}
|
||||
Created by {decodeIfEncoded(owner)}
|
||||
</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
|
@ -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 (
|
||||
<Card
|
||||
@ -113,7 +114,7 @@ export const ImageCard = ({
|
||||
color: "white",
|
||||
}}
|
||||
>
|
||||
Created by {owner}
|
||||
Created by {decodeIfEncoded(owner)}
|
||||
</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
|
@ -96,6 +96,7 @@ import { useHandleMobileNativeBack } from "../../hooks/useHandleMobileNativeBack
|
||||
import { AdminSpace } from "../Chat/AdminSpace";
|
||||
import { useSetRecoilState } from "recoil";
|
||||
import { selectedGroupIdAtom } from "../../atoms/global";
|
||||
import { sortArrayByTimestampAndGroupName } from "../../utils/time";
|
||||
|
||||
// let touchStartY = 0;
|
||||
// let disablePullToRefresh = false;
|
||||
@ -910,7 +911,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);
|
||||
|
||||
@ -2673,7 +2674,7 @@ export const Group = ({
|
||||
)}
|
||||
{(isMobile && mobileViewMode === "apps" && appsMode !== 'home') && !mobileViewModeKeepOpen && (
|
||||
<>
|
||||
<AppsNavBar />
|
||||
<AppsNavBar appsMode={appsMode} />
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
|
16
src/utils/decode.ts
Normal file
16
src/utils/decode.ts
Normal file
@ -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;
|
||||
}
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user