Comply w/ coding style

- Use 1 name for 1 abstraction. Instead of useFullScreen and enabled use
  fullScreen.
- Comments are correct English sentences so no double spaces between
  senteces, no capitalization of the work On midsentence.
- Write as little source code as possible if readability is preserved.
- Utilize Facebook's Flow.
- The name of a private function must start with _ and the jsdoc should
  state that the function is private.
This commit is contained in:
Lyubomir Marinov 2017-02-06 15:32:03 -06:00
parent 7a8c84e990
commit 2ad869a036
4 changed files with 30 additions and 26 deletions

View File

@ -1,8 +1,8 @@
rootProject.name = 'jitsi-meet-react'
include ':react-native-immersive'
project(':react-native-immersive').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-immersive/android')
include ':app'
include ':react-native-immersive'
project(':react-native-immersive').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-immersive/android')
include ':react-native-keep-awake'
project(':react-native-keep-awake').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keep-awake/android')
include ':react-native-vector-icons'

View File

@ -22,11 +22,11 @@
"bootstrap": "3.1.1",
"i18next": "3.4.4",
"i18next-xhr-backend": "1.1.0",
"jQuery-Impromptu": "trentrichardson/jQuery-Impromptu#v6.0.0",
"jitsi-meet-logger": "jitsi/jitsi-meet-logger",
"jquery": "~2.1.1",
"jquery-contextmenu": "*",
"jquery-i18next": "1.1.0",
"jQuery-Impromptu": "trentrichardson/jQuery-Impromptu#v6.0.0",
"jquery-ui": "1.10.5",
"jssha": "1.5.0",
"jws": "*",

View File

@ -1,3 +1,5 @@
/* @flow */
import { NativeModules } from 'react-native';
import { APP_WILL_MOUNT } from '../app';
@ -49,7 +51,9 @@ MiddlewareRegistry.register(store => next => action => {
if (mode !== null) {
AudioMode.setMode(mode)
.catch(err =>
console.error(`Failed to set audio mode ${mode}: ${err}`));
console.error(
`Failed to set audio mode ${String(mode)}: `
+ `${err}`));
}
}

View File

@ -1,3 +1,5 @@
/* @flow */
import { StatusBar } from 'react-native';
import { Immersive } from 'react-native-immersive';
@ -11,7 +13,7 @@ import { MiddlewareRegistry } from '../base/redux';
/**
* Middleware that captures conference actions and activates or deactivates the
* full screen mode. On iOS it hides the status bar, and on Android it uses the
* full screen mode. On iOS it hides the status bar, and on Android it uses the
* immersive mode:
* https://developer.android.com/training/system-ui/immersive.html
* In immersive mode the status and navigation bars are hidden and thus the
@ -21,31 +23,30 @@ import { MiddlewareRegistry } from '../base/redux';
* @returns {Function}
*/
MiddlewareRegistry.register(store => next => action => {
let useFullScreen;
let fullScreen;
switch (action.type) {
case CONFERENCE_WILL_JOIN: {
const state = store.getState()['features/base/conference'];
const conference = store.getState()['features/base/conference'];
useFullScreen = !state.audioOnly;
fullScreen = !conference.audioOnly;
break;
}
case CONFERENCE_FAILED:
case CONFERENCE_LEFT:
useFullScreen = false;
fullScreen = false;
break;
default:
useFullScreen = null;
fullScreen = null;
break;
}
if (useFullScreen !== null) {
setFullScreen(useFullScreen)
.catch(err => {
console.warn(`Error setting full screen mode: ${err}`);
});
if (fullScreen !== null) {
_setFullScreen(fullScreen)
.catch(err =>
console.warn(`Failed to set full screen mode: ${err}`));
}
return next(action);
@ -53,24 +54,23 @@ MiddlewareRegistry.register(store => next => action => {
/**
* Activates/deactivates the full screen mode. On iOS it will hide the status
* bar and On Android this will turn on immersive mode.
* bar, and on Android it will turn immersive mode on.
*
* @param {boolean} enabled - True to set full screen mode, false to
* @param {boolean} fullScreen - True to set full screen mode, false to
* deactivate it.
* @private
* @returns {Promise}
*/
function setFullScreen(enabled) {
// XXX The Immersive module is only implemented on Android and throws on
// other platforms.
function _setFullScreen(fullScreen: boolean) {
// XXX The React Native module Immersive is only implemented on Android and
// throws on other platforms.
if (Platform.OS === 'android') {
if (enabled) {
return Immersive.on();
}
return Immersive.off();
return fullScreen ? Immersive.on() : Immersive.off();
}
StatusBar.setHidden(enabled, 'slide');
// On platforms other than Android go with whatever React Native itself
// supports.
StatusBar.setHidden(fullScreen, 'slide');
return Promise.resolve();
}