fix: improve currency regex and split membership gift types for better tracking

This commit is contained in:
Yusuf İpek
2025-10-05 04:42:47 +03:00
parent 773d35e85e
commit aef59fb291
4 changed files with 45 additions and 77 deletions
+10 -3
View File
@@ -195,10 +195,16 @@ function extractSuperChatInfo(item: any): SuperChatInfo | undefined {
let currency = ''; let currency = '';
if (amountText) { if (amountText) {
const match = amountText.match(/^([\$\€\£\¥\₹\₺A-Z]+)?\s*([\d,\.]+)/); // Regex to capture currency symbol/code and amount
// Handles: $5.00, €5,00, 5,00 €, 5.00 USD, TRY5.00
const match = amountText.match(/([\$\€\£\¥\₹\₺A-Z]+)?\s*([\d,\.,]+)\s*([\$\€\£\¥\₹\₺A-Z]+)?/);
if (match) { if (match) {
currency = match[1] || ''; // Prefer currency symbol before the number, fallback to after
currency = match[1] || match[3] || '';
amount = match[2]; amount = match[2];
} else {
// Fallback for cases where only the number is present
amount = amountText;
} }
} }
@@ -262,7 +268,8 @@ function normalizeAction(action: any): ChatMessage | null {
isMember, isMember,
isVerified, isVerified,
superChat: extractSuperChatInfo(item), superChat: extractSuperChatInfo(item),
membershipGift: isMembership || isGiftPurchase || isGiftReceived, membershipGift: isMembership || isGiftReceived,
membershipGiftPurchase: isGiftPurchase,
membershipLevel membershipLevel
}; };
} }
+1 -1
View File
@@ -54,7 +54,7 @@ export default function DashboardPage() {
}, [pollError, overlayStatus]); }, [pollError, overlayStatus]);
const superChats = useMemo(() => messages.filter(m => m.superChat), [messages]); const superChats = useMemo(() => messages.filter(m => m.superChat), [messages]);
const newMembers = useMemo(() => messages.filter(m => m.membershipGift), [messages]); const newMembers = useMemo(() => messages.filter(m => m.membershipGiftPurchase), [messages]);
const regularMessages = useMemo(() => messages.filter(m => !m.superChat && !m.membershipGift), [messages]); const regularMessages = useMemo(() => messages.filter(m => !m.superChat && !m.membershipGift), [messages]);
return ( return (
+33 -73
View File
@@ -518,7 +518,8 @@ main {
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
padding-right: 0.25rem; padding-right: 0.5rem; /* Add space for scrollbar */
margin-right: -0.5rem; /* Pull scrollbar into padding */
padding-bottom: 1rem; /* Add space at the bottom */ padding-bottom: 1rem; /* Add space at the bottom */
min-height: 0; min-height: 0;
} }
@@ -637,6 +638,7 @@ main {
font-size: 0.9rem; font-size: 0.9rem;
color: #fff; color: #fff;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
align-self: flex-start; /* Align to the left */
} }
.chatItem__membership { .chatItem__membership {
@@ -839,19 +841,17 @@ main {
} }
.overlay__card { .overlay__card {
padding: 2rem 2.5rem; background: #1f1f1f;
border-radius: 24px; border: 1px solid #3a3a3a;
background: linear-gradient(135deg, #0f172a, #1e293b); border-radius: 8px;
border: 2px solid rgba(96, 165, 250, 0.3); padding: 1rem 1.5rem;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; gap: 0.75rem;
text-align: center; width: min(100% - 2rem, 600px);
gap: 1.5rem; max-width: 95vw;
min-width: min(600px, 90vw);
max-width: min(900px, 95vw);
animation: fadeIn 0.4s ease-out; animation: fadeIn 0.4s ease-out;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
} }
.overlay__card--fadeOut { .overlay__card--fadeOut {
@@ -860,96 +860,56 @@ main {
.overlay__header { .overlay__header {
display: flex; display: flex;
gap: 1rem; gap: 0.75rem;
align-items: center;
justify-content: center;
width: 100%;
padding-bottom: 1rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.overlay__header > div {
display: flex;
flex-direction: column;
align-items: center; align-items: center;
} }
.overlay__avatar { .overlay__avatar {
width: 56px; width: 40px;
height: 56px; height: 40px;
border-radius: 50%; border-radius: 50%;
object-fit: cover; object-fit: cover;
border: 3px solid rgba(96, 165, 250, 0.5); border: 2px solid #3a3a3a;
box-shadow: 0 4px 12px rgba(96, 165, 250, 0.3);
} }
.overlay__authorLine { .overlay__authorLine {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; gap: 0.5rem;
gap: 0.75rem;
flex-wrap: wrap;
} }
.overlay__author { .overlay__author {
font-size: 1.4rem; font-size: 1rem;
font-weight: 700; font-weight: 600;
color: #60a5fa; color: #e5e7eb;
text-shadow: 0 2px 8px rgba(96, 165, 250, 0.4);
} }
.overlay__badge { .overlay__badge {
font-size: 1.2rem; font-size: 0.9rem;
padding: 0.25rem 0.5rem;
border-radius: 6px;
display: inline-flex;
align-items: center;
} }
.overlay__badge--moderator { .overlay__superchat,
background: rgba(239, 68, 68, 0.3); .overlay__membership {
border: 1px solid rgba(239, 68, 68, 0.5); padding: 0.6rem 1rem;
} border-radius: 8px;
font-weight: 600;
.overlay__badge--member { font-size: 0.9rem;
background: rgba(34, 197, 94, 0.3);
border: 1px solid rgba(34, 197, 94, 0.5);
}
.overlay__badge--verified {
background: rgba(59, 130, 246, 0.3);
border: 1px solid rgba(59, 130, 246, 0.5);
}
.overlay__superchat {
padding: 1rem 1.5rem;
border-radius: 12px;
font-weight: 700;
font-size: 1.2rem;
color: #fff; color: #fff;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); align-self: flex-start;
text-align: center;
} }
.overlay__membership { .overlay__membership {
padding: 1rem 1.5rem;
background: linear-gradient(135deg, #10b981, #059669); background: linear-gradient(135deg, #10b981, #059669);
border-radius: 12px;
font-weight: 700;
font-size: 1.2rem;
color: #fff;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
text-align: center;
} }
.overlay__text { .overlay__text {
font-size: clamp(1.5rem, 2.5vw, 2.2rem); font-size: 1.1rem;
line-height: 1.5; line-height: 1.5;
color: #f1f5f9; color: #d1d5db;
font-weight: 500; font-weight: 400;
text-align: center; text-align: left;
word-break: break-word;
} }
.overlay__placeholder { .overlay__placeholder {
+1
View File
@@ -22,5 +22,6 @@ export type ChatMessage = {
isVerified?: boolean; isVerified?: boolean;
superChat?: SuperChatInfo; superChat?: SuperChatInfo;
membershipGift?: boolean; membershipGift?: boolean;
membershipGiftPurchase?: boolean;
membershipLevel?: string; // e.g., "New member", "Member (6 months)", etc. membershipLevel?: string; // e.g., "New member", "Member (6 months)", etc.
}; };