From d051ecf83884dfb1c6881207843f1097089fb014 Mon Sep 17 00:00:00 2001 From: bl4ckm0r3 Date: Wed, 6 Dec 2017 18:48:19 +0000 Subject: [PATCH] removed var usages in favour of let/const --- .eslintrc | 1 + js/F8App.js | 2 +- js/F8Navigator.js | 4 +- js/FacebookSDK.js | 2 +- js/Playground.js | 8 ++-- js/common/F8BackgroundRepeat.js | 4 +- js/common/F8Header.js | 2 +- js/common/F8Modal.js | 2 +- js/common/F8PageControl.js | 18 ++++---- js/common/F8SegmentedControl.js | 4 +- js/common/ItemsWithSeparator.js | 6 +-- js/common/LoginButton.js | 2 +- js/common/MapView.js | 2 +- js/common/MessengerChatHead.js | 2 +- js/common/MessengerModal.js | 2 +- js/common/ParallaxBackground.js | 4 +- js/common/ViewPager.js | 8 ++-- js/filter/FilterScreen.android.js | 6 +-- js/filter/FilterScreen.ios.js | 6 +-- js/filter/FriendsList.js | 8 ++-- js/filter/Header.js | 6 +-- js/filter/Section.js | 4 +- js/login/LoginScreen.js | 2 +- js/rating/Header.js | 2 +- js/reducers/scheduleTopics.js | 4 +- js/reducers/sessions.js | 2 +- js/reducers/videoTopics.js | 4 +- js/store/configureStore.js | 6 +-- js/tabs/MenuItem.js | 8 ++-- js/tabs/demos/DemosCarousel.js | 2 +- js/tabs/demos/F8DemoDetails.js | 8 ++-- js/tabs/info/CommonQuestions.js | 2 +- js/tabs/info/DirectionsLink.js | 6 +-- js/tabs/info/LinksList.js | 4 +- js/tabs/info/Section.js | 2 +- js/tabs/info/WiFiDetails.js | 2 +- js/tabs/maps/F8MapView.js | 2 +- js/tabs/maps/F8VenueMap.js | 2 +- js/tabs/maps/ZoomableImage.js | 8 ++-- js/tabs/notifications/RateSessionsCell.js | 2 +- js/tabs/notifications/allNotifications.js | 6 +-- js/tabs/notifications/findSessionByURI.js | 6 +-- js/tabs/schedule/EmptySchedule.js | 2 +- js/tabs/schedule/F8FriendGoing.js | 2 +- js/tabs/schedule/F8GanttGrid.js | 2 +- js/tabs/schedule/F8SessionCell.js | 2 +- js/tabs/schedule/F8SessionDetails.js | 11 ++--- js/tabs/schedule/F8SpeakerProfile.js | 6 +-- js/tabs/schedule/FilterHeader.js | 2 +- js/tabs/schedule/FriendCell.js | 2 +- js/tabs/schedule/FriendsUsingApp.js | 2 +- js/tabs/schedule/PrivacyIcon.js | 2 +- js/tabs/schedule/ProfileButton.js | 2 +- js/tabs/schedule/SessionsCarousel.js | 10 ++--- js/tabs/schedule/SessionsSectionHeader.js | 2 +- js/tabs/schedule/SharingSettingsCommon.js | 2 +- js/tabs/schedule/SharingSettingsScreen.js | 2 +- js/tabs/schedule/filterSessions.js | 2 +- js/tabs/schedule/groupSessions.js | 4 +- server/parse-server/cloud/auth.js | 2 +- server/parse-server/cloud/functions/agenda.js | 10 ++--- .../parse-server/cloud/functions/friends.js | 12 +++--- .../parse-server/cloud/functions/meetups.js | 8 ++-- .../cloud/functions/messengerbot.js | 20 ++++----- .../cloud/functions/notifications.js | 6 +-- .../cloud/functions/surveyexports.js | 42 +++++++++---------- .../parse-server/cloud/functions/surveys.js | 26 ++++++------ server/parse-server/cloud/functions/tests.js | 20 ++++----- .../cloud/jobs/installationSync.js | 2 +- .../parse-server/cloud/jobs/unmaskAgenda.js | 8 ++-- server/parse-server/cloud/jobs/unmaskDemos.js | 8 ++-- .../cloud/jobs/updateVideoSources.js | 12 +++--- .../cloud/triggers/pushChannels.js | 14 +++---- server/parse-server/cloud/triggers/videos.js | 2 +- 74 files changed, 217 insertions(+), 215 deletions(-) diff --git a/.eslintrc b/.eslintrc index 96131181e..29f81aa60 100644 --- a/.eslintrc +++ b/.eslintrc @@ -102,6 +102,7 @@ "use-isnan": 1, // disallow comparisons with the value NaN "valid-jsdoc": 0, // Ensure JSDoc comments are valid (off by default) "valid-typeof": 1, // Ensure that the results of typeof are compared against a valid string + "no-var": 1, // discouraging the use of var and encouraging the use of const or let instead // Best Practices // These are rules designed to prevent you from making mistakes. They either prescribe a better way of doing something or help you avoid footguns. diff --git a/js/F8App.js b/js/F8App.js index 1092e638b..e46000502 100644 --- a/js/F8App.js +++ b/js/F8App.js @@ -105,7 +105,7 @@ class F8App extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { flex: 1 } diff --git a/js/F8Navigator.js b/js/F8Navigator.js index 4a66dfd7a..88d154c4d 100644 --- a/js/F8Navigator.js +++ b/js/F8Navigator.js @@ -45,7 +45,7 @@ import { switchTab } from "./actions"; import F8MapView from "./tabs/maps/F8MapView"; import DemosCarousel from "./tabs/demos/DemosCarousel"; -var F8Navigator = React.createClass({ +const F8Navigator = React.createClass({ _handlers: ([]: Array<() => boolean>), componentDidMount: function() { @@ -158,7 +158,7 @@ F8Navigator.childContextTypes = { removeBackButtonListener: React.PropTypes.func }; -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: F8Colors.bianca diff --git a/js/FacebookSDK.js b/js/FacebookSDK.js index b9aafbf61..5cedd86da 100644 --- a/js/FacebookSDK.js +++ b/js/FacebookSDK.js @@ -73,7 +73,7 @@ async function loginWithFacebookSDK( return _authResponse; } -var FacebookSDK = { +const FacebookSDK = { init() { // This is needed by Parse window.FB = FacebookSDK; diff --git a/js/Playground.js b/js/Playground.js index 4a6a65142..279212530 100644 --- a/js/Playground.js +++ b/js/Playground.js @@ -36,10 +36,10 @@ class Playground extends React.Component { const define = (name: string, render: Function) => { content.push(); }; - // var Module = require('F8PageControl'); - var Module = require("F8Header"); - // var Module = require('./tabs/schedule/AddToScheduleButton'); - // var Module = require('./rating/Header'); + // const Module = require('F8PageControl'); + const Module = require("F8Header"); + // const Module = require('./tabs/schedule/AddToScheduleButton'); + // const Module = require('./rating/Header'); // $FlowFixMe: doesn't understand static Module.__cards__(define); this.state = { content }; diff --git a/js/common/F8BackgroundRepeat.js b/js/common/F8BackgroundRepeat.js index 6e51f02a3..d9c86d7d8 100644 --- a/js/common/F8BackgroundRepeat.js +++ b/js/common/F8BackgroundRepeat.js @@ -44,7 +44,7 @@ class F8BackgroundRepeat extends React.Component { const numHorizontal = Math.ceil(width / img.width); const numVertical = Math.ceil(height / img.height); - for (var i = 0; i < numVertical; i++) { + for (let i = 0; i < numVertical; i++) { content.push(this.renderRow(numHorizontal, i)); } @@ -62,7 +62,7 @@ class F8BackgroundRepeat extends React.Component { renderRow(colsInRow, idx) { const cols = []; - for (var i = 0; i < colsInRow; i++) { + for (let i = 0; i < colsInRow; i++) { cols.push(this.renderImage(i)); } return ( diff --git a/js/common/F8Header.js b/js/common/F8Header.js index 8ac7bbdc2..68ed92425 100644 --- a/js/common/F8Header.js +++ b/js/common/F8Header.js @@ -305,7 +305,7 @@ class ItemWrapperIOS extends React.Component { /* StyleSheet ============================================================================= */ -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ toolbar: { android: { // backgroundColor: F8Colors.background, diff --git a/js/common/F8Modal.js b/js/common/F8Modal.js index e07e2455e..bcd243b57 100644 --- a/js/common/F8Modal.js +++ b/js/common/F8Modal.js @@ -77,7 +77,7 @@ class F8Modal extends React.Component { /* StyleSheet ============================================================================= */ -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: F8Colors.colorWithAlpha("tangaroa", 0.8), diff --git a/js/common/F8PageControl.js b/js/common/F8PageControl.js index b632d5b19..e693752fd 100644 --- a/js/common/F8PageControl.js +++ b/js/common/F8PageControl.js @@ -26,9 +26,9 @@ import React from "react"; import { StyleSheet, View } from "react-native"; -var PropTypes = React.PropTypes; +const PropTypes = React.PropTypes; -var F8PageControl = React.createClass({ +const F8PageControl = React.createClass({ propTypes: { style: View.propTypes.style, count: PropTypes.number.isRequired, @@ -36,9 +36,9 @@ var F8PageControl = React.createClass({ }, render: function() { - var images = []; - for (var i = 0; i < this.props.count; i++) { - var isSelected = this.props.selectedIndex === i; + const images = []; + for (let i = 0; i < this.props.count; i++) { + const isSelected = this.props.selectedIndex === i; images.push(); } return ( @@ -49,16 +49,16 @@ var F8PageControl = React.createClass({ } }); -var Circle = React.createClass({ +const Circle = React.createClass({ render: function() { - var extraStyle = this.props.isSelected ? styles.full : styles.empty; + const extraStyle = this.props.isSelected ? styles.full : styles.empty; return ; } }); -var CIRCLE_SIZE = 4; +const CIRCLE_SIZE = 4; -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { alignItems: "center", justifyContent: "center" diff --git a/js/common/F8SegmentedControl.js b/js/common/F8SegmentedControl.js index 695c6e726..6c3e2f73d 100644 --- a/js/common/F8SegmentedControl.js +++ b/js/common/F8SegmentedControl.js @@ -54,7 +54,7 @@ class F8SegmentedControl extends React.Component { render() { const { backgroundColor, borderColor, textColor } = this.props; - var segments = this.props.values.map((value, index) => ( + const segments = this.props.values.map((value, index) => ( { children.push(child); if (ii !== length - 1) { @@ -51,7 +51,7 @@ class ItemsWithSeparator extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ separator: { backgroundColor: "#0322500A", height: 1 / PixelRatio.get() diff --git a/js/common/LoginButton.js b/js/common/LoginButton.js index e28e46552..4e7c79323 100644 --- a/js/common/LoginButton.js +++ b/js/common/LoginButton.js @@ -96,7 +96,7 @@ class LoginButton extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ button: { alignSelf: "center", width: 284 diff --git a/js/common/MapView.js b/js/common/MapView.js index 165fc8d84..42015b632 100644 --- a/js/common/MapView.js +++ b/js/common/MapView.js @@ -199,7 +199,7 @@ function urlForMap(map: ?Map): string { /* StyleSheet ============================================================================= */ -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ defaultMap: { resizeMode: "contain" } diff --git a/js/common/MessengerChatHead.js b/js/common/MessengerChatHead.js index 8dd3c3c65..587047988 100644 --- a/js/common/MessengerChatHead.js +++ b/js/common/MessengerChatHead.js @@ -85,7 +85,7 @@ class MessengerChatHead extends React.Component { /* StyleSheet ============================================================================= */ -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { width: CONTAINER_WIDTH, height: CONTAINER_HEIGHT diff --git a/js/common/MessengerModal.js b/js/common/MessengerModal.js index ace5aeff7..09cdee0a5 100644 --- a/js/common/MessengerModal.js +++ b/js/common/MessengerModal.js @@ -104,7 +104,7 @@ class MessengerModal extends React.Component { /* StyleSheet =============================================================== */ -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ content: { alignItems: "center", paddingVertical: 45, diff --git a/js/common/ParallaxBackground.js b/js/common/ParallaxBackground.js index 426c471c5..b754688a1 100644 --- a/js/common/ParallaxBackground.js +++ b/js/common/ParallaxBackground.js @@ -148,9 +148,9 @@ class ParallaxBackground extends React.Component { } } -var HEADER_HEIGHT = HEIGHT + 156; +const HEADER_HEIGHT = HEIGHT + 156; -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { position: "absolute", left: 0, diff --git a/js/common/ViewPager.js b/js/common/ViewPager.js index 88ddca390..7d0d1022e 100644 --- a/js/common/ViewPager.js +++ b/js/common/ViewPager.js @@ -135,8 +135,8 @@ class ViewPager extends React.Component { } renderContent(): Array { - var { width, height } = this.state; - var style = Platform.OS === "ios" && styles.card; + const { width, height } = this.state; + const style = Platform.OS === "ios" && styles.card; return React.Children.map(this.props.children, (child, i) => ( {child} @@ -145,7 +145,7 @@ class ViewPager extends React.Component { } handleHorizontalScroll(e: any) { - var selectedIndex = e.nativeEvent.position; + let selectedIndex = e.nativeEvent.position; if (selectedIndex === undefined) { selectedIndex = Math.round( e.nativeEvent.contentOffset.x / this.state.width @@ -175,7 +175,7 @@ class ViewPager extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { flex: 1 }, diff --git a/js/filter/FilterScreen.android.js b/js/filter/FilterScreen.android.js index 4f9855b8b..bb54341a8 100644 --- a/js/filter/FilterScreen.android.js +++ b/js/filter/FilterScreen.android.js @@ -156,8 +156,8 @@ class FilterScreen extends React.Component { } toggleTopic(topic: string, value: boolean) { - var selectedTopics = { ...this.state.selectedTopics }; - var value = !selectedTopics[topic]; + const selectedTopics = { ...this.state.selectedTopics }; + let value = !selectedTopics[topic]; if (value) { selectedTopics[topic] = true; } else { @@ -193,7 +193,7 @@ class FilterScreen extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ contentWrapper: { flex: 1, alignItems: "flex-end" diff --git a/js/filter/FilterScreen.ios.js b/js/filter/FilterScreen.ios.js index 3424de26d..f02872954 100644 --- a/js/filter/FilterScreen.ios.js +++ b/js/filter/FilterScreen.ios.js @@ -157,8 +157,8 @@ class FilterScreen extends React.Component { } toggleTopic(topic: string, value: boolean) { - var selectedTopics = { ...this.state.selectedTopics }; - var value = !selectedTopics[topic]; + const selectedTopics = { ...this.state.selectedTopics }; + const value = !selectedTopics[topic]; if (value) { selectedTopics[topic] = true; } else { @@ -191,7 +191,7 @@ class FilterScreen extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: F8Colors.tangaroa diff --git a/js/filter/FriendsList.js b/js/filter/FriendsList.js index dbe9d6c82..5d48a62bb 100644 --- a/js/filter/FriendsList.js +++ b/js/filter/FriendsList.js @@ -25,7 +25,7 @@ "use strict"; import React from "react-native"; -var { Image, StyleSheet, Text, TouchableOpacity, View } = React; +const { Image, StyleSheet, Text, TouchableOpacity, View } = React; type Friend = { id: string, @@ -69,8 +69,8 @@ class UserPog extends React.Component { }; render() { - var { id, name } = this.props.user; - var firstName = name.split(" ")[0]; // TODO: problems with i18n + const { id, name } = this.props.user; + const firstName = name.split(" ")[0]; // TODO: problems with i18n return ( }; function topics(state: State = [], action: Action): State { if (action.type === "LOADED_SESSIONS") { - var topicsMap = Object.create(null); + const topicsMap = Object.create(null); action.list.forEach(session => { - var tags = session.get("tags") || []; + const tags = session.get("tags") || []; tags.forEach(tag => { topicsMap[tag] = true; }); diff --git a/js/reducers/sessions.js b/js/reducers/sessions.js index c437dc983..d2081c9ef 100644 --- a/js/reducers/sessions.js +++ b/js/reducers/sessions.js @@ -53,7 +53,7 @@ export type Session = { }; function fromParseSpeaker(speaker: Object): Speaker { - var pic = speaker.get("speakerPic"); + const pic = speaker.get("speakerPic"); return { id: speaker.id, bio: speaker.get("speakerBio"), diff --git a/js/reducers/videoTopics.js b/js/reducers/videoTopics.js index f02ae808b..47c71a2cf 100644 --- a/js/reducers/videoTopics.js +++ b/js/reducers/videoTopics.js @@ -29,9 +29,9 @@ type Action = { type: string, list: Array }; function topics(state: State = [], action: Action): State { if (action.type === "LOADED_VIDEOS") { - var topicsMap = Object.create(null); + const topicsMap = Object.create(null); action.list.forEach(video => { - var tags = video.get("tags") || []; + const tags = video.get("tags") || []; tags.forEach(tag => { topicsMap[tag] = true; }); diff --git a/js/store/configureStore.js b/js/store/configureStore.js index 2dc505f0e..d6267c7a7 100644 --- a/js/store/configureStore.js +++ b/js/store/configureStore.js @@ -33,15 +33,15 @@ import { persistStore, autoRehydrate } from "redux-persist"; import { AsyncStorage } from "react-native"; import { ensureCompatibility } from "./compatibility"; -var isDebuggingInChrome = false; +const isDebuggingInChrome = false; -var logger = createLogger({ +const logger = createLogger({ predicate: (getState, action) => isDebuggingInChrome, collapsed: true, duration: true }); -var createF8Store = applyMiddleware(thunk, promise, array, analytics, logger)( +const createF8Store = applyMiddleware(thunk, promise, array, analytics, logger)( createStore ); diff --git a/js/tabs/MenuItem.js b/js/tabs/MenuItem.js index 368cb3a82..9d12c76ad 100644 --- a/js/tabs/MenuItem.js +++ b/js/tabs/MenuItem.js @@ -41,9 +41,9 @@ class MenuItem extends React.Component { }; render() { - var icon = this.props.selected ? this.props.selectedIcon : this.props.icon; - var selectedTitleStyle = this.props.selected && styles.selectedTitle; - var badge; + let icon = this.props.selected ? this.props.selectedIcon : this.props.icon; + const selectedTitleStyle = this.props.selected && styles.selectedTitle; + let badge; if (this.props.badge) { badge = ( @@ -65,7 +65,7 @@ class MenuItem extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { flexDirection: "row", height: 50, diff --git a/js/tabs/demos/DemosCarousel.js b/js/tabs/demos/DemosCarousel.js index 61f401e42..37150cb34 100644 --- a/js/tabs/demos/DemosCarousel.js +++ b/js/tabs/demos/DemosCarousel.js @@ -118,7 +118,7 @@ class DemosCarousel extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: F8Colors.white diff --git a/js/tabs/demos/F8DemoDetails.js b/js/tabs/demos/F8DemoDetails.js index fa779de15..2cacbbc54 100644 --- a/js/tabs/demos/F8DemoDetails.js +++ b/js/tabs/demos/F8DemoDetails.js @@ -54,7 +54,7 @@ const WINDOW_WIDTH = Dimensions.get("window").width, ============================================================================= */ -var F8DemoDetails = React.createClass({ +const F8DemoDetails = React.createClass({ getInitialState: function() { return { scrollTop: 0 @@ -200,11 +200,11 @@ class Section extends React.Component { }; render() { - var { children } = this.props; + const { children } = this.props; if (React.Children.count(children) === 0) { return null; } - var header; + let header; if (this.props.title) { header = ( @@ -223,7 +223,7 @@ class Section extends React.Component { /* StyleSheet =============================================================== */ -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: "white" diff --git a/js/tabs/info/CommonQuestions.js b/js/tabs/info/CommonQuestions.js index fc5e5d053..4b5e08362 100644 --- a/js/tabs/info/CommonQuestions.js +++ b/js/tabs/info/CommonQuestions.js @@ -76,7 +76,7 @@ class Row extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ row: { marginVertical: 15 }, diff --git a/js/tabs/info/DirectionsLink.js b/js/tabs/info/DirectionsLink.js index 0ec36a76e..ae36161fe 100644 --- a/js/tabs/info/DirectionsLink.js +++ b/js/tabs/info/DirectionsLink.js @@ -67,19 +67,19 @@ class DirectionsLink extends React.Component { }; openMaps = option => { - var address = encodeURIComponent(this.props.address); + const address = encodeURIComponent(this.props.address); switch (option) { case 0: F8Linking.openURL("https://maps.apple.com/?q=" + address); break; case 1: - var nativeGoogleUrl = + const nativeGoogleUrl = "comgooglemaps-x-callback://?q=" + address + "&x-success=f8://&x-source=F8"; F8Linking.canOpenURL(nativeGoogleUrl).then(supported => { - var url = supported + const url = supported ? nativeGoogleUrl : "https://maps.google.com/?q=" + address; F8Linking.openURL(url); diff --git a/js/tabs/info/LinksList.js b/js/tabs/info/LinksList.js index 0b5260bc6..21d49828c 100644 --- a/js/tabs/info/LinksList.js +++ b/js/tabs/info/LinksList.js @@ -92,8 +92,8 @@ class Row extends React.Component { }; render() { - var { logo, title } = this.props.link; - var image = logo && ( + const { logo, title } = this.props.link; + const image = logo && ( , push: Array ): Array { - var uniquePush = push.filter(pushNotification => { - var existsOnServer = server.find( + const uniquePush = push.filter(pushNotification => { + const existsOnServer = server.find( serverNotification => serverNotification.text === pushNotification.text ); return !existsOnServer; }); - var all = [].concat(server, uniquePush); + const all = [].concat(server, uniquePush); return all.sort((a, b) => b.time - a.time); } diff --git a/js/tabs/notifications/findSessionByURI.js b/js/tabs/notifications/findSessionByURI.js index 5d5a06886..88dd554d0 100644 --- a/js/tabs/notifications/findSessionByURI.js +++ b/js/tabs/notifications/findSessionByURI.js @@ -29,9 +29,9 @@ function findSessionByURI(sessions: Array, uri: ?string): ?Session { if (!uri) { return null; } - var slug = uri.replace("f8://", ""); - for (var i = 0; i < sessions.length; i++) { - var session = sessions[i]; + const slug = uri.replace("f8://", ""); + for (let i = 0; i < sessions.length; i++) { + const session = sessions[i]; if (session.slug === slug || session.id === slug) { return session; } diff --git a/js/tabs/schedule/EmptySchedule.js b/js/tabs/schedule/EmptySchedule.js index 351a61e8c..3f04eef58 100644 --- a/js/tabs/schedule/EmptySchedule.js +++ b/js/tabs/schedule/EmptySchedule.js @@ -65,7 +65,7 @@ class EmptySchedule extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { justifyContent: "center" }, diff --git a/js/tabs/schedule/F8FriendGoing.js b/js/tabs/schedule/F8FriendGoing.js index 141895a4e..cb370288c 100644 --- a/js/tabs/schedule/F8FriendGoing.js +++ b/js/tabs/schedule/F8FriendGoing.js @@ -50,7 +50,7 @@ class F8FriendGoing extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { flexDirection: "row", alignItems: "center", diff --git a/js/tabs/schedule/F8GanttGrid.js b/js/tabs/schedule/F8GanttGrid.js index 91adf48a2..49b22b52f 100644 --- a/js/tabs/schedule/F8GanttGrid.js +++ b/js/tabs/schedule/F8GanttGrid.js @@ -51,7 +51,7 @@ export default class F8GanttGrid extends React.Component { renderColumns(momentStart, count) { let cols = []; let previousLabelAMPM = null; - for (var i = 0; i < count + 1; i++) { + for (let i = 0; i < count + 1; i++) { const left = this.props.containerWidth / count * i - LABELS_WIDTH / 2; let label = null; if (i % 2 === 0) { diff --git a/js/tabs/schedule/F8SessionCell.js b/js/tabs/schedule/F8SessionCell.js index 255bd4044..582edeedb 100644 --- a/js/tabs/schedule/F8SessionCell.js +++ b/js/tabs/schedule/F8SessionCell.js @@ -163,7 +163,7 @@ class F8SessionCell extends React.Component { /* StyleSheet ============================================================================= */ -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ cell: { paddingTop: CELL_PADDING_TOP, paddingBottom: CELL_PADDING_BOTTOM, diff --git a/js/tabs/schedule/F8SessionDetails.js b/js/tabs/schedule/F8SessionDetails.js index d5a0315f8..954679791 100644 --- a/js/tabs/schedule/F8SessionDetails.js +++ b/js/tabs/schedule/F8SessionDetails.js @@ -48,7 +48,7 @@ const WINDOW_WIDTH = Dimensions.get("window").width, HORIZONTAL_BREAKPOINT = WINDOW_WIDTH <= 320, CONTENT_PADDING_H = HORIZONTAL_BREAKPOINT ? 20 : 30; -var F8SessionDetails = React.createClass({ +const F8SessionDetails = React.createClass({ getInitialState: function() { return { scrollTop: 0, @@ -116,7 +116,8 @@ var F8SessionDetails = React.createClass({ }, renderSpeakers() { - var speakersProfiles = (this.props.session.speakers || []).map(speaker => ( + const speakersProfiles = (this.props.session.speakers || [] + ).map(speaker => ( @@ -263,7 +264,7 @@ class Section extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: "white" diff --git a/js/tabs/schedule/F8SpeakerProfile.js b/js/tabs/schedule/F8SpeakerProfile.js index 68f0c9cce..50cbc1ee7 100644 --- a/js/tabs/schedule/F8SpeakerProfile.js +++ b/js/tabs/schedule/F8SpeakerProfile.js @@ -29,9 +29,9 @@ import React from "react"; import { Heading3, Text } from "../../common/F8Text"; import { StyleSheet, View } from "react-native"; -var F8SpeakerProfile = React.createClass({ +const F8SpeakerProfile = React.createClass({ render: function() { - var speaker = this.props.speaker; + const speaker = this.props.speaker; return ( {speaker.name} @@ -43,7 +43,7 @@ var F8SpeakerProfile = React.createClass({ } }); -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ row: { paddingBottom: 14 }, diff --git a/js/tabs/schedule/FilterHeader.js b/js/tabs/schedule/FilterHeader.js index c02c0438f..9c2bc4fb3 100644 --- a/js/tabs/schedule/FilterHeader.js +++ b/js/tabs/schedule/FilterHeader.js @@ -44,7 +44,7 @@ class FilterHeader extends React.Component { }; render() { - var topics = Object.keys(this.props.filter); + const topics = Object.keys(this.props.filter); if (topics.length === 0) { return null; } diff --git a/js/tabs/schedule/FriendCell.js b/js/tabs/schedule/FriendCell.js index 6394a3a7d..88cd0720c 100644 --- a/js/tabs/schedule/FriendCell.js +++ b/js/tabs/schedule/FriendCell.js @@ -71,7 +71,7 @@ class FriendCell extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ cell: { height: 68, paddingLeft: 11, diff --git a/js/tabs/schedule/FriendsUsingApp.js b/js/tabs/schedule/FriendsUsingApp.js index ff3d105b7..41c74ce3e 100644 --- a/js/tabs/schedule/FriendsUsingApp.js +++ b/js/tabs/schedule/FriendsUsingApp.js @@ -125,7 +125,7 @@ class FriendsUsingApp extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { alignItems: "center" }, diff --git a/js/tabs/schedule/PrivacyIcon.js b/js/tabs/schedule/PrivacyIcon.js index 994921ce3..5eca1c133 100644 --- a/js/tabs/schedule/PrivacyIcon.js +++ b/js/tabs/schedule/PrivacyIcon.js @@ -109,7 +109,7 @@ class PrivacyIcon extends React.Component { /* Styles ============================================================================= */ -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { alignItems: "center", justifyContent: "center" diff --git a/js/tabs/schedule/ProfileButton.js b/js/tabs/schedule/ProfileButton.js index e36590a2d..b140c5ba0 100644 --- a/js/tabs/schedule/ProfileButton.js +++ b/js/tabs/schedule/ProfileButton.js @@ -39,7 +39,7 @@ class ProfileButton extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ profilePic: { width: 30, height: 30, diff --git a/js/tabs/schedule/SessionsCarousel.js b/js/tabs/schedule/SessionsCarousel.js index b55f50f2e..4a21845b1 100644 --- a/js/tabs/schedule/SessionsCarousel.js +++ b/js/tabs/schedule/SessionsCarousel.js @@ -68,9 +68,9 @@ class SessionsCarusel extends React.Component { constructor(props: Props) { super(props); - var flatSessionsList = []; - var contexts: Array = []; - var allSessions = this.props.allSessions; + const flatSessionsList = []; + const contexts: Array = []; + let allSessions = this.props.allSessions; if (!allSessions) { const { session } = this.props; allSessions = { @@ -112,7 +112,7 @@ class SessionsCarusel extends React.Component { } render() { - var { rowIndex, sectionLength, sectionTitle } = this.state.contexts[ + const { rowIndex, sectionLength, sectionTitle } = this.state.contexts[ this.state.selectedIndex ]; @@ -191,7 +191,7 @@ class SessionsCarusel extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: F8Colors.white diff --git a/js/tabs/schedule/SessionsSectionHeader.js b/js/tabs/schedule/SessionsSectionHeader.js index 4657fad42..8645c6efe 100644 --- a/js/tabs/schedule/SessionsSectionHeader.js +++ b/js/tabs/schedule/SessionsSectionHeader.js @@ -43,7 +43,7 @@ class SessionsSectionHeader extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ header: { // position:'relative', left: 0, diff --git a/js/tabs/schedule/SharingSettingsCommon.js b/js/tabs/schedule/SharingSettingsCommon.js index e7d370bd7..c56f86dd5 100644 --- a/js/tabs/schedule/SharingSettingsCommon.js +++ b/js/tabs/schedule/SharingSettingsCommon.js @@ -65,7 +65,7 @@ class SharingSettingsCommon extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { alignItems: "center" }, diff --git a/js/tabs/schedule/SharingSettingsScreen.js b/js/tabs/schedule/SharingSettingsScreen.js index a1790d98c..11db68ae4 100644 --- a/js/tabs/schedule/SharingSettingsScreen.js +++ b/js/tabs/schedule/SharingSettingsScreen.js @@ -99,7 +99,7 @@ class SharingSettingsScreen extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { flex: 1, justifyContent: "center", diff --git a/js/tabs/schedule/filterSessions.js b/js/tabs/schedule/filterSessions.js index 2b8c606b6..f76c47be1 100644 --- a/js/tabs/schedule/filterSessions.js +++ b/js/tabs/schedule/filterSessions.js @@ -36,7 +36,7 @@ function byTopics(sessions: Array, topics: StringMap): Array { return sessions; } return sessions.filter(session => { - var hasMatchingTag = false; + let hasMatchingTag = false; session.tags.forEach(tag => { hasMatchingTag = hasMatchingTag || topics[tag]; }); diff --git a/js/tabs/schedule/groupSessions.js b/js/tabs/schedule/groupSessions.js index ea401a1d9..36ac7e05e 100644 --- a/js/tabs/schedule/groupSessions.js +++ b/js/tabs/schedule/groupSessions.js @@ -32,9 +32,9 @@ export type SessionsListData = { }; function groupSessions(sessions: Array): SessionsListData { - var data = {}; + const data = {}; sessions.forEach(session => { - var timeSectionKey = session.allDay + const timeSectionKey = session.allDay ? "All Day" : formatTime(session.startTime); data[timeSectionKey] = data[timeSectionKey] || {}; diff --git a/server/parse-server/cloud/auth.js b/server/parse-server/cloud/auth.js index 276ae4901..05cda47c5 100644 --- a/server/parse-server/cloud/auth.js +++ b/server/parse-server/cloud/auth.js @@ -1,4 +1,4 @@ -var tokenTypes = { +const tokenTypes = { PushConsole: 1, MessengerBot: 2, SurveyExports: 3 diff --git a/server/parse-server/cloud/functions/agenda.js b/server/parse-server/cloud/functions/agenda.js index 305a1a5de..5b9df6c80 100644 --- a/server/parse-server/cloud/functions/agenda.js +++ b/server/parse-server/cloud/functions/agenda.js @@ -7,15 +7,15 @@ import _ from "lodash"; import moment from "moment"; Parse.Cloud.define("agenda", function(request, response) { - var Agenda = Parse.Object.extend("Agenda"); - var query = new Parse.Query(Agenda); + const Agenda = Parse.Object.extend("Agenda"); + const query = new Parse.Query(Agenda); function queryAgenda() { return new Promise(function(resolve, reject) { query.include("speakers"); query.exists("day"); query.find({ useMasterKey: true }).then(function(results) { - var json = results.map(function(result) { + const json = results.map(function(result) { return result.toJSON(); }); buildSchedule(json).then(function(formattedSchedule) { @@ -26,8 +26,8 @@ Parse.Cloud.define("agenda", function(request, response) { } function buildSchedule(schedule) { - var dayArrayLookup; - var sortedSchedule = [{}, {}]; + let dayArrayLookup; + const sortedSchedule = [{}, {}]; return new Promise(function(resolve, reject) { _.forEach(schedule, function(session) { diff --git a/server/parse-server/cloud/functions/friends.js b/server/parse-server/cloud/functions/friends.js index dc343b826..341068ec2 100644 --- a/server/parse-server/cloud/functions/friends.js +++ b/server/parse-server/cloud/functions/friends.js @@ -2,7 +2,7 @@ /* global Parse */ Parse.Cloud.define("friends", function(request, response) { - var user = request.user; + const user = request.user; if (!user) { return response.success([]); } @@ -10,8 +10,8 @@ Parse.Cloud.define("friends", function(request, response) { return response.error("Current user is not linked to Facebook"); } - var authData = user.get("authData"); - var token = authData.facebook.access_token; + const authData = user.get("authData"); + const token = authData.facebook.access_token; // TODO: Fetch all friends using paging Parse.Cloud .httpRequest({ @@ -19,11 +19,11 @@ Parse.Cloud.define("friends", function(request, response) { "https://graph.facebook.com/me/friends?fields=id&access_token=" + token }) .then(function(res) { - var friendIds = res.data.data.map(function(friend) { + const friendIds = res.data.data.map(function(friend) { return friend.id; }); - var query = new Parse.Query(Parse.User) + const query = new Parse.Query(Parse.User) .containedIn("facebook_id", friendIds) .ascending("name"); @@ -58,7 +58,7 @@ function fetchSchedule(user) { .query() .find({ useMasterKey: true }) .then(function(sessions) { - var schedule = {}; + const schedule = {}; sessions.forEach(function(session) { schedule[session.id] = true; }); diff --git a/server/parse-server/cloud/functions/meetups.js b/server/parse-server/cloud/functions/meetups.js index 4bc98e95e..0819e706d 100644 --- a/server/parse-server/cloud/functions/meetups.js +++ b/server/parse-server/cloud/functions/meetups.js @@ -1,12 +1,12 @@ "use strict"; /* global Parse */ -var Meetups = Parse.Object.extend("Meetups"); -var Sponsors = Parse.Object.extend("MeetupSponsors"); +const Meetups = Parse.Object.extend("Meetups"); +const Sponsors = Parse.Object.extend("MeetupSponsors"); Parse.Cloud.define("meetups", function(request, response) { - var meetupsQuery = new Parse.Query(Meetups); - var sponsorsQuery = new Parse.Query(Sponsors); + const meetupsQuery = new Parse.Query(Meetups); + const sponsorsQuery = new Parse.Query(Sponsors); function queryMeetups() { return new Promise(function(resolve, reject) { diff --git a/server/parse-server/cloud/functions/messengerbot.js b/server/parse-server/cloud/functions/messengerbot.js index b4551efff..8065aec43 100644 --- a/server/parse-server/cloud/functions/messengerbot.js +++ b/server/parse-server/cloud/functions/messengerbot.js @@ -1,7 +1,7 @@ "use strict"; /* global Parse */ -var Agenda = Parse.Object.extend("Agenda"); +const Agenda = Parse.Object.extend("Agenda"); import CloudAuth from "../auth"; @@ -16,7 +16,7 @@ Parse.Cloud.define("mbot_get_schedule", function(request, response) { } // just in case passed as number - var fbid = String(request.params.facebook_user_id); + const fbid = String(request.params.facebook_user_id); // do query new Parse.Query(Parse.User) @@ -46,7 +46,7 @@ function fetchSchedule(user) { .query() .find({ useMasterKey: true }) .then(function(sessions) { - var schedule = {}; + const schedule = {}; sessions.forEach(function(session) { schedule[session.id] = true; }); @@ -69,8 +69,8 @@ Parse.Cloud.define("mbot_add_to_schedule", function(request, response) { } // just in case passed as number - var fbid = String(request.params.facebook_user_id); - var sid = String(request.params.session_id); + const fbid = String(request.params.facebook_user_id); + const sid = String(request.params.session_id); // do query new Parse.Query(Parse.User) @@ -108,8 +108,8 @@ Parse.Cloud.define("mbot_remove_from_schedule", function(request, response) { } // just in case passed as number - var fbid = String(request.params.facebook_user_id); - var sid = String(request.params.session_id); + const fbid = String(request.params.facebook_user_id); + const sid = String(request.params.session_id); // do query new Parse.Query(Parse.User) @@ -147,7 +147,7 @@ Parse.Cloud.define("mbot_users_by_session", function(request, response) { } // just in case passed as number - var sid = String(request.params.session_id); + const sid = String(request.params.session_id); // do many queries new Parse.Query(Parse.User) @@ -162,7 +162,7 @@ Parse.Cloud.define("mbot_users_by_session", function(request, response) { }) .then( function(value) { - var filtered = []; + const filtered = []; value.forEach(function(u) { if (u !== null) { filtered.push({ @@ -189,7 +189,7 @@ function hasSavedSession(user, sid) { .query() .find({ useMasterKey: true }) .then(function(sessions) { - var userSavedSession = false; + let userSavedSession = false; sessions.forEach(function(session) { if (session.id === sid) { userSavedSession = true; diff --git a/server/parse-server/cloud/functions/notifications.js b/server/parse-server/cloud/functions/notifications.js index e88918b8f..55377d3ba 100644 --- a/server/parse-server/cloud/functions/notifications.js +++ b/server/parse-server/cloud/functions/notifications.js @@ -4,8 +4,8 @@ import CloudAuth from "../auth"; -var Notification = Parse.Object.extend("Notification"); // Done: make real -var PendingNotifications = Parse.Object.extend("PendingNotifications"); +const Notification = Parse.Object.extend("Notification"); // Done: make real +const PendingNotifications = Parse.Object.extend("PendingNotifications"); Parse.Cloud.define("send_push_by_channel", function(request, response) { // gate request by cc push token @@ -18,7 +18,7 @@ Parse.Cloud.define("send_push_by_channel", function(request, response) { return response.error("Error: missing required params"); } - var pushData = request.params.data; + const pushData = request.params.data; pushData.badge = "Increment"; pushData.sound = "default"; diff --git a/server/parse-server/cloud/functions/surveyexports.js b/server/parse-server/cloud/functions/surveyexports.js index f1bf9ff6b..33adca83e 100644 --- a/server/parse-server/cloud/functions/surveyexports.js +++ b/server/parse-server/cloud/functions/surveyexports.js @@ -1,9 +1,9 @@ "use strict"; /* global Parse */ -var Survey = Parse.Object.extend("Survey"); -var SurveyResult = Parse.Object.extend("SurveyResult"); -var SurveyQuestions = Parse.Object.extend("SurveyQuestions"); +const Survey = Parse.Object.extend("Survey"); +const SurveyResult = Parse.Object.extend("SurveyResult"); +const SurveyQuestions = Parse.Object.extend("SurveyQuestions"); import CloudAuth from "../auth"; @@ -12,9 +12,9 @@ Parse.Cloud.define("survey_response_rate", function(request, response) { return response.error("CloudAuth: Permission denied (survey export)"); } - var allQuery = new Parse.Query(SurveyResult).count({ useMasterKey: true }); + const allQuery = new Parse.Query(SurveyResult).count({ useMasterKey: true }); - var incompleteQuery = new Parse.Query(SurveyResult) + const incompleteQuery = new Parse.Query(SurveyResult) .equalTo("rawAnswers", null) .count({ useMasterKey: true }); @@ -47,8 +47,8 @@ Parse.Cloud.define("export_survey_results_by_questions", function( return response.error({ message: "Need a question set id" }); } - var paginatedLength = 1000; - var sq = new SurveyQuestions(); + const paginatedLength = 1000; + const sq = new SurveyQuestions(); sq.id = request.params.questions_id; // before making queries, figure out how many it will take (via count) @@ -58,9 +58,9 @@ Parse.Cloud.define("export_survey_results_by_questions", function( .count({ useMasterKey: true }) // count the results .then(function(totalCount) { // create as many queries as it takes to get all relevant results - var queries = []; - var iterations = Math.ceil(totalCount / paginatedLength); - for (var i = 0; i < iterations; i++) { + const queries = []; + const iterations = Math.ceil(totalCount / paginatedLength); + for (let i = 0; i < iterations; i++) { queries.push( new Parse.Query(SurveyResult) .notEqualTo("rawAnswers", null) @@ -81,7 +81,7 @@ Parse.Cloud.define("export_survey_results_by_questions", function( }) .then(function(grouped) { // group the paginated queries into a flat array of SurveyResult-s; - var combined = []; + const combined = []; grouped.map(function(g) { g.map(function(r) { combined.push({ @@ -104,17 +104,17 @@ Parse.Cloud.define("export_survey_results_by_questions", function( .get(sq.id, { useMasterKey: true }) .then(function(questionKey) { // common result keys - var sessionIdKey = "Session Id"; - var sessionTitleKey = "Session Title"; - var fbidKey = "App-scoped User Id"; - var csvKeys = [sessionIdKey, sessionTitleKey, fbidKey]; // append the rest later; + const sessionIdKey = "Session Id"; + const sessionTitleKey = "Session Title"; + const fbidKey = "App-scoped User Id"; + const csvKeys = [sessionIdKey, sessionTitleKey, fbidKey]; // append the rest later; // get the raw question data - var rawQuestions = questionKey.get("questions"); + const rawQuestions = questionKey.get("questions"); // process the raw data arrays and end up with normalized columns - var arrayResults = allSurveyResults.map(function(resultObj) { - var surveyResultArr = JSON.parse(resultObj.answers); + const arrayResults = allSurveyResults.map(function(resultObj) { + const surveyResultArr = JSON.parse(resultObj.answers); // create temp result obj - var obj = {}; + const obj = {}; // set common columns obj[sessionIdKey] = resultObj.sessionId; obj[sessionTitleKey] = resultObj.sessionTitle; @@ -122,11 +122,11 @@ Parse.Cloud.define("export_survey_results_by_questions", function( // set survey-specific columns surveyResultArr.map(function(answerValue, answerIndex) { // mutate temp object with variable amount of columns - var question = rawQuestions[answerIndex]; + const question = rawQuestions[answerIndex]; // flatten further if question is of a multiple-response type if (question.ratings && question.ratings.rows) { question.ratings.rows.map(function(rowItem, rowIndex) { - var normalizedArrayKey = rowItem + " - " + question.text; + const normalizedArrayKey = rowItem + " - " + question.text; obj[normalizedArrayKey] = answerValue[rowIndex]; // add to list of csv cols (once) if (csvKeys.indexOf(normalizedArrayKey) < 0) { diff --git a/server/parse-server/cloud/functions/surveys.js b/server/parse-server/cloud/functions/surveys.js index 279e41985..b1efa16b6 100644 --- a/server/parse-server/cloud/functions/surveys.js +++ b/server/parse-server/cloud/functions/surveys.js @@ -1,10 +1,10 @@ "use strict"; /* global Parse */ -var Agenda = Parse.Object.extend("Agenda"); -var Attendance = Parse.Object.extend("Attendance"); -var Survey = Parse.Object.extend("Survey"); -var SurveyResult = Parse.Object.extend("SurveyResult"); +const Agenda = Parse.Object.extend("Agenda"); +const Attendance = Parse.Object.extend("Attendance"); +const Survey = Parse.Object.extend("Survey"); +const SurveyResult = Parse.Object.extend("SurveyResult"); import CloudAuth from "../auth"; @@ -13,18 +13,18 @@ Parse.Cloud.define("send_surveys", function(request, response) { return response.error("CloudAuth: Permission denied (push)"); } - var sessionId = request.params.sessionId; + const sessionId = request.params.sessionId; if (!sessionId) { return response.error("Need sessionId"); } console.log("Fetching attendees for " + sessionId); - var agenda = new Agenda({ id: sessionId }); - var attendees = new Parse.Query(Attendance) + const agenda = new Agenda({ id: sessionId }); + const attendees = new Parse.Query(Attendance) .equalTo("agenda", agenda) .notEqualTo("sent", true) .find({ useMasterKey: true }); - var survey = new Parse.Query(Survey) + const survey = new Parse.Query(Survey) .equalTo("session", agenda) .first({ useMasterKey: true }); @@ -44,7 +44,7 @@ Parse.Cloud.define("send_surveys", function(request, response) { Parse.Cloud.define("surveys", function(request, response) { // Parse.Cloud.useMasterKey(); - var user = request.user; + const user = request.user; if (!user) { return response.success([]); } @@ -70,12 +70,12 @@ Parse.Cloud.define("surveys", function(request, response) { Parse.Cloud.define("submit_survey", function(request, response) { // Parse.Cloud.useMasterKey(); - var user = request.user; + const user = request.user; if (!user) { return response.error({ message: "Not logged in" }); } - var params = request.params; + const params = request.params; if (!params.id || !params.answers) { return response.error({ message: "Need id and answers" }); } @@ -116,7 +116,7 @@ function sendSurveys(attendees, survey, session) { return Parse.Promise .when( attendees.map(function(record) { - var user = record.get("user"); + const user = record.get("user"); return new SurveyResult() .save( { @@ -154,7 +154,7 @@ function sendSurveys(attendees, survey, session) { function toSurveys(emptyResults) { return emptyResults.map(function(emptyResult) { - var survey = emptyResult.get("survey"); + const survey = emptyResult.get("survey"); return { id: emptyResult.id, sessionId: survey.get("session").id, diff --git a/server/parse-server/cloud/functions/tests.js b/server/parse-server/cloud/functions/tests.js index 8a398fd8d..145687b83 100644 --- a/server/parse-server/cloud/functions/tests.js +++ b/server/parse-server/cloud/functions/tests.js @@ -1,22 +1,22 @@ "use strict"; /* global Parse */ -var Survey = Parse.Object.extend("Survey"); -var SurveyResult = Parse.Object.extend("SurveyResult"); +const Survey = Parse.Object.extend("Survey"); +const SurveyResult = Parse.Object.extend("SurveyResult"); Parse.Cloud.define("test_push", function(request, response) { // Parse.Cloud.useMasterKey(); - var user = request.user; + const user = request.user; if (!user) { return response.error({ message: "Not logged in" }); } - var query = new Parse.Query(Parse.Installation); + const query = new Parse.Query(Parse.Installation); query.equalTo("user", user); - var userName = user.get("name").split(" ")[0]; - var data; + const userName = user.get("name").split(" ")[0]; + let data; if (request.params.url === "link") { data = { alert: "Hey " + userName + ", check out this great website", @@ -75,7 +75,7 @@ Parse.Cloud.define("test_push", function(request, response) { Parse.Cloud.define("test_survey", function(request, response) { // Parse.Cloud.useMasterKey(); - var user = request.user; + const user = request.user; if (!user) { return response.error({ message: "Not logged in" }); } @@ -86,7 +86,7 @@ Parse.Cloud.define("test_survey", function(request, response) { .then(pickRandom) .then(function(survey) { console.log(survey); - var sessionTitle = survey.get("session").get("sessionTitle"); + const sessionTitle = survey.get("session").get("sessionTitle"); return new SurveyResult() .save({ user: user, survey: survey }, { useMasterKey: true }) .then(function() { @@ -118,12 +118,12 @@ function pickRandom(list) { if (list.length === 0) { throw new Error("Can not pick random item from empty list"); } - var index = Math.floor(Math.random() * list.length); + const index = Math.floor(Math.random() * list.length); return list[index]; } Parse.Cloud.define("test_attendance", function(request, response) { - var Agenda = Parse.Object.extend("Agenda"); + const Agenda = Parse.Object.extend("Agenda"); new Parse.Query(Agenda) .select(["id", "sessionTitle"]) .find({ useMasterKey: true }) diff --git a/server/parse-server/cloud/jobs/installationSync.js b/server/parse-server/cloud/jobs/installationSync.js index fc6d6800e..6e4eb061d 100644 --- a/server/parse-server/cloud/jobs/installationSync.js +++ b/server/parse-server/cloud/jobs/installationSync.js @@ -3,7 +3,7 @@ Parse.Cloud.job("installationSync", function(request, status) { // Parse.Cloud.useMasterKey(); - var counter = 0; + let counter = 0; new Parse.Query(Parse.Installation) .get({ useMasterKey: true }) diff --git a/server/parse-server/cloud/jobs/unmaskAgenda.js b/server/parse-server/cloud/jobs/unmaskAgenda.js index 6c30e77c8..784a968cf 100644 --- a/server/parse-server/cloud/jobs/unmaskAgenda.js +++ b/server/parse-server/cloud/jobs/unmaskAgenda.js @@ -1,11 +1,11 @@ "use strict"; /* global Parse */ -var Agenda = Parse.Object.extend("Agenda"), +const Agenda = Parse.Object.extend("Agenda"), UnmaskedAgenda = Parse.Object.extend("UnmaskedAgenda"); Parse.Cloud.job("unmaskAgenda", function(request, status) { - var countTotal = 0, + let countTotal = 0, countUpdated = 0; // here we go new Parse.Query(UnmaskedAgenda) @@ -28,7 +28,7 @@ Parse.Cloud.job("unmaskAgenda", function(request, status) { throw new Error("No matching Agenda item to update!"); } // ...or proceed to updating the fields - var updates = {}; + const updates = {}; if (unmasked.get("sessionSlug")) { updates.sessionSlug = unmasked.get("sessionSlug"); } @@ -51,7 +51,7 @@ Parse.Cloud.job("unmaskAgenda", function(request, status) { updates.tags = unmasked.get("tags"); } // update the Agenda item with unmasked data, or throw if it there's nothing - var updatedFields = Object.keys(updates); + const updatedFields = Object.keys(updates); if (updatedFields.length) { return masked.save(updates, { useMasterKey: true }); } else { diff --git a/server/parse-server/cloud/jobs/unmaskDemos.js b/server/parse-server/cloud/jobs/unmaskDemos.js index 976fd8a5b..e7cba27fc 100644 --- a/server/parse-server/cloud/jobs/unmaskDemos.js +++ b/server/parse-server/cloud/jobs/unmaskDemos.js @@ -1,11 +1,11 @@ "use strict"; /* global Parse */ -var Demo = Parse.Object.extend("Demo"), +const Demo = Parse.Object.extend("Demo"), UnmaskedDemo = Parse.Object.extend("UnmaskedDemo"); Parse.Cloud.job("unmaskDemo", function(request, status) { - var countTotal = 0, + let countTotal = 0, countUpdated = 0; // for job status feedback new Parse.Query(UnmaskedDemo) @@ -28,7 +28,7 @@ Parse.Cloud.job("unmaskDemo", function(request, status) { throw new Error("No matching Demo item to update!"); } // ...or proceed to updating the fields - var updates = {}; + const updates = {}; if (unmasked.get("title")) { updates.title = unmasked.get("title"); } @@ -42,7 +42,7 @@ Parse.Cloud.job("unmaskDemo", function(request, status) { updates.location = unmasked.get("location"); } // update the Demo item with unmasked data, or throw if it there's nothing - var updatedFields = Object.keys(updates); + const updatedFields = Object.keys(updates); if (updatedFields.length) { return masked.save(updates, { useMasterKey: true }); } else { diff --git a/server/parse-server/cloud/jobs/updateVideoSources.js b/server/parse-server/cloud/jobs/updateVideoSources.js index e161faffb..6205e3b19 100644 --- a/server/parse-server/cloud/jobs/updateVideoSources.js +++ b/server/parse-server/cloud/jobs/updateVideoSources.js @@ -1,21 +1,21 @@ "use strict"; /* global Parse */ -var Video = Parse.Object.extend("Video"), +const Video = Parse.Object.extend("Video"), GRAPH_BASE_URL = "https://graph.facebook.com/v2.8/", GRAPH_FIELDS_PARAM = "?fields=source", //,picture -> poor quality GRAPH_ACCESS_PARAM = "&access_token=" + process.env.FB_GRAPH_ACCESS_TOKEN; Parse.Cloud.job("updateVideoSources", function(request, status) { - var countTotal = "?"; - var countUpdated = 0; + let countTotal = "?"; + let countUpdated = 0; new Parse.Query(Video) .find({ useMasterKey: true }) .then(function(videos) { return Parse.Promise.when( videos.map(function(video) { - var fbid = video.get("facebookId"); + const fbid = video.get("facebookId"); if (countTotal !== videos.length) { countTotal = videos.length; } @@ -26,8 +26,8 @@ Parse.Cloud.job("updateVideoSources", function(request, status) { }) .then( function(response) { - var data = response.data; - var changed = false; + const data = response.data; + let changed = false; // update the video source, if necessary if (data.source && data.source !== video.get("source")) { video.set("source", data.source); diff --git a/server/parse-server/cloud/triggers/pushChannels.js b/server/parse-server/cloud/triggers/pushChannels.js index c9b2a57a2..8f37dd963 100644 --- a/server/parse-server/cloud/triggers/pushChannels.js +++ b/server/parse-server/cloud/triggers/pushChannels.js @@ -3,10 +3,10 @@ Parse.Cloud.afterSave(Parse.User, function(request) { // Parse.Cloud.useMasterKey(); - var installationsQ = new Parse.Query(Parse.Installation) + const installationsQ = new Parse.Query(Parse.Installation) .equalTo("user", request.object) .find({ useMasterKey: true }); - var scheduleQ = request.object + const scheduleQ = request.object .relation("mySchedule") .query() .select(["id"]) @@ -21,7 +21,7 @@ Parse.Cloud.afterSave(Parse.User, function(request) { schedule.length + " sessions in schedule" ); - var sessionIds = schedule.map(function(s) { + const sessionIds = schedule.map(function(s) { return "session_" + s.id; }); console.log(sessionIds); @@ -38,7 +38,7 @@ Parse.Cloud.afterSave(Parse.User, function(request) { }, function(errors) { if (Array.isArray(errors)) { - for (var i = 0; i < errors.length; i++) { + for (let i = 0; i < errors.length; i++) { console.error( "Error! #" + i + " " + errors[i].message || errors[i] ); @@ -51,8 +51,8 @@ Parse.Cloud.afterSave(Parse.User, function(request) { }); Parse.Cloud.beforeSave(Parse.Installation, function(request, response) { - var installation = request.object; - var user = installation.get("user"); + const installation = request.object; + const user = installation.get("user"); if (installation.dirtyKeys().indexOf("user") === -1) { response.success(); return; @@ -66,7 +66,7 @@ Parse.Cloud.beforeSave(Parse.Installation, function(request, response) { .select(["id"]) .find({ useMasterKey: true }) .then(function(schedule) { - var sessionIds = schedule.map(function(s) { + const sessionIds = schedule.map(function(s) { return "session_" + s.id; }); installation.set("channels", sessionIds); diff --git a/server/parse-server/cloud/triggers/videos.js b/server/parse-server/cloud/triggers/videos.js index 49e86133b..4ce2483fc 100644 --- a/server/parse-server/cloud/triggers/videos.js +++ b/server/parse-server/cloud/triggers/videos.js @@ -1,7 +1,7 @@ "use strict"; /* global Parse */ -var Video = Parse.Object.extend("Video"); +const Video = Parse.Object.extend("Video"); Parse.Cloud.afterSave(Video, function(request) { if (request.object.existed()) {