diff --git a/package.json b/package.json index f200536..ecdc333 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sociowire-frontend", "private": true, - "version": "0.0.64", + "version": "0.0.65", "type": "module", "scripts": { "dev": "vite --host 0.0.0.0", diff --git a/src/api/client.js b/src/api/client.js index 0114352..7dd3ac2 100644 --- a/src/api/client.js +++ b/src/api/client.js @@ -424,15 +424,16 @@ export async function votePostTruth(postId, vote) { throw new Error(text || "truth vote failed"); } const data = await res.json().catch(() => ({})); - // Normalize response - API may return { truth: {...} } or flat object + // Normalize response - API returns { ok: true, truth: {...} } const truth = data?.truth || data || {}; const voteCount = truth.vote_count ?? truth.total_votes ?? truth.count ?? 0; - const aiScore = truth.ai_score ?? truth.ai ?? truth.truth_score ?? 50; - const userScore = truth.user_score ?? truth.user ?? truth.truth_score ?? 50; + const aiScore = truth.ai_score ?? truth.ai ?? 50; + const truthScore = truth.truth_score ?? truth.TruthScore ?? 50; // Final calculated score + const userVoteEffect = truth.user_score ?? 0; // Vote effect (+/- points), not the score return { ai_score: aiScore, - user_score: userScore, - truth_score: userScore ?? aiScore, // Main display score + user_score: userVoteEffect, + truth_score: truthScore, // Main display score - the final calculated value total_votes: voteCount, vote_count: voteCount, user_vote: vote, // The vote that was just cast diff --git a/src/components/Map/markerManager.js b/src/components/Map/markerManager.js index f4c3d13..114688c 100644 --- a/src/components/Map/markerManager.js +++ b/src/components/Map/markerManager.js @@ -1329,7 +1329,7 @@ export function openCenteredOverlay({ map, post, theme, fullScreen = false }) {
-
+
${truth}
- Truth + + Truth
${ @@ -1385,76 +1417,6 @@ export function openCenteredOverlay({ map, post, theme, fullScreen = false }) {
-
- - -
-
- ${truth} - Truth Score -
-
-
-
-
- - -
-
👁 ${formatCount(viewCount)}
❤️ ${formatCount(likeCount)}
@@ -1502,16 +1464,32 @@ export function openCenteredOverlay({ map, post, theme, fullScreen = false }) {
${!isCamera ? ` -
+
${truth}
- Truth + + Truth
` : ''}
@@ -1575,76 +1569,6 @@ export function openCenteredOverlay({ map, post, theme, fullScreen = false }) { ${escapeHtml(data?.summary || postData?.snippet || "")}
-
- - -
-
- ${truth} - Truth Score -
-
-
-
-
- - -
-
👁 ${formatCount(viewCount)}
❤️ ${formatCount(likeCount)}
@@ -1941,13 +1865,12 @@ export function openCenteredOverlay({ map, post, theme, fullScreen = false }) { }); } - // Truth vote handlers (thumbs up/down) - const truthVoteSection = modalWrap.querySelector('.sw-truth-vote-section'); - if (truthVoteSection && postID > 0) { - const downvoteBtn = truthVoteSection.querySelector('.sw-truth-downvote'); - const upvoteBtn = truthVoteSection.querySelector('.sw-truth-upvote'); - const scoreDisplay = truthVoteSection.querySelector('.sw-truth-score-display'); - const railFill = truthVoteSection.querySelector('.sw-truth-rail-fill'); + // Truth vote handlers (thumbs up/down in truth badge) + const truthBadgeNew = modalWrap.querySelector('.sw-truth-badge'); + if (truthBadgeNew && postID > 0) { + const downvoteBtn = truthBadgeNew.querySelector('.sw-truth-downvote'); + const upvoteBtn = truthBadgeNew.querySelector('.sw-truth-upvote'); + const scoreDisplay = truthBadgeNew.querySelector('.sw-truth-badge-score'); let currentVote = null; let isVoting = false; @@ -1955,18 +1878,7 @@ export function openCenteredOverlay({ map, post, theme, fullScreen = false }) { if (scoreDisplay && Number.isFinite(newScore)) { const score = Math.round(newScore); scoreDisplay.textContent = String(score); - // Update color based on score - const color = score >= 70 ? '#34d399' : score >= 50 ? '#fbbf24' : '#f87171'; - const glow = score >= 70 ? 'rgba(52, 211, 153, 0.5)' : score >= 50 ? 'rgba(251, 191, 36, 0.5)' : 'rgba(248, 113, 113, 0.5)'; - scoreDisplay.style.color = color; - scoreDisplay.style.textShadow = `0 0 20px ${glow}`; - // Update rail - if (railFill) { - railFill.style.width = `${Math.min(100, Math.max(0, score))}%`; - const gradient = score >= 70 ? 'linear-gradient(90deg, #10b981, #34d399)' : score >= 50 ? 'linear-gradient(90deg, #f59e0b, #fbbf24)' : 'linear-gradient(90deg, #ef4444, #f87171)'; - railFill.style.background = gradient; - railFill.style.boxShadow = `0 0 8px ${glow}`; - } + scoreDisplay.style.background = truthColor(score); } }; @@ -1980,11 +1892,11 @@ export function openCenteredOverlay({ map, post, theme, fullScreen = false }) { // Visual feedback if (vote === 'true' && upvoteBtn) { - upvoteBtn.style.transform = 'scale(1.15)'; - upvoteBtn.style.background = 'rgba(52, 211, 153, 0.4)'; + upvoteBtn.style.transform = 'scale(1.2)'; + upvoteBtn.style.background = 'rgba(52, 211, 153, 0.5)'; } else if (vote === 'false' && downvoteBtn) { - downvoteBtn.style.transform = 'scale(1.15)'; - downvoteBtn.style.background = 'rgba(239, 68, 68, 0.4)'; + downvoteBtn.style.transform = 'scale(1.2)'; + downvoteBtn.style.background = 'rgba(239, 68, 68, 0.5)'; } try { @@ -2004,11 +1916,11 @@ export function openCenteredOverlay({ map, post, theme, fullScreen = false }) { setTimeout(() => { if (upvoteBtn) { upvoteBtn.style.transform = ''; - upvoteBtn.style.background = currentVote === 'true' ? 'rgba(52, 211, 153, 0.35)' : 'rgba(52, 211, 153, 0.15)'; + upvoteBtn.style.background = currentVote === 'true' ? 'rgba(52, 211, 153, 0.4)' : 'rgba(52, 211, 153, 0.15)'; } if (downvoteBtn) { downvoteBtn.style.transform = ''; - downvoteBtn.style.background = currentVote === 'false' ? 'rgba(239, 68, 68, 0.35)' : 'rgba(239, 68, 68, 0.15)'; + downvoteBtn.style.background = currentVote === 'false' ? 'rgba(239, 68, 68, 0.4)' : 'rgba(239, 68, 68, 0.15)'; } isVoting = false; }, 200);