Skip to content

Commit

Permalink
Fix visited comment previews for Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDaub committed Dec 5, 2024
1 parent 1d6c92a commit d1a4425
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/views/components/row.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ const row = (
period,
recentJoiners,
invert = false,
// NOTE: query is currently only used when we want to mark a comment preview
// as visited, and so since comment previews are only active on / and /new, we
// don't have to properly set query anywhere else.
query = "",
) => {
const size = 12;
return (story, i) => {
Expand Down Expand Up @@ -666,7 +670,8 @@ const row = (
>
<a
class="comment-preview-anchor"
href="#0x${story.lastComment.index}"
href="${path === "/" ? "" : path}${query}#0x${story
.lastComment.index}"
style="width: 100%; display: flex; pointer-events: none;"
>
<div style="width:90%;">
Expand Down
18 changes: 18 additions & 0 deletions src/views/feed.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,15 @@ export default async function (trie, theme, page, domain) {
const content = await index(trie, page, domain);
const { ad, originals, stories, start, contestStories } = content;

let currentQuery = "";
if (page && domain) {
currentQuery += `?page=${page}&domain=${domain}`;
} else if (page && !domain) {
currentQuery += `?page=${page}`;
} else if (!page && domain) {
currentQuery += `?domain=${domain}`;
}

let query = `?page=${page + 1}`;
if (domain) {
query += `&domain=${domain}`;
Expand Down Expand Up @@ -510,6 +519,7 @@ export default async function (trie, theme, page, domain) {
null,
recentJoiners,
true,
currentQuery,
),
)}
${stories
Expand All @@ -523,6 +533,8 @@ export default async function (trie, theme, page, domain) {
null,
null,
recentJoiners,
false,
currentQuery,
),
)}
${ad &&
Expand All @@ -534,6 +546,8 @@ export default async function (trie, theme, page, domain) {
null,
null,
recentJoiners,
false,
currentQuery,
)(ad)}
${stories
.slice(3, 8)
Expand All @@ -546,6 +560,8 @@ export default async function (trie, theme, page, domain) {
null,
null,
recentJoiners,
false,
currentQuery,
)(story, i + 3),
)}
${stories
Expand All @@ -559,6 +575,8 @@ export default async function (trie, theme, page, domain) {
null,
null,
recentJoiners,
false,
currentQuery,
)(story, i + 8),
)}
${stories.length < totalStories
Expand Down
3 changes: 3 additions & 0 deletions src/views/new.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export default async function (trie, theme) {
const path = "/new";
const ogImage = "https://news.kiwistand.com/kiwi_new_feed_page.png";
const recentJoiners = await registry.recents();
const query = "?cached=true";
return html`
<html lang="en" op="news">
<head>
Expand Down Expand Up @@ -146,6 +147,8 @@ export default async function (trie, theme) {
null,
null,
recentJoiners,
false,
query,
),
)}
</table>
Expand Down
2 changes: 1 addition & 1 deletion src/views/upvotes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export default async function (
<td>No activity yet...</td>
</tr>`
: ""}
${stories.map(Row(null, "/best", "margin-bottom: 17px;"))}
${stories.map(Row(null, "/upvotes", "margin-bottom: 17px;"))}
${stories.length === totalStories
? html`
<tr style="height: 50px">
Expand Down

0 comments on commit d1a4425

Please sign in to comment.