Weiter am Dating gearbeitet
Some checks failed
Host-Based Deploy (Java 21 Fix) / build-and-run (push) Has been cancelled
Some checks failed
Host-Based Deploy (Java 21 Fix) / build-and-run (push) Has been cancelled
This commit is contained in:
@@ -700,6 +700,11 @@
|
||||
}
|
||||
html += ` <button onclick="openMeldungDialog('PROFIL','${profile.userId}')" style="background:none;border:1px solid var(--color-secondary);color:var(--color-muted);border-radius:6px;padding:0.4rem 0.8rem;cursor:pointer;font-size:0.85rem;">⚑ Melden</button>`;
|
||||
actions.innerHTML = html;
|
||||
|
||||
// Dating-Like-Button – nur anzeigen wenn Ziel-User Dating aktiviert hat
|
||||
if (profile.datingAktiv) {
|
||||
loadDatingLikeButton(profile.userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1410,6 +1415,60 @@
|
||||
});
|
||||
|
||||
// esc, fmtDate, toggleEmojiPicker, insertEmoji kommen aus shared.js
|
||||
|
||||
// ── Dating-Like auf Profilseite ──────────────────────────────────────────
|
||||
async function loadDatingLikeButton(targetUserId) {
|
||||
// Nur einblenden wenn eigener User Dating aktiviert hat
|
||||
const meRes = await fetch('/login/me');
|
||||
if (!meRes.ok) return;
|
||||
const me = await meRes.json();
|
||||
if (!me.datingAktiv) return;
|
||||
|
||||
let liked = false;
|
||||
try {
|
||||
const idsRes = await fetch('/dating/liked-by-me');
|
||||
if (idsRes.ok) {
|
||||
const ids = await idsRes.json();
|
||||
liked = ids.includes(targetUserId);
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
const btn = document.createElement('button');
|
||||
btn.id = 'datingLikeBtn';
|
||||
btn.title = liked ? 'Unlike' : 'Like';
|
||||
btn.style.cssText = 'padding:0.4rem 0.9rem;font-size:0.9rem;' +
|
||||
(liked ? 'background:var(--color-primary);color:#fff;' : 'background:none;border:1px solid var(--color-primary);color:var(--color-primary);') +
|
||||
'border-radius:6px;cursor:pointer;';
|
||||
btn.textContent = liked ? '♥ Liked' : '♥ Liken';
|
||||
btn.addEventListener('click', async () => {
|
||||
btn.disabled = true;
|
||||
try {
|
||||
const res = await fetch('/dating/like/' + targetUserId, { method: 'POST' });
|
||||
if (!res.ok) return;
|
||||
const data = await res.json();
|
||||
liked = data.liked;
|
||||
btn.textContent = liked ? '♥ Liked' : '♥ Liken';
|
||||
btn.title = liked ? 'Unlike' : 'Like';
|
||||
btn.style.background = liked ? 'var(--color-primary)' : 'none';
|
||||
btn.style.color = liked ? '#fff' : 'var(--color-primary)';
|
||||
btn.style.border = liked ? 'none' : '1px solid var(--color-primary)';
|
||||
if (data.newMatch) {
|
||||
const t = document.createElement('div');
|
||||
t.textContent = '🎉 Es ist ein Match!';
|
||||
Object.assign(t.style, {
|
||||
position:'fixed', bottom:'2rem', left:'50%', transform:'translateX(-50%)',
|
||||
background:'var(--color-primary)', color:'#fff', padding:'0.75rem 1.5rem',
|
||||
borderRadius:'8px', fontWeight:'700', zIndex:'999'
|
||||
});
|
||||
document.body.appendChild(t);
|
||||
setTimeout(() => t.remove(), 3500);
|
||||
}
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
}
|
||||
});
|
||||
document.getElementById('profileActions').appendChild(btn);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user