mirror of
https://github.com/fromchat-messenger/web.git
synced 2026-09-22 19:15:08 +03:00
Fix the structure
This commit is contained in:
@@ -6,15 +6,16 @@ import type { UserProfile } from "../../../core/types";
|
|||||||
import { UserProfileDialog } from "./UserProfileDialog";
|
import { UserProfileDialog } from "./UserProfileDialog";
|
||||||
import { MessageContextMenu, type ContextMenuState } from "./MessageContextMenu";
|
import { MessageContextMenu, type ContextMenuState } from "./MessageContextMenu";
|
||||||
import { fetchUserProfile } from "../../api/profileApi";
|
import { fetchUserProfile } from "../../api/profileApi";
|
||||||
import { useState } from "react";
|
import { useState, type ReactNode } from "react";
|
||||||
import { delay } from "../../../utils/utils";
|
import { delay } from "../../../utils/utils";
|
||||||
import { request } from "../../../websocket";
|
import { request } from "../../../websocket";
|
||||||
|
|
||||||
interface ChatMessagesProps {
|
interface ChatMessagesProps {
|
||||||
messages?: MessageType[];
|
messages?: MessageType[];
|
||||||
|
children?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ChatMessages({ messages: propMessages }: ChatMessagesProps) {
|
export function ChatMessages({ messages: propMessages, children }: ChatMessagesProps) {
|
||||||
const { messages: hookMessages } = useChat();
|
const { messages: hookMessages } = useChat();
|
||||||
const { user } = useAppState();
|
const { user } = useAppState();
|
||||||
|
|
||||||
@@ -137,6 +138,7 @@ export function ChatMessages({ messages: propMessages }: ChatMessagesProps) {
|
|||||||
isLoadingProfile={isLoadingProfile}
|
isLoadingProfile={isLoadingProfile}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
{children}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UserProfileDialog
|
<UserProfileDialog
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { useState, useEffect, useRef } from "react";
|
import { useState, useEffect, useRef } from "react";
|
||||||
import { MessagePanel, type MessagePanelState } from "../../panels/MessagePanel";
|
import { MessagePanel, type MessagePanelState } from "../../panels/MessagePanel";
|
||||||
import { ChatMainHeader } from "./ChatMainHeader";
|
|
||||||
import { ChatMessages } from "./ChatMessages";
|
import { ChatMessages } from "./ChatMessages";
|
||||||
import { ChatInputWrapper } from "./ChatInputWrapper";
|
import { ChatInputWrapper } from "./ChatInputWrapper";
|
||||||
import defaultAvatar from "../../../resources/images/default-avatar.png";
|
import defaultAvatar from "../../../resources/images/default-avatar.png";
|
||||||
@@ -106,8 +105,8 @@ export function MessagePanelRenderer({ panel, isChatSwitching }: MessagePanelRen
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="chat-messages" id="chat-messages">
|
|
||||||
{panelState.isLoading ? (
|
{panelState.isLoading ? (
|
||||||
|
<div className="chat-messages" id="chat-messages">
|
||||||
<div style={{
|
<div style={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
@@ -117,13 +116,12 @@ export function MessagePanelRenderer({ panel, isChatSwitching }: MessagePanelRen
|
|||||||
}}>
|
}}>
|
||||||
Loading messages...
|
Loading messages...
|
||||||
</div>
|
</div>
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<ChatMessages messages={panelState.messages} />
|
|
||||||
<div ref={messagesEndRef} />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
): (
|
||||||
|
<ChatMessages messages={panelState.messages}>
|
||||||
|
<div ref={messagesEndRef} />
|
||||||
|
</ChatMessages>
|
||||||
|
)}
|
||||||
|
|
||||||
<ChatInputWrapper onSendMessage={panel.handleSendMessage} />
|
<ChatInputWrapper onSendMessage={panel.handleSendMessage} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user