fhg
This commit is contained in:
@@ -745,7 +745,8 @@ class CommentSystem {
|
||||
// Render skeleton (Result: Layout visible immediately)
|
||||
// Skip when preserveScroll=true (tab re-focus refresh): the user already sees comments,
|
||||
// so wiping the DOM causes the browser to lose the #c anchor element and auto-scroll to top.
|
||||
if (!scrollToId && !preserveScroll) {
|
||||
// Only render skeleton for logged-in users to avoid flashing "Login to comment" before comments/permissions load.
|
||||
if (!scrollToId && !preserveScroll && this.user) {
|
||||
this.render([], this.user, initialIsSubscribed);
|
||||
this.restoreState(state);
|
||||
}
|
||||
|
||||
+22
-11
@@ -9168,7 +9168,7 @@ class NotificationSystem {
|
||||
// Restore mention placeholders
|
||||
content = content.replace(/\x02MNT(\d+)\x03/g, (_, i) => mentionStore[+i]);
|
||||
} catch (e) {
|
||||
console.error('Marked error in w0bm.js', e);
|
||||
console.error('Marked error:', e);
|
||||
// Fallback
|
||||
content = content.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
||||
content = content.replace(/^>(.*)/gm, '<span class="greentext">>$1</span>');
|
||||
@@ -10575,7 +10575,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const myHallsError = document.getElementById('my-halls-modal-error');
|
||||
|
||||
const isLoggedIn = window.f0ckSession && window.f0ckSession.logged_in;
|
||||
const csrf = window.f0ckSession?.csrf_token || '';
|
||||
const getCsrf = () => (window.f0ckSession && window.f0ckSession.csrf_token) || '';
|
||||
const csrf = getCsrf();
|
||||
|
||||
if (myHallsSection) {
|
||||
myHallsSection.style.display = isLoggedIn ? '' : 'none';
|
||||
@@ -10696,11 +10697,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
confirmBtn.disabled = true;
|
||||
confirmBtn.textContent = window.f0ckI18n?.hall_adding || 'Adding...';
|
||||
|
||||
const token = getCsrf();
|
||||
try {
|
||||
const resp = await fetch('/mod/halls/add', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: `id=${itemid}&hall=${encodeURIComponent(hallSlug)}`
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'X-CSRF-Token': token
|
||||
},
|
||||
body: `id=${itemid}&hall=${encodeURIComponent(hallSlug)}&csrf_token=${encodeURIComponent(token)}`
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (data.success) {
|
||||
@@ -10722,6 +10727,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const onMyHallConfirm = async () => {
|
||||
if (!myHallsSelect || !myHallsConfirmBtn || !myHallsError) return;
|
||||
let hallSlug = myHallsSelect.value;
|
||||
const token = getCsrf();
|
||||
|
||||
// Create new hall inline if requested
|
||||
if (!hallSlug && myHallsNewName && myHallsNewName.value.trim()) {
|
||||
@@ -10732,8 +10738,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
myHallsConfirmBtn.textContent = window.f0ckI18n?.hall_creating || 'Creating…';
|
||||
const r = await fetch('/api/v2/me/halls', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'x-csrf-token': csrf },
|
||||
body: JSON.stringify({ name: newName, slug: newSlug })
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': token },
|
||||
body: JSON.stringify({ name: newName, slug: newSlug, csrf_token: token })
|
||||
});
|
||||
const d = await r.json();
|
||||
if (!d.success) throw new Error(d.message || d.msg || 'Failed to create');
|
||||
@@ -10758,8 +10764,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
try {
|
||||
const resp = await fetch(`/api/v2/me/halls/${encodeURIComponent(hallSlug)}/items`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'x-csrf-token': csrf },
|
||||
body: JSON.stringify({ item_id: itemid })
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': token },
|
||||
body: JSON.stringify({ item_id: itemid, csrf_token: token })
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (data.success) {
|
||||
@@ -10796,11 +10802,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
if (!confirm(`Remove from hall "${hallSlug}"?`)) return;
|
||||
siteHallRemoveBtn.disabled = true;
|
||||
siteHallRemoveBtn.textContent = window.f0ckI18n?.hall_removing || 'Removing…';
|
||||
const token = getCsrf();
|
||||
try {
|
||||
const resp = await fetch('/mod/halls/remove', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: `id=${itemid}&hall=${encodeURIComponent(hallSlug)}`
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'X-CSRF-Token': token
|
||||
},
|
||||
body: `id=${itemid}&hall=${encodeURIComponent(hallSlug)}&csrf_token=${encodeURIComponent(token)}`
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (data.success) {
|
||||
@@ -10825,10 +10835,11 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
if (!slug) return;
|
||||
myHallsRemoveBtn.disabled = true;
|
||||
myHallsRemoveBtn.textContent = 'Removing…';
|
||||
const token = getCsrf();
|
||||
try {
|
||||
const resp = await fetch(`/api/v2/me/halls/${encodeURIComponent(slug)}/items/${itemid}`, {
|
||||
method: 'DELETE',
|
||||
headers: { 'x-csrf-token': csrf }
|
||||
headers: { 'X-CSRF-Token': token }
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (data.success) {
|
||||
|
||||
Reference in New Issue
Block a user