Browse Source

Fix lint.

Kanta Asada 8 years ago
parent
commit
72f63b830a
2 changed files with 23 additions and 21 deletions
  1. 12 12
      README.md
  2. 11 9
      index.android.js

+ 12 - 12
README.md

@@ -195,9 +195,11 @@ Permissions.request('location', { type: 'always' }).then(response => {
   this.setState({ locationPermission: response })
 })
 
-Permissions.request('notification', { type: ['alert', 'badge'] }).then(response => {
-  this.setState({ notificationPermission: response })
-})
+Permissions.request('notification', { type: ['alert', 'badge'] }).then(
+  response => {
+    this.setState({ notificationPermission: response })
+  },
+)
 ```
 
 * You cannot request microphone permissions on the simulator.
@@ -259,16 +261,14 @@ You can find more informations about this issue in #46.
 
 ```js
 // example
-Permissions.request(
-  'camera',
-  {
-    rationale: {
-      'title': 'Cool Photo App Camera Permission',
-      'message': 'Cool Photo App needs access to your camera ' +
-                 'so you can take awesome pictures.'
-    },
+Permissions.request('camera', {
+  rationale: {
+    title: 'Cool Photo App Camera Permission',
+    message:
+      'Cool Photo App needs access to your camera ' +
+      'so you can take awesome pictures.',
   },
-).then(response => {
+}).then(response => {
   this.setState({ cameraPermission: response })
 })
 ```

+ 11 - 9
index.android.js

@@ -61,7 +61,7 @@ class ReactNativePermissions {
     })
   }
 
-    request = (permission, { rationale }) => {
+  request = (permission, { rationale }) => {
     const androidPermission = permissionTypes[permission]
 
     if (!androidPermission) {
@@ -72,15 +72,17 @@ class ReactNativePermissions {
       )
     }
 
-    return PermissionsAndroid.request(androidPermission, rationale).then(result => {
-      // PermissionsAndroid.request() to native module resolves to boolean
-      // rather than string if running on OS version prior to Android M
-      if (typeof result === 'boolean') {
-        return result ? 'authorized' : 'denied'
-      }
+    return PermissionsAndroid.request(androidPermission, rationale).then(
+      result => {
+        // PermissionsAndroid.request() to native module resolves to boolean
+        // rather than string if running on OS version prior to Android M
+        if (typeof result === 'boolean') {
+          return result ? 'authorized' : 'denied'
+        }
 
-      return setDidAskOnce(permission).then(() => RESULTS[result])
-    })
+        return setDidAskOnce(permission).then(() => RESULTS[result])
+      },
+    )
   }
 
   checkMultiple = permissions =>