Skip to content

Commit

Permalink
team building: no contacts in teams tab (keybase#18624)
Browse files Browse the repository at this point in the history
* team building: no contacts in teams tab

* move check outside action, android docs update
  • Loading branch information
aaazalea authored Jul 31, 2019
1 parent 88374d4 commit f78c0f2
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 28 deletions.
18 changes: 16 additions & 2 deletions shared/actions/__tests__/team-building.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,14 @@ describe('Search Actions', () => {
it('Calls search', () => {
const {dispatch} = init
expect(rpc).not.toHaveBeenCalled()
dispatch(TeamBuildingGen.createSearch({namespace: testNamespace, query: 'marcopolo', service: 'keybase'}))
dispatch(
TeamBuildingGen.createSearch({
includeContacts: false,
namespace: testNamespace,
query: 'marcopolo',
service: 'keybase',
})
)
expect(rpc).toHaveBeenCalled()
})

Expand All @@ -145,7 +152,14 @@ describe('Search Actions', () => {
const query = 'marcopolo'
const service = 'keybase'
expect(rpc).not.toHaveBeenCalled()
dispatch(TeamBuildingGen.createSearch({namespace: testNamespace, query: 'marcopolo', service: 'keybase'}))
dispatch(
TeamBuildingGen.createSearch({
includeContacts: false,
namespace: testNamespace,
query: 'marcopolo',
service: 'keybase',
})
)
expect(getState().chat2.teamBuilding.teamBuildingSearchQuery).toEqual('marcopolo')
expect(getState().chat2.teamBuilding.teamBuildingSelectedService).toEqual('keybase')
return Testing.flushPromises().then(() => {
Expand Down
3 changes: 2 additions & 1 deletion shared/actions/json/team-building.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
],
"actions": {
"fetchedUserRecs": {"namespace": "Types.AllowedNamespace", "users": "Array<Types.User>"},
"fetchUserRecs": {"namespace": "Types.AllowedNamespace"},
"fetchUserRecs": {"includeContacts": "boolean", "namespace": "Types.AllowedNamespace"},
"finishedTeamBuilding": {"namespace": "Types.AllowedNamespace", "teamname?": "string"},
"cancelTeamBuilding": {"namespace": "Types.AllowedNamespace"},
"search": {
"includeContacts": "boolean",
"namespace": "Types.AllowedNamespace",
"query": "string",
"service": "Types.ServiceIdWithContact",
Expand Down
3 changes: 2 additions & 1 deletion shared/actions/team-building-gen.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 24 additions & 15 deletions shared/actions/team-building.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ import {validateNumber} from '../util/phone-numbers'

const closeTeamBuilding = () => RouteTreeGen.createClearModals()
export type NSAction = {payload: {namespace: TeamBuildingTypes.AllowedNamespace}}
type SearchOrRecAction = {payload: {namespace: TeamBuildingTypes.AllowedNamespace; includeContacts: boolean}}

const apiSearch = (
query: string,
service: TeamBuildingTypes.ServiceIdWithContact,
maxResults: number,
includeServicesSummary: boolean,
impTofuQuery: RPCTypes.ImpTofuQuery | null
impTofuQuery: RPCTypes.ImpTofuQuery | null,
includeContacts: boolean
): Promise<Array<TeamBuildingTypes.User>> =>
RPCTypes.userSearchUserSearchRpcPromise({
impTofuQuery,
includeContacts: flags.sbsContacts && service === 'keybase',
includeContacts: flags.sbsContacts && service === 'keybase' && includeContacts,
includeServicesSummary,
maxResults,
query,
Expand Down Expand Up @@ -93,7 +95,8 @@ function* searchResultCounts(state: TypedState, {payload: {namespace}}: NSAction
service,
teamBuildingSearchLimit,
true,
null
null,
false
).then(users =>
TeamBuildingGen.createSearchResultsLoaded({
namespace,
Expand Down Expand Up @@ -130,7 +133,7 @@ const makeImpTofuQuery = (query: string, region: string | null): RPCTypes.ImpTof
return null
}

const search = (state: TypedState, {payload: {namespace}}: NSAction) => {
const search = (state: TypedState, {payload: {namespace, includeContacts}}: SearchOrRecAction) => {
const {teamBuildingSearchQuery, teamBuildingSelectedService, teamBuildingSearchLimit} = state[
namespace
].teamBuilding
Expand All @@ -147,21 +150,27 @@ const search = (state: TypedState, {payload: {namespace}}: NSAction) => {
impTofuQuery = makeImpTofuQuery(query, userRegion)
}

return apiSearch(query, teamBuildingSelectedService, teamBuildingSearchLimit, true, impTofuQuery).then(
users =>
TeamBuildingGen.createSearchResultsLoaded({
namespace,
query,
service: teamBuildingSelectedService,
users,
})
return apiSearch(
query,
teamBuildingSelectedService,
teamBuildingSearchLimit,
true,
impTofuQuery,
includeContacts
).then(users =>
TeamBuildingGen.createSearchResultsLoaded({
namespace,
query,
service: teamBuildingSelectedService,
users,
})
)
}

const fetchUserRecs = (state: TypedState, {payload: {namespace}}: NSAction) =>
const fetchUserRecs = (state: TypedState, {payload: {namespace, includeContacts}}: SearchOrRecAction) =>
Promise.all([
RPCTypes.userInterestingPeopleRpcPromise({maxUsers: 50}),
flags.sbsContacts
flags.sbsContacts && includeContacts
? RPCTypes.contactsGetContactsForUserRecommendationsRpcPromise()
: Promise.resolve([] as RPCTypes.ProcessedContact[]),
])
Expand All @@ -187,7 +196,7 @@ const fetchUserRecs = (state: TypedState, {payload: {namespace}}: NSAction) =>
serviceMap: {keybase: username},
})
)
const expectingContacts = flags.sbsContacts && state.settings.contacts.importEnabled
const expectingContacts = flags.sbsContacts && state.settings.contacts.importEnabled && includeContacts
if (expectingContacts) {
suggestions = suggestions.slice(0, 10)
}
Expand Down
19 changes: 12 additions & 7 deletions shared/docs/android/setup.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
## Prereqs

Follow instructions for "Building Projects with Native Code" at
https://facebook.github.io/react-native/docs/getting-started.html to
install and configure Android.

## Emulator Setup

### macOS

If you're installing on macOS on High Sierra, skip installing
HAX. Instead, follow the instructions in
https://issuetracker.google.com/issues/62395878#comment7 , i.e. put
Expand All @@ -24,6 +26,7 @@ emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure KVM is properly installed and usable.
CPU acceleration status: This user doesn't have permissions to use KVM (/dev/kvm)
```

Normally, `/dev/kvm` can only be used by `root`, but you don't
want to run things as root regularly. Instead, make a `kvm` group and
add your current user in it:
Expand All @@ -33,15 +36,18 @@ add your current user in it:
addgroup kvm
usermod -a -G kvm $USER
```

You may have to log out and re-log in, or even reboot, for this to
take effect. Then you'll want to configure the right group and permissions
for `/dev/kvm`. From [this StackExchange answer](https://unix.stackexchange.com/questions/373872/non-root-user-can-not-use-enable-kvm),

1. Create the file `/etc/udev/rules.d/65-kvm.rules` as root
2. Put the following line inside this file:

```
KERNEL=="kvm", NAME="%k", GROUP="kvm", MODE="0660"
```

3. Reload rules with `udevadm control --reload-rules && udevadm trigger`

## Android Studio
Expand All @@ -50,7 +56,7 @@ Select "Open an existing Android Studio Project" and point it to
`shared/android`. Not necessary to register the `client`
dir as a VCS-controlled dir with Android studio, but may as well.

You'll get various prompts about installing various tools. You should
You might get various prompts about installing various tools. You should
install 'Build Tools' and any missing platforms. However, _don't_
update the Android Gradle Plugin to 3.0.1.

Expand All @@ -60,6 +66,9 @@ Some instructions talk about the SDK Manager / AVD Manager. This is
under the Tools > Android menu. You may have to wait for Gradle to
sync before they appear.

Before running the build process in android studio, you will need to
run `yarn rn-gobuild-android`.

### Dealing with Android Studio

Sometimes Android Studio gets into a bad state, especially if you're
Expand Down Expand Up @@ -142,7 +151,6 @@ assuming you've set the `$ANDROID_HOME` variable and added
`$ANDROID_HOME/tools` to your `PATH`, per
https://facebook.github.io/react-native/docs/getting-started.html .


### Using a device

To run on your Android device, make sure USB debugging is enabled; see
Expand Down Expand Up @@ -170,17 +178,15 @@ On your computer run:
adb reverse tcp:8081 tcp:8081
```



To recap, you should have run:

1. `adb devices` (should list *exactly* one device)
1. `adb devices` (should list _exactly_ one device)
1. `yarn rn-gobuild-android`,
1. `yarn rn-start android`
1. `yarn rn-build-android` (or `gradle installDebug` inside android),
1. `yarn rn-push-android` (To install the apk on the device. NOTE: `gradle installDebug` does this automatically)

and have an emulator or android device connected. (i.e. `adb devices` should list *exactly* one device)
and have an emulator or android device connected. (i.e. `adb devices` should list _exactly_ one device)

Then you can run

Expand All @@ -197,4 +203,3 @@ developing!
Occasionally you might get a white screen that doesn't go away, even
after the bundler has finished bundling. Stopping the app and
restarting it seems to fix it.

7 changes: 5 additions & 2 deletions shared/team-building/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,13 @@ const makeDebouncedSearch = (time: number) =>
namespace: AllowedNamespace,
query: string,
service: ServiceIdWithContact,
includeContacts: boolean,
limit?: number
) =>
requestIdleCallback(() =>
dispatch(
TeamBuildingGen.createSearch({
includeContacts,
limit,
namespace,
query,
Expand All @@ -199,9 +201,10 @@ const mapDispatchToProps = (dispatch: Container.TypedDispatch, {namespace, teamn
dispatch(SettingsGen.createRequestContactPermissions({thenToggleImportOn: true})),
_search: (query: string, service: ServiceIdWithContact, limit?: number) => {
const func = service === 'keybase' ? debouncedSearchKeybase : debouncedSearch
return func(dispatch, namespace, query, service, limit)
return func(dispatch, namespace, query, service, namespace === 'chat2', limit)
},
fetchUserRecs: () => dispatch(TeamBuildingGen.createFetchUserRecs({namespace})),
fetchUserRecs: () =>
dispatch(TeamBuildingGen.createFetchUserRecs({includeContacts: namespace === 'chat2', namespace})),
onAskForContactsLater: () => dispatch(SettingsGen.createImportContactsLater()),
onChangeSendNotification: (sendNotification: boolean) =>
namespace === 'teams' &&
Expand Down

0 comments on commit f78c0f2

Please sign in to comment.