Compare commits
16 Commits
comments-f
...
f0bm
| Author | SHA1 | Date | |
|---|---|---|---|
| 588ab3c3de | |||
| 46fb7067ed | |||
| 5815334e7b | |||
| 6bfb200626 | |||
| 166ba96f0f | |||
| a2ebea2ba3 | |||
| 91546a1f0d | |||
| 017ac4ca4c | |||
| cb31cfd85b | |||
| a5acc22c4a | |||
| dbcf39c3ba | |||
| 4d2fd7561f | |||
| c4bb21bc31 | |||
| 7d58acd5ed | |||
| 286791de0d | |||
| 1b8a9185bb |
1
add_index_tags_assign.sql
Normal file
1
add_index_tags_assign.sql
Normal file
@@ -0,0 +1 @@
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS tags_assign_tag_id_idx ON public.tags_assign (tag_id);
|
||||
@@ -3848,7 +3848,7 @@ input#s_avatar {
|
||||
/* Comments System */
|
||||
#comments-container {
|
||||
padding: 0px 5px 5px 5px;
|
||||
background: var(--metadata-bg);
|
||||
background: #00000087;
|
||||
color: var(--white);
|
||||
font-family: var(--font);
|
||||
}
|
||||
@@ -3941,7 +3941,7 @@ input#s_avatar {
|
||||
.comment-input textarea {
|
||||
width: 100%;
|
||||
min-height: 80px;
|
||||
background: var(--bg);
|
||||
background: #000000a1;
|
||||
border: 1px solid var(--gray);
|
||||
color: var(--white);
|
||||
padding: 10px;
|
||||
@@ -4028,6 +4028,11 @@ input#s_avatar {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#comment-sort, #subscribe-btn, #lock-thread-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* Admin buttons */
|
||||
.admin-edit-btn,
|
||||
.admin-delete-btn {
|
||||
|
||||
@@ -53,9 +53,8 @@ class CommentSystem {
|
||||
// If comments are already rendered, we might need to re-render them to show emojis
|
||||
// but usually loadComments also happens async.
|
||||
// To be safe, if we just got emojis, trigger a silent update if container exists
|
||||
if (this.container && this.container.querySelector('.comment-content')) {
|
||||
// This is a bit heavy, but ensures emojis appear if they loaded AFTER comments
|
||||
// For now let's just let it be.
|
||||
if (this.container && this.lastData) {
|
||||
this.render(this.lastData, this.lastUserId, this.lastIsSubscribed);
|
||||
}
|
||||
} else {
|
||||
this.customEmojis = {};
|
||||
@@ -188,6 +187,11 @@ class CommentSystem {
|
||||
}
|
||||
|
||||
render(comments, currentUserId, isSubscribed) {
|
||||
// Store for re-rendering when emojis load
|
||||
this.lastData = comments;
|
||||
this.lastUserId = currentUserId;
|
||||
this.lastIsSubscribed = isSubscribed;
|
||||
|
||||
// Build two-level tree: top-level comments + all replies at one level
|
||||
const map = new Map();
|
||||
const roots = [];
|
||||
|
||||
@@ -47,7 +47,7 @@ export default new class {
|
||||
tmp = "items.id in (select item_id from tags_assign where tag_id = 2 group by item_id)";
|
||||
break;
|
||||
case 2: // untagged
|
||||
tmp = "items.id not in (select item_id from tags_assign group by item_id)";
|
||||
tmp = "not exists (select 1 from tags_assign where item_id = items.id)";
|
||||
break;
|
||||
case 3: // all
|
||||
tmp = "1 = 1";
|
||||
@@ -94,7 +94,7 @@ export default new class {
|
||||
const untagged = +(await db`
|
||||
select count(*) as total
|
||||
from "items"
|
||||
where id not in (select item_id from tags_assign group by item_id) and active = true
|
||||
where not exists (select 1 from tags_assign where item_id = items.id) and active = true
|
||||
`)[0].total;
|
||||
const sfw = +(await db`
|
||||
select count(*) as total
|
||||
|
||||
@@ -33,7 +33,7 @@ export default {
|
||||
${o.fav ? db`and "user".user ilike ${'%' + user + '%'}` : db``}
|
||||
${!o.fav && user ? db`and items.username ilike ${'%' + user + '%'}` : db``}
|
||||
${mime ? db`and items.mime ilike ${smime}` : db``}
|
||||
${!o.session && globalfilter ? db`and items.id not in (select item_id from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db``}
|
||||
${!o.session && globalfilter ? db`and not exists (select 1 from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db``}
|
||||
group by items.id, tags.tag
|
||||
`)?.length || 0;
|
||||
|
||||
@@ -67,7 +67,7 @@ export default {
|
||||
${o.fav ? db`and "user".user ilike ${'%' + user + '%'}` : db``}
|
||||
${!o.fav && user ? db`and items.username ilike ${'%' + user + '%'}` : db``}
|
||||
${mime ? db`and items.mime ilike ${smime}` : db``}
|
||||
${!o.session && globalfilter ? db`and items.id not in (select item_id from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db``}
|
||||
${!o.session && globalfilter ? db`and not exists (select 1 from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db``}
|
||||
group by items.id, tags.tag, ta.tag_id
|
||||
order by items.id desc
|
||||
offset ${offset}
|
||||
@@ -131,7 +131,7 @@ export default {
|
||||
${o.fav ? db`and "user"."user" ilike ${user}` : db``}
|
||||
${!o.fav && user ? db`and items.username ilike ${'%' + user + '%'}` : db``}
|
||||
${mime ? db`and items.mime ilike ${smime}` : db``}
|
||||
${!o.session && globalfilter ? db`and items.id not in (select item_id from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db``}
|
||||
${!o.session && globalfilter ? db`and not exists (select 1 from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db``}
|
||||
group by items.id, tags.tag, ta.tag_id
|
||||
order by items.id desc
|
||||
`;
|
||||
@@ -234,7 +234,7 @@ export default {
|
||||
and "user".user ilike ${'%' + user + '%'}
|
||||
and items.active = 'true'
|
||||
${mime ? db`and items.mime ilike ${smime}` : db``}
|
||||
${!o.session && globalfilter ? db`and items.id not in (select item_id from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db``}
|
||||
${!o.session && globalfilter ? db`and not exists (select 1 from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db``}
|
||||
group by items.id
|
||||
order by random()
|
||||
limit 1
|
||||
@@ -253,7 +253,7 @@ export default {
|
||||
${tag ? db`and tags.normalized ilike '%' || slugify(${tag}) || '%'` : db``}
|
||||
${user ? db`and items.username ilike ${'%' + user + '%'}` : db``}
|
||||
${mime ? db`and items.mime ilike ${smime}` : db``}
|
||||
${!o.session && globalfilter ? db`and items.id not in (select item_id from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db``}
|
||||
${!o.session && globalfilter ? db`and not exists (select 1 from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db``}
|
||||
group by items.id, tags.tag
|
||||
order by random()
|
||||
limit 1
|
||||
|
||||
@@ -40,7 +40,7 @@ export default router => {
|
||||
active = 'true'
|
||||
${isFav ? db`and fu."user" = ${user}` : db`and items.username ilike ${user}`}
|
||||
${tag ? db`and tags.normalized ilike '%' || slugify(${tag}) || '%'` : db``}
|
||||
${!hasSession && globalfilter ? db`and items.id not in (select item_id from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db``}
|
||||
${!hasSession && globalfilter ? db`and not exists (select 1 from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db``}
|
||||
order by random()
|
||||
limit 1
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user