Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use name from search results instead of spinner #20124

Merged
merged 2 commits into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions shared/actions/chat2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,7 @@ function* inboxSearch(_: TypedState, action: Chat2Gen.InboxSearchPayload, logger
return l.push(
Constants.makeInboxSearchConvHit({
conversationIDKey: Types.stringToConversationIDKey(h.convID),
name: h.name,
teamType: teamType(h.teamType),
})
)
Expand All @@ -1603,6 +1604,7 @@ function* inboxSearch(_: TypedState, action: Chat2Gen.InboxSearchPayload, logger
Chat2Gen.createInboxSearchTextResult({
result: Constants.makeInboxSearchTextHit({
conversationIDKey,
name: resp.searchHit.convName,
numHits: (resp.searchHit.hits || []).length,
query: resp.searchHit.query,
teamType: teamType(resp.searchHit.teamType),
Expand Down
2 changes: 2 additions & 0 deletions shared/chat/conversation-list/conversation-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const _itemRenderer = (_, row) => {
<SelectableSmallTeam
conversationIDKey={row.conversationIDKey}
isSelected={row.isSelected}
name=""
onSelectConversation={row.onSelectConversation}
/>
)
Expand All @@ -58,6 +59,7 @@ const _itemRenderer = (_, row) => {
<SelectableBigTeamChannel
conversationIDKey={row.conversationIDKey}
isSelected={row.isSelected}
name=""
onSelectConversation={row.onSelectConversation}
/>
)
Expand Down
2 changes: 2 additions & 0 deletions shared/chat/inbox-search/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default namedConnect(
nameResults: stateProps._inboxSearch.nameResults
.map(r => ({
conversationIDKey: r.conversationIDKey,
name: r.name,
type: r.teamType,
}))
.toArray(),
Expand All @@ -45,6 +46,7 @@ export default namedConnect(
textResults: stateProps._inboxSearch.textResults
.map(r => ({
conversationIDKey: r.conversationIDKey,
name: r.name,
numHits: r.numHits,
query: r.query,
type: r.teamType,
Expand Down
4 changes: 4 additions & 0 deletions shared/chat/inbox-search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import {inboxWidth} from '../inbox/row/sizes'

type NameResult = {
conversationIDKey: Types.ConversationIDKey
name: string
type: 'big' | 'small'
}

type TextResult = {
conversationIDKey: Types.ConversationIDKey
type: 'big' | 'small'
name: string
numHits: number
query: string
}
Expand Down Expand Up @@ -47,6 +49,7 @@ class InboxSearch extends React.Component<Props, State> {
<SelectableBigTeamChannel
conversationIDKey={item.conversationIDKey}
isSelected={!Styles.isMobile && this.props.selectedIndex === realIndex}
name={item.name}
numSearchHits={
// Auto generated from flowToTs. Please clean me!
// Auto generated from flowToTs. Please clean me!
Expand All @@ -64,6 +67,7 @@ class InboxSearch extends React.Component<Props, State> {
<SelectableSmallTeam
conversationIDKey={item.conversationIDKey}
isSelected={!Styles.isMobile && this.props.selectedIndex === realIndex}
name={item.name}
numSearchHits={
// Auto generated from flowToTs. Please clean me!
// Auto generated from flowToTs. Please clean me!
Expand Down
14 changes: 12 additions & 2 deletions shared/chat/selectable-big-team-channel-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type OwnProps = {
conversationIDKey: Types.ConversationIDKey
isSelected: boolean
maxSearchHits?: number
name: string
numSearchHits?: number
onSelectConversation: () => void
}
Expand All @@ -21,15 +22,24 @@ const mapStateToProps = (state, {conversationIDKey}) => {
const mapDispatchToProps = () => ({})

const mergeProps = (stateProps, _, ownProps: OwnProps) => {
let teamname = stateProps.teamname
let channelname = stateProps.channelname
if (!teamname) {
const parts = ownProps.name.split('#')
if (parts.length >= 2) {
teamname = parts[0]
channelname = parts[1]
}
}
return {
channelname: stateProps.channelname,
channelname,
isSelected: ownProps.isSelected,
maxSearchHits: ownProps.maxSearchHits,
numSearchHits: ownProps.numSearchHits,
onSelectConversation: ownProps.onSelectConversation,
showBadge: stateProps.showBadge,
showBold: stateProps.showBold && !ownProps.isSelected,
teamname: stateProps.teamname,
teamname,
}
}

Expand Down
31 changes: 16 additions & 15 deletions shared/chat/selectable-small-team-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {namedConnect} from '../util/container'
type OwnProps = {
conversationIDKey: Types.ConversationIDKey
filter?: string
name: string
numSearchHits?: number
maxSearchHits?: number
isSelected: boolean
Expand Down Expand Up @@ -34,23 +35,23 @@ const mergeProps = (stateProps, _, ownProps) => {

// order participants by hit, if it's set
const filter = ownProps.filter || ''
const participants = Constants.getRowParticipants(stateProps._meta, stateProps._username)
.toArray()
.sort((a, b) => {
const ai = a.indexOf(filter)
const bi = b.indexOf(filter)
const metaParts = Constants.getRowParticipants(stateProps._meta, stateProps._username).toArray()
let participants = metaParts.length > 0 ? metaParts : ownProps.name.split(',')
participants = participants.sort((a, b) => {
const ai = a.indexOf(filter)
const bi = b.indexOf(filter)

if (ai === -1) {
return bi === -1 ? -1 : 1
} else if (bi === -1) {
return -1
} else {
if (bi === 0) {
return 1
}
return -1
if (ai === -1) {
return bi === -1 ? -1 : 1
} else if (bi === -1) {
return -1
} else {
if (bi === 0) {
return 1
}
})
return -1
}
})

return {
backgroundColor: styles.backgroundColor,
Expand Down
2 changes: 2 additions & 0 deletions shared/constants/chat2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@ export const makeInboxSearchInfo = I.Record<Types._InboxSearchInfo>({

export const makeInboxSearchConvHit = I.Record<Types._InboxSearchConvHit>({
conversationIDKey: noConversationIDKey,
name: '',
teamType: 'small',
})

export const makeInboxSearchTextHit = I.Record<Types._InboxSearchTextHit>({
conversationIDKey: noConversationIDKey,
name: '',
numHits: 0,
query: '',
teamType: 'small',
Expand Down
2 changes: 2 additions & 0 deletions shared/constants/types/chat2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type InboxSearchStatus = 'initial' | 'inprogress' | 'success' | 'error'

export type _InboxSearchTextHit = {
conversationIDKey: Common.ConversationIDKey
name: string
numHits: number
query: string
teamType: 'big' | 'small'
Expand All @@ -56,6 +57,7 @@ export type InboxSearchTextHit = I.RecordOf<_InboxSearchTextHit>

export type _InboxSearchConvHit = {
conversationIDKey: Common.ConversationIDKey
name: string
teamType: 'big' | 'small'
}

Expand Down