mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 14:16:39 +01:00
Remember replies toggle state during the "session"
This commit is contained in:
parent
ba0f61af8d
commit
64b59e42a5
1 changed files with 12 additions and 1 deletions
|
@ -33,6 +33,7 @@ import useTitle from '../utils/useTitle';
|
||||||
const LIMIT = 40;
|
const LIMIT = 40;
|
||||||
const THREAD_LIMIT = 20;
|
const THREAD_LIMIT = 20;
|
||||||
|
|
||||||
|
let cachedRepliesToggle = {};
|
||||||
let cachedStatusesMap = {};
|
let cachedStatusesMap = {};
|
||||||
function resetScrollPosition(id) {
|
function resetScrollPosition(id) {
|
||||||
delete cachedStatusesMap[id];
|
delete cachedStatusesMap[id];
|
||||||
|
@ -293,6 +294,7 @@ function StatusPage() {
|
||||||
states.scrollPositions = {};
|
states.scrollPositions = {};
|
||||||
states.reloadStatusPage = 0;
|
states.reloadStatusPage = 0;
|
||||||
cachedStatusesMap = {};
|
cachedStatusesMap = {};
|
||||||
|
cachedRepliesToggle = {};
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
@ -870,9 +872,18 @@ function SubComments({ hasManyStatuses, replies, instance, hasParentThread }) {
|
||||||
|
|
||||||
const open =
|
const open =
|
||||||
(!hasParentThread || replies.length === 1) && (isBrief || !hasManyStatuses);
|
(!hasParentThread || replies.length === 1) && (isBrief || !hasManyStatuses);
|
||||||
|
const openBefore = cachedRepliesToggle[replies[0].id];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<details class="replies" open={open}>
|
<details
|
||||||
|
class="replies"
|
||||||
|
open={openBefore || open}
|
||||||
|
onToggle={(e) => {
|
||||||
|
const { open } = e.target;
|
||||||
|
// use first reply as ID
|
||||||
|
cachedRepliesToggle[replies[0].id] = open;
|
||||||
|
}}
|
||||||
|
>
|
||||||
<summary hidden={open}>
|
<summary hidden={open}>
|
||||||
<span class="avatars">
|
<span class="avatars">
|
||||||
{accounts.map((a) => (
|
{accounts.map((a) => (
|
||||||
|
|
Loading…
Reference in a new issue