Skip to content

Commit

Permalink
Separate tweets & replies tab (Fixes #8)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffany352 committed Oct 9, 2019
1 parent bd50eff commit 4daa42a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/components/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default function Session(props) {
{session.account.username}'s Archive
</div>
<button className="Session-header-item" onClick={() => setPage('tweets')}>Tweets</button>
<button className="Session-header-item" onClick={() => setPage('tweetsAndReplies')}>Tweets & Replies</button>
<button className="Session-header-item" onClick={() => setPage('messages')}>Messages</button>
<button className="Session-header-item">Likes</button>
<div className="Session-header-spacer"></div>
Expand All @@ -42,6 +43,7 @@ export default function Session(props) {
</header>
{{
tweets: () => <TweetsPage />,
tweetsAndReplies: () => <TweetsPage includeReplies />,
messages: () => <MessagesPage />,
}[session.page]()}
</div>
Expand Down
25 changes: 10 additions & 15 deletions src/components/TweetsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,20 @@ export default function TweetsPage(props) {
const [count, setCount] = useState(30)
const session = useSelector((state) => state.session)

let tweets
const tweets = []
const needle = session.search && session.search.toLowerCase()
let hasMore = false
if (session.search) {
tweets = []
const needle = session.search.toLowerCase()
for (let i = 0; i < session.tweet.length; i++) {
const tweet = session.tweet[i]
if (tweet.full_text.toLowerCase().includes(needle)) {

for (const tweet of session.tweet) {
if (props.includeReplies || tweet.in_reply_to_user_id_str === undefined) {
if (!needle || tweet.full_text.toLowerCase().includes(needle)) {
tweets.push(tweet)
}
if (tweets.length >= count) {
hasMore = true
break
}
}
}
else {
tweets = session.tweet.slice(0, count)
hasMore = count < session.tweet.length
if (tweets.length >= count) {
hasMore = true
break
}
}

const loadMore = () => {
Expand Down

0 comments on commit 4daa42a

Please sign in to comment.