Skip to content

Commit 006e714

Browse files
committed
FIX: keyboard would be for URLs when it should be the default
In the discover page, the `keyboardType` should be the default not the URL See images: Also fixed an issue where we could see 2 loading when fetching tags
1 parent ca885d3 commit 006e714

2 files changed

Lines changed: 42 additions & 56 deletions

File tree

js/screens/DiscoverScreen.js

Lines changed: 41 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -150,43 +150,52 @@ class DiscoverScreen extends React.Component {
150150
view: VIEWS.TAG_DETAIL,
151151
});
152152

153-
this._fetchTagCommunities(tag);
154-
this._fetchHotTopicsForTag(tag);
153+
this._fetchTagDetail(tag);
155154
}
156155

157-
_fetchHotTopicsForTag(tag) {
158-
api
159-
.fetchHotTopics(tag, 1)
160-
.then(json => {
161-
if (tag !== this.state.activeTag) {
162-
return; // stale response
163-
}
156+
async _fetchTagDetail(tag) {
157+
const [communitiesResult, hotTopicsResult] = await Promise.allSettled([
158+
api.fetchTagCommunities(tag),
159+
api.fetchHotTopics(tag, 1),
160+
]);
164161

165-
const topics = json.hot_topics || [];
166-
this.setState({
167-
hotTopics: topics,
168-
hotTopicsLoading: false,
169-
hotTopicsHasMore: Boolean(json.more_topics_url),
170-
});
162+
if (tag !== this.state.activeTag) {
163+
return; // stale response
164+
}
171165

172-
if (topics.length === 0) {
173-
this.setState({
174-
view: VIEWS.ALL_COMMUNITIES,
175-
previousView: VIEWS.SPLASH,
176-
communitiesFilter: tag,
177-
allCommunities: [],
178-
allCommunitiesLoading: true,
179-
});
180-
this._fetchAllCommunities(tag);
181-
}
182-
})
183-
.catch(e => {
184-
console.log(e);
185-
if (tag !== this.state.activeTag) {
186-
return;
187-
}
188-
this.setState({ hotTopicsLoading: false });
166+
if (communitiesResult.status === 'rejected') {
167+
console.log(communitiesResult.reason);
168+
}
169+
if (hotTopicsResult.status === 'rejected') {
170+
console.log(hotTopicsResult.reason);
171+
}
172+
173+
const hotTopicsJson = hotTopicsResult.value;
174+
const topics = hotTopicsJson?.hot_topics || [];
175+
const loaded = {
176+
hotTopicsLoading: false,
177+
tagCommunitiesLoading: false,
178+
tagCommunities: communitiesResult.value?.topics || [],
179+
};
180+
181+
if (hotTopicsResult.status === 'fulfilled' && topics.length === 0) {
182+
this.setState({
183+
...loaded,
184+
view: VIEWS.ALL_COMMUNITIES,
185+
previousView: VIEWS.SPLASH,
186+
communitiesFilter: tag,
187+
allCommunities: [],
188+
allCommunitiesLoading: true,
189189
});
190+
this._fetchAllCommunities(tag);
191+
return;
192+
}
193+
194+
this.setState({
195+
...loaded,
196+
hotTopics: topics,
197+
hotTopicsHasMore: Boolean(hotTopicsJson?.more_topics_url),
198+
});
190199
}
191200

192201
fetchHotTopics(tag, opts = {}) {
@@ -221,29 +230,6 @@ class DiscoverScreen extends React.Component {
221230
});
222231
}
223232

224-
_fetchTagCommunities(tag) {
225-
api
226-
.fetchTagCommunities(tag)
227-
.then(json => {
228-
if (tag !== this.state.activeTag) {
229-
return;
230-
}
231-
232-
if (json.topics) {
233-
this.setState({
234-
tagCommunities: json.topics,
235-
tagCommunitiesLoading: false,
236-
});
237-
} else {
238-
this.setState({ tagCommunities: [], tagCommunitiesLoading: false });
239-
}
240-
})
241-
.catch(e => {
242-
console.log(e);
243-
this.setState({ tagCommunitiesLoading: false });
244-
});
245-
}
246-
247233
onPressCommunity(community) {
248234
this.setState({
249235
activeCommunity: community,

js/screens/DiscoverScreenComponents/TermBar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const TermBar = props => {
8383
</View>
8484
<TextInput
8585
enterKeyHint="search"
86-
keyboardType="url"
86+
keyboardType={props.addSiteScreenParent ? 'url' : 'default'}
8787
clearButtonMode="never"
8888
autoCapitalize="none"
8989
autoCorrect={false}

0 commit comments

Comments
 (0)