fix height

This commit is contained in:
PhilReact 2024-09-21 15:07:37 +03:00
parent bcf22ca5e0
commit 5a8f21bfb9
6 changed files with 33 additions and 13 deletions

View File

@ -129,7 +129,7 @@ const defaultValues: MyContextInterface = {
message: "",
},
};
export let isMobile = true
export let isMobile = false
const isMobileDevice = () => {
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
@ -313,6 +313,7 @@ function App() {
const [apiKey, setApiKey] = useState("");
const [isOpenSendQort, setIsOpenSendQort] = useState(false)
const [isOpenSendQortSuccess, setIsOpenSendQortSuccess] = useState(false)
const [rootHeight, setRootHeight] = useState('100%')
useEffect(() => {
if(!isMobile) return
// Function to set the height of the app to the viewport height
@ -320,6 +321,7 @@ function App() {
const height = window.visualViewport ? window.visualViewport.height : window.innerHeight;
// Set the height to the root element (usually #root)
document.getElementById('root').style.height = height + "px";
setRootHeight(height + "px")
};
// Set the initial height
@ -1619,6 +1621,7 @@ function App() {
onOk,
show,
message,
rootHeight
}}
>
<Box

View File

@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react'
import { objectToBase64 } from '../../qdn/encryption/group-encryption'
import { ChatList } from './ChatList'
@ -46,6 +46,11 @@ export const ChatDirect = ({ myAddress, isNewChat, selectedDirect, setSelectedDi
const setEditorRef = (editorInstance) => {
editorRef.current = editorInstance;
};
const [, forceUpdate] = useReducer((x) => x + 1, 0);
const triggerRerender = () => {
forceUpdate(); // Trigger re-render by updating the state
};
const publicKeyOfRecipientRef = useRef(null)
console.log({messages})
const getPublicKeyFunc = async (address)=> {
@ -276,6 +281,9 @@ const clearEditorContent = () => {
editorRef.current?.chain().blur().run();
setIsFocusedParent(false)
executeEvent("sent-new-message-group", {})
setTimeout(() => {
triggerRerender();
}, 300);
}, 200);
}
}

View File

@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react'
import { CreateCommonSecret } from './CreateCommonSecret'
import { reusableGet } from '../../qdn/publish/pubish'
import { uint8ArrayToObject } from '../../backgroundFunctions/encryption'
@ -44,7 +44,11 @@ export const ChatGroup = ({selectedGroup, secretKey, setSecretKey, getSecretKey,
const groupSocketTimeoutRef = useRef(null); // Group Socket Timeout reference
const editorRef = useRef(null);
const { queueChats, addToQueue, processWithNewMessages } = useMessageQueue();
const [, forceUpdate] = useReducer((x) => x + 1, 0);
const triggerRerender = () => {
forceUpdate(); // Trigger re-render by updating the state
};
const setEditorRef = (editorInstance) => {
editorRef.current = editorInstance;
};
@ -292,6 +296,9 @@ const clearEditorContent = () => {
editorRef.current?.chain().blur().run();
setIsFocusedParent(false)
executeEvent("sent-new-message-group", {})
setTimeout(() => {
triggerRerender();
}, 300);
}, 200);
}
}

View File

@ -143,7 +143,7 @@ export const GroupAnnouncements = ({
const [selectedAnnouncement, setSelectedAnnouncement] = useState(null);
const [isFocusedParent, setIsFocusedParent] = useState(false);
const { show } = React.useContext(MyContext);
const { show, rootHeight } = React.useContext(MyContext);
const [openSnack, setOpenSnack] = React.useState(false);
const [infoSnack, setInfoSnack] = React.useState(null);
const hasInitialized = useRef(false);
@ -488,7 +488,7 @@ export const GroupAnnouncements = ({
<div
style={{
// reference to change height
height: isMobile ? `calc(${getRootHeight()} - 127px` : "100vh",
height: isMobile ? `calc(${rootHeight} - 127px` : "100vh",
display: "flex",
flexDirection: "column",
width: "100%",
@ -514,7 +514,7 @@ export const GroupAnnouncements = ({
<div
style={{
// reference to change height
height: isMobile ? `calc(${getRootHeight()} - 127px` : "100vh",
height: isMobile ? `calc(${rootHeight} - 127px` : "100vh",
display: "flex",
flexDirection: "column",
width: "100%",

View File

@ -1,12 +1,13 @@
import React, {
useCallback,
useContext,
useEffect,
useMemo,
useRef,
useState,
} from "react";
import { GroupMail } from "../Group/Forum/GroupMail";
import { isMobile } from "../../App";
import { MyContext, isMobile } from "../../App";
import { getRootHeight } from "../../utils/mobile/mobileUtils";
@ -25,6 +26,7 @@ export const GroupForum = ({
defaultThread,
setDefaultThread
}) => {
const { rootHeight } = useContext(MyContext);
const [isMoved, setIsMoved] = useState(false);
useEffect(() => {
if (hide) {
@ -38,7 +40,7 @@ export const GroupForum = ({
<div
style={{
// reference to change height
height: isMobile ? `calc(${getRootHeight()} - 127px` : "100vh",
height: isMobile ? `calc(${rootHeight} - 127px` : "100vh",
display: "flex",
flexDirection: "column",
width: "100%",

View File

@ -398,7 +398,7 @@ export const Group = ({
const [openAddGroup, setOpenAddGroup] = useState(false);
const [isInitialGroups, setIsInitialGroups] = useState(false);
const [openManageMembers, setOpenManageMembers] = useState(false);
const { setMemberGroups, memberGroups } = useContext(MyContext);
const { setMemberGroups, memberGroups, rootHeight } = useContext(MyContext);
const lastGroupNotification = useRef<null | number>(null);
const [timestampEnterData, setTimestampEnterData] = useState({});
const [chatMode, setChatMode] = useState("groups");
@ -1552,7 +1552,7 @@ export const Group = ({
width: isMobile ? "100%" : "380px",
flexDirection: "column",
alignItems: "flex-start",
height: isMobile ? `calc(${getRootHeight()} - 45px)` : "100%",
height: isMobile ? `calc(${rootHeight} - 45px)` : "100%",
background: !isMobile && 'var(--bg-primary)',
borderRadius: !isMobile && '0px 15px 15px 0px'
}}
@ -2266,7 +2266,7 @@ export const Group = ({
top: "0px",
background: "#27282c",
zIndex: 5,
height: isMobile && `calc(${getRootHeight()} - 45px)`,
height: isMobile && `calc(${rootHeight} - 45px)`,
}}
>
<ChatDirect
@ -2542,7 +2542,7 @@ export const Group = ({
top: "0px",
background: "#27282c",
zIndex: 5,
height: isMobile && `calc(${getRootHeight()} - 45px)`,
height: isMobile && `calc(${rootHeight} - 45px)`,
}}
>
<Box