Skip to content

Commit

Permalink
TopicList [nfc]: Pass stream name into TopicItem
Browse files Browse the repository at this point in the history
This will be required for actionsheets to work properly.
  • Loading branch information
WesleyAC authored and chrisbobbe committed Apr 8, 2021
1 parent 6edf599 commit a3fab39
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/topics/TopicList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, { PureComponent } from 'react';
import { FlatList } from 'react-native';

import type { TopicExtended } from '../types';
import type { Stream, TopicExtended } from '../types';
import { createStyleSheet } from '../styles';
import TopicItem from '../streams/TopicItem';
import { LoadingIndicator, SearchEmptyState } from '../common';
Expand All @@ -15,13 +15,14 @@ const styles = createStyleSheet({
});

type Props = $ReadOnly<{|
stream: Stream,
topics: ?(TopicExtended[]),
onPress: (stream: string, topic: string) => void,
|}>;

export default class TopicList extends PureComponent<Props> {
render() {
const { topics, onPress } = this.props;
const { stream, topics, onPress } = this.props;

if (!topics) {
return <LoadingIndicator size={40} />;
Expand All @@ -40,6 +41,7 @@ export default class TopicList extends PureComponent<Props> {
renderItem={({ item }) => (
<TopicItem
name={item.name}
stream={stream.name}
isMuted={item.isMuted}
unreadCount={item.unreadCount}
onPress={onPress}
Expand Down
4 changes: 2 additions & 2 deletions src/topics/TopicListScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ class TopicListScreen extends PureComponent<Props, State> {
handleFilterChange = (filter: string) => this.setState({ filter });

render() {
const { topics } = this.props;
const { stream, topics } = this.props;
const { filter } = this.state;
const filteredTopics =
topics && topics.filter(topic => topic.name.toLowerCase().includes(filter.toLowerCase()));

return (
<Screen title="Topics" centerContent search searchBarOnChange={this.handleFilterChange}>
<TopicList topics={filteredTopics} onPress={this.handlePress} />
<TopicList stream={stream} topics={filteredTopics} onPress={this.handlePress} />
</Screen>
);
}
Expand Down

0 comments on commit a3fab39

Please sign in to comment.