From d283fc460476a4e8662fc12a129cfa701a5f90ac Mon Sep 17 00:00:00 2001 From: Oliver Lloyd Date: Mon, 4 Jan 2021 14:37:20 +0000 Subject: [PATCH 1/2] Removed unused prop --- src/App.stories.tsx | 8 -------- src/App.test.tsx | 5 ----- src/App.tsx | 43 +++++++++++++++++++++---------------------- 3 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/App.stories.tsx b/src/App.stories.tsx index 21b63620..8d75e825 100644 --- a/src/App.stories.tsx +++ b/src/App.stories.tsx @@ -40,7 +40,6 @@ export const LoggedOutHiddenPicks = () => ( expanded={false} onPermalinkClick={() => {}} apiKey="" - onHeightChange={() => {}} /> ); @@ -68,7 +67,6 @@ export const InitialPage = () => ( expanded={true} onPermalinkClick={() => {}} apiKey="" - onHeightChange={() => {}} /> ); @@ -96,7 +94,6 @@ export const Overrides = () => ( expanded={true} onPermalinkClick={() => {}} apiKey="" - onHeightChange={() => {}} /> ); @@ -122,7 +119,6 @@ export const LoggedInHiddenNoPicks = () => ( expanded={false} onPermalinkClick={() => {}} apiKey="" - onHeightChange={() => {}} /> ); @@ -149,7 +145,6 @@ export const LoggedOutHiddenNoPicks = () => ( expanded={false} onPermalinkClick={() => {}} apiKey="" - onHeightChange={() => {}} /> ); @@ -177,7 +172,6 @@ export const Closed = () => ( expanded={true} onPermalinkClick={() => {}} apiKey="" - onHeightChange={() => {}} /> ); @@ -202,7 +196,6 @@ export const NoComments = () => ( expanded={false} onPermalinkClick={() => {}} apiKey="" - onHeightChange={() => {}} /> ); @@ -229,7 +222,6 @@ export const LegacyDiscussion = () => ( expanded={false} onPermalinkClick={() => {}} apiKey="" - onHeightChange={() => {}} /> ); diff --git a/src/App.test.tsx b/src/App.test.tsx index 6b4e312f..432a143e 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -44,7 +44,6 @@ describe('App', () => { }} apiKey="discussion-rendering-test" onPermalinkClick={() => {}} - onHeightChange={() => {}} />, ); @@ -74,7 +73,6 @@ describe('App', () => { expanded={false} onPermalinkClick={() => {}} apiKey="" - onHeightChange={() => {}} />, ); @@ -102,7 +100,6 @@ describe('App', () => { }} apiKey="discussion-rendering-test" onPermalinkClick={() => {}} - onHeightChange={() => {}} />, ); @@ -129,7 +126,6 @@ describe('App', () => { }} apiKey="discussion-rendering-test" onPermalinkClick={() => {}} - onHeightChange={() => {}} />, ); @@ -157,7 +153,6 @@ describe('App', () => { }} apiKey="discussion-rendering-test" onPermalinkClick={() => {}} - onHeightChange={() => {}} />, ); diff --git a/src/App.tsx b/src/App.tsx index c89b469d..a3ab310d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -40,10 +40,13 @@ type Props = { expanded: boolean; onPermalinkClick: (commentId: number) => void; apiKey: string; - onHeightChange?: () => void; onRecommend?: (commentId: number) => Promise; onComment?: (shortUrl: string, body: string) => Promise; - onReply?: (shortUrl: string, body: string, parentCommentId: number) => Promise; + onReply?: ( + shortUrl: string, + body: string, + parentCommentId: number, + ) => Promise; onPreview?: (body: string) => Promise; }; @@ -75,13 +78,12 @@ const DEFAULT_FILTERS: FilterOptions = { const NoComments = () => (
No comments found
@@ -218,11 +220,10 @@ export const App = ({ expanded, onPermalinkClick, apiKey, - onHeightChange = () => {}, onRecommend, onComment, onReply, - onPreview + onPreview, }: Props) => { const [filters, setFilters] = useState( initialiseFilters({ @@ -237,16 +238,17 @@ export const App = ({ const [totalPages, setTotalPages] = useState(0); const [page, setPage] = useState(initialPage || 1); const [picks, setPicks] = useState([]); - const [commentBeingRepliedTo, setCommentBeingRepliedTo] = useState< - CommentType - >(); + const [ + commentBeingRepliedTo, + setCommentBeingRepliedTo, + ] = useState(); const [comments, setComments] = useState([]); const [commentCount, setCommentCount] = useState(0); const [mutes, setMutes] = useState(readMutes()); useEffect(() => { setLoading(true); - getDiscussion(shortUrl, { ...filters, page }).then(json => { + getDiscussion(shortUrl, { ...filters, page }).then((json) => { setLoading(false); if (json?.status !== 'error') { setComments(json?.discussion?.comments); @@ -266,7 +268,7 @@ export const App = ({ // If these override props are updated we want to respect them useEffect(() => { - setFilters(oldFilters => { + setFilters((oldFilters) => { return { ...oldFilters, orderBy: orderByOverride ? orderByOverride : oldFilters.orderBy, @@ -319,26 +321,23 @@ export const App = ({ rememberFilters(newFilterObject); // Filters also show when the view is not expanded but we want to expand when they're changed setIsExpanded(true); - onHeightChange(); setFilters(newFilterObject); }; const onPageChange = (page: number) => { document.getElementById('comment-filters')?.scrollIntoView(); setPage(page); - onHeightChange(); }; const expandView = () => { setIsExpanded(true); - onHeightChange(); }; const toggleMuteStatus = (userId: string) => { let updatedMutes; if (mutes.includes(userId)) { // Already muted, unmute them - updatedMutes = mutes.filter(id => id !== userId); + updatedMutes = mutes.filter((id) => id !== userId); } else { // Add this user to our list of mutes updatedMutes = [...mutes, userId]; @@ -419,7 +418,7 @@ export const App = ({ ) : (
    - {comments.slice(0, 2).map(comment => ( + {comments.slice(0, 2).map((comment) => (
  • ) : (
      - {comments.map(comment => ( + {comments.map((comment) => (
    • Date: Mon, 4 Jan 2021 15:37:59 +0000 Subject: [PATCH 2/2] Set size for View more comments --- src/App.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/App.tsx b/src/App.tsx index c366b795..0c3616a7 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -448,6 +448,7 @@ export const App = ({ icon={} iconSide="left" linkName="more-comments" + size="small" > View more comments