From 860da9b0af9fc7bf4e79a4f0f492e0489eca3310 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Tue, 22 Aug 2017 10:49:37 -0300 Subject: [PATCH] Make code cleaner --- app/actions/index.js | 121 ----------------------------------- app/components/MessageBox.js | 5 -- app/constants/types.js | 8 --- app/index.js | 23 ------- app/lib/realm.js | 1 - app/lib/rocketchat.js | 7 -- 6 files changed, 165 deletions(-) diff --git a/app/actions/index.js b/app/actions/index.js index 75a05545f..1a4e3d542 100644 --- a/app/actions/index.js +++ b/app/actions/index.js @@ -24,124 +24,3 @@ export function login() { type: 'LOGIN' }; } - - -// // GENRES -// export function retrieveMoviesGenresSuccess(res) { -// return { -// type: types.RETRIEVE_MOVIES_GENRES_SUCCESS, -// moviesGenres: res.data -// }; -// } - -// export function retrieveMoviesGenres() { -// return function (dispatch) { -// return axios.get(`${TMDB_URL}/genre/movie/list?api_key=${TMDB_API_KEY}`) -// .then(res => { -// dispatch(retrieveMoviesGenresSuccess(res)); -// }) -// .catch(error => { -// console.log(error); //eslint-disable-line -// }); -// }; -// } - -// // POPULAR -// export function retrievePopularMoviesSuccess(res) { -// return { -// type: types.RETRIEVE_POPULAR_MOVIES_SUCCESS, -// popularMovies: res.data -// }; -// } - -// export function retrievePopularMovies(page) { -// return function (dispatch) { -// return axios.get(`${TMDB_URL}/movie/popular?api_key=${TMDB_API_KEY}&page=${page}`) -// .then(res => { -// dispatch(retrievePopularMoviesSuccess(res)); -// }) -// .catch(error => { -// console.log('Popular', error); //eslint-disable-line -// }); -// }; -// } - -// // NOW PLAYING -// export function retrieveNowPlayingMoviesSuccess(res) { -// return { -// type: types.RETRIEVE_NOWPLAYING_MOVIES_SUCCESS, -// nowPlayingMovies: res.data -// }; -// } - -// export function retrieveNowPlayingMovies(page) { -// return function (dispatch) { -// return axios.get(`${TMDB_URL}/movie/now_playing?api_key=${TMDB_API_KEY}&page=${page}`) -// .then(res => { -// dispatch(retrieveNowPlayingMoviesSuccess(res)); -// }) -// .catch(error => { -// console.log('Now Playing', error); //eslint-disable-line -// }); -// }; -// } - -// // MOVIES LIST -// export function retrieveMoviesListSuccess(res) { -// return { -// type: types.RETRIEVE_MOVIES_LIST_SUCCESS, -// list: res.data -// }; -// } - -// export function retrieveMoviesList(type, page) { -// return function (dispatch) { -// return axios.get(`${TMDB_URL}/movie/${type}?api_key=${TMDB_API_KEY}&page=${page}`) -// .then(res => { -// dispatch(retrieveMoviesListSuccess(res)); -// }) -// .catch(error => { -// console.log('Movies List', error); //eslint-disable-line -// }); -// }; -// } - -// // SEARCH RESULTS -// export function retrieveMoviesSearchResultsSuccess(res) { -// return { -// type: types.RETRIEVE_MOVIES_SEARCH_RESULT_SUCCESS, -// searchResults: res.data -// }; -// } - -// export function retrieveMoviesSearchResults(query, page) { -// return function (dispatch) { -// return axios.get(`${TMDB_URL}/search/movie?api_key=${TMDB_API_KEY}&query=${query}&page=${page}`) -// .then(res => { -// dispatch(retrieveMoviesSearchResultsSuccess(res)); -// }) -// .catch(error => { -// console.log('Movies Search Results', error); //eslint-disable-line -// }); -// }; -// } - -// // MOVIE DETAILS -// export function retrieveMovieDetailsSuccess(res) { -// return { -// type: types.RETRIEVE_MOVIE_DETAILS_SUCCESS, -// details: res.data -// }; -// } - -// export function retrieveMovieDetails(movieId) { -// return function (dispatch) { -// return axios.get(`${TMDB_URL}/movie/${movieId}?api_key=${TMDB_API_KEY}&append_to_response=casts,images,videos`) -// .then(res => { -// dispatch(retrieveMovieDetailsSuccess(res)); -// }) -// .catch(error => { -// console.log('Movie Details', error); //eslint-disable-line -// }); -// }; -// } diff --git a/app/components/MessageBox.js b/app/components/MessageBox.js index 263b1b992..e1f809073 100644 --- a/app/components/MessageBox.js +++ b/app/components/MessageBox.js @@ -37,7 +37,6 @@ export default class MessageBox extends React.PureComponent { } submit(message) { - // console.log(this.state); const text = message; if (text.trim() === '') { return; @@ -56,8 +55,6 @@ export default class MessageBox extends React.PureComponent { }; ImagePicker.showImagePicker(options, (response) => { - // console.log('Response = ', response); - if (response.didCancel) { console.log('User cancelled image picker'); } else if (response.error) { @@ -84,8 +81,6 @@ export default class MessageBox extends React.PureComponent { this.component = component} style={styles.textBoxInput} - // value={this.state.text} - // onChangeText={text => this.setState({ text })} returnKeyType='send' onSubmitEditing={event => this.submit(event.nativeEvent.text)} blurOnSubmit={false} diff --git a/app/constants/types.js b/app/constants/types.js index 97c8b2e7c..f772c2b92 100644 --- a/app/constants/types.js +++ b/app/constants/types.js @@ -1,10 +1,2 @@ -// export const RETRIEVE_MOVIES_GENRES_SUCCESS = 'RETRIEVE_MOVIES_GENRES_SUCCESS'; - -// export const RETRIEVE_POPULAR_MOVIES_SUCCESS = 'RETRIEVE_POPULAR_MOVIES_SUCCESS'; -// export const RETRIEVE_NOWPLAYING_MOVIES_SUCCESS = 'RETRIEVE_NOWPLAYING_MOVIES_SUCCESS'; -// export const RETRIEVE_MOVIES_LIST_SUCCESS = 'RETRIEVE_MOVIES_LIST_SUCCESS'; -// export const RETRIEVE_MOVIE_DETAILS_SUCCESS = 'RETRIEVE_MOVIE_DETAILS_SUCCESS'; -// export const RETRIEVE_MOVIES_SEARCH_RESULT_SUCCESS = 'RETRIEVE_MOVIES_SEARCH_RESULT_SUCCESS'; - export const SET_CURRENT_SERVER = 'SET_CURRENT_SERVER'; export const SET_ALL_SETTINGS = 'SET_ALL_SETTINGS'; diff --git a/app/index.js b/app/index.js index 394d881ab..fb6d5b5fa 100644 --- a/app/index.js +++ b/app/index.js @@ -8,16 +8,6 @@ import ListServerView from './views/serverList'; import store from './lib/createStore'; -// -// export const authenticated = (view) => { -// if (!store.getState().login.authenticated) { -// return store.getState().navigator.resetTo({ -// screen: 'Login' -// }); -// } -// return view; -// }; - export const authenticated = WrappedComponent => class _p extends React.PureComponent { constructor() { super(); @@ -36,12 +26,6 @@ export const authenticated = WrappedComponent => class _p extends React.PureComp }; // export class PublicScreen extends React.PureComponent { - // componentWillMount() { - // this.props.setNavigator(this.props.navigator); - // if (this.props.currentServer) { - // return this.props.navigator.navigate('private'); - // } - // } render() { return !this.login.isAuthenticated || !this.login.user ? null : (); } @@ -52,20 +36,13 @@ export class PublicScreen extends React.PureComponent { setNavigator: navigator => dispatch(setNavigator(navigator)) })) export class PrivateScreen extends React.PureComponent { - componentWillMount() { - // this.props.setNavigator(this.props.navigator); - } render() { - // if (this.props.logged) { - // return (oi); - // } return (); } } @connect(() => ({ // logged: state.login.isAuthenticated }), dispatch => ({ - // navigate: routeName => dispatch(NavigationActions.navigate({ routeName })), setNavigator: navigator => dispatch(setNavigator(navigator)) })) export const HomeScreen = class extends React.PureComponent { diff --git a/app/lib/realm.js b/app/lib/realm.js index 2ab94a14f..f77882afa 100644 --- a/app/lib/realm.js +++ b/app/lib/realm.js @@ -33,7 +33,6 @@ const subscriptionSchema = { name: 'string', fname: { type: 'string', optional: true }, rid: 'string', - // u: { _id: 'hKCY2XGzHYk89SAaM', username: 'rodrigo', name: null }, open: { type: 'bool', optional: true }, alert: { type: 'bool', optional: true }, // roles: [ 'owner' ], diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 1bed464f1..bed91a75d 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -42,7 +42,6 @@ const RocketChat = { const url = `${ _url }/websocket`; Meteor.connect(url, { autoConnect: true, autoReconnect: true }); - // , { autoConnect: false, autoReconnect: false } Meteor.ddp.on('disconnected', () => { reduxStore.dispatch(disconnect()); }); @@ -50,9 +49,6 @@ const RocketChat = { reduxStore.dispatch(connectSuccess()); resolve(); }); - // Meteor.ddp.on('loggin', () => { - // reduxStore.dispatch(loginSuccess({})); - // }); Meteor.ddp.on('connected', () => { Meteor.call('public-settings/get', (err, data) => { if (err) { @@ -78,19 +74,16 @@ const RocketChat = { }); Meteor.ddp.on('changed', (ddbMessage) => { - // console.log('changed', ddbMessage); if (ddbMessage.collection === 'stream-room-messages') { realm.write(() => { const message = ddbMessage.fields.args[0]; message.temp = false; message._server = { id: reduxStore.getState().server }; - // write('messages', message); realm.create('messages', message, true); }); } if (ddbMessage.collection === 'stream-notify-user') { - // console.log(ddbMessage); realm.write(() => { const data = ddbMessage.fields.args[1]; data._server = { id: reduxStore.getState().server };