mirror of
https://github.com/pezkuwichain/pezkuwi-telegram-miniapp.git
synced 2026-04-21 23:37:55 +00:00
fix: chat message alignment + auto-refresh for all P2P screens
- TradeChat: use authUserId for sender matching (fixes all messages appearing on left side instead of bubble alignment) - BalanceCard: auto-refresh every 30s - OfferList: auto-refresh every 15s - MyOffers/MyTrades: auto-refresh every 15s when tab is active
This commit is contained in:
@@ -43,6 +43,8 @@ export function BalanceCard({
|
||||
|
||||
useEffect(() => {
|
||||
fetchBalances();
|
||||
const interval = setInterval(fetchBalances, 30000);
|
||||
return () => clearInterval(interval);
|
||||
}, [fetchBalances]);
|
||||
|
||||
const handleRefresh = () => {
|
||||
|
||||
@@ -56,6 +56,8 @@ export function OfferList({ adType, onAcceptOffer }: OfferListProps) {
|
||||
|
||||
useEffect(() => {
|
||||
fetchOffers(1);
|
||||
const interval = setInterval(() => fetchOffers(1), 15000);
|
||||
return () => clearInterval(interval);
|
||||
}, [fetchOffers]);
|
||||
|
||||
const handleAccept = (offer: P2POffer) => {
|
||||
|
||||
@@ -12,7 +12,7 @@ interface TradeChatProps {
|
||||
}
|
||||
|
||||
export function TradeChat({ tradeId, onClose }: TradeChatProps) {
|
||||
const { sessionToken, user } = useAuth();
|
||||
const { sessionToken, authUserId } = useAuth();
|
||||
const { t, isRTL } = useTranslation();
|
||||
const { hapticImpact } = useTelegram();
|
||||
|
||||
@@ -23,8 +23,6 @@ export function TradeChat({ tradeId, onClose }: TradeChatProps) {
|
||||
// eslint-disable-next-line no-undef
|
||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const userId = user?.id;
|
||||
|
||||
const fetchMessages = useCallback(async () => {
|
||||
if (!sessionToken) return;
|
||||
try {
|
||||
@@ -97,7 +95,7 @@ export function TradeChat({ tradeId, onClose }: TradeChatProps) {
|
||||
</div>
|
||||
) : (
|
||||
messages.map((msg) => {
|
||||
const isOwn = msg.sender_id === userId;
|
||||
const isOwn = msg.sender_id === authUserId;
|
||||
const isSystem = msg.message_type === 'system';
|
||||
return (
|
||||
<div
|
||||
|
||||
@@ -99,8 +99,12 @@ export function P2PSection() {
|
||||
useEffect(() => {
|
||||
if (activeTab === 'myAds') {
|
||||
fetchMyOffersFull();
|
||||
const interval = setInterval(fetchMyOffersFull, 15000);
|
||||
return () => clearInterval(interval);
|
||||
} else if (activeTab === 'myTrades') {
|
||||
fetchMyTrades();
|
||||
const interval = setInterval(fetchMyTrades, 15000);
|
||||
return () => clearInterval(interval);
|
||||
}
|
||||
}, [activeTab, fetchMyOffersFull, fetchMyTrades]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user