Skip to content

Commit

Permalink
Default InviewContext to true so wheneven CommentComponent is used …
Browse files Browse the repository at this point in the history
…outside of the post (search, profile, expand) - it will render controls (#391)
  • Loading branch information
4vanger authored Aug 23, 2024
1 parent 38bbdb4 commit 514bf5c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 9 deletions.
6 changes: 1 addition & 5 deletions frontend/src/Components/UserProfileComments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {useCache} from '../API/use/useCache';
import {CommentInfo} from '../Types/PostInfo';
import CommentComponent from './CommentComponent';
import {useDebouncedCallback} from 'use-debounce';
import {InviewContext} from '../Pages/PostPage';

type UserProfileCommentsProps = {
username: string;
Expand Down Expand Up @@ -99,9 +98,7 @@ export default function UserProfileComments(props: UserProfileCommentsProps) {
{loading ? <div className={styles.loading}></div> :
<>
{error && <div className={styles.error}>{styles.error}</div> }
<InviewContext.Provider value={true}>

{comments ?
{comments ?
comments.map(comment =>
<CommentComponent idx={getParentComment(comment.parentComment) ? 1 : 0}
parent={getParentComment(comment.parentComment)} key={comment.id}
Expand All @@ -113,7 +110,6 @@ export default function UserProfileComments(props: UserProfileCommentsProps) {
: <div className={styles.loading}>Загрузка...</div>
)
}
</InviewContext.Provider>
<div className={styles.paginatorContainer}>
<Paginator page={page} pages={pages} base={`/u/${props.username}/comments`} queryStringParams={params} />
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Pages/PostPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {InView} from 'react-intersection-observer';

const THREAD_GROUP_SIZE = 10;

export const InviewContext = createContext<boolean>(false);
export const InviewContext = createContext<boolean>(true);

export default function PostPage() {
const params = useParams<{postId: string}>();
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/Pages/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {UserGender} from '../Types/UserInfo';
import classNames from 'classnames';
import {useCache} from '../API/use/useCache';
import {LARGE_AUTO_CUT} from '../Components/ContentComponent';
import {InviewContext} from './PostPage';

type SearchForm = {
term: string;
Expand All @@ -27,7 +26,6 @@ function SearchResult(props: {
{!total.value ? 'Ничего не найдено' :
<>{total.value.toLocaleString()} найдено {total.value > 250 && <>(250 показано)</>}</>}
</div>
<InviewContext.Provider value={true}>

{results.map((resultItem: SearchResultEntity) => {
const author = {username: resultItem.author, id: 0, gender: UserGender.fluid};
Expand Down Expand Up @@ -64,7 +62,6 @@ function SearchResult(props: {
showSite={true} hideRating={true}/>;

})}
</InviewContext.Provider>
</>;
}

Expand Down

0 comments on commit 514bf5c

Please sign in to comment.