Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linting #35

Merged
merged 1 commit into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"env": {
"browser": true,
"es6": true
},
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
}
}
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"semi": false
}
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ node_js:
install:
- yarn
script:
- yarn build
- yarn run format:ci
- yarn run build
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,17 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"format": "prettier --write \"src/**/*.{js,jsx}\"",
"format:ci": "prettier --list-different \"src/**/*.{js,jsx}\""
},
"devDependencies": {
"css-loader": "^3.1.0",
"eslint": "^5.16.0",
"eslint-config-prettier": "^6.1.0",
"eslint-plugin-prettier": "^3.1.0",
"moment": "^2.22.2",
"prettier": "^1.18.2",
"react-big-calendar": "^0.19.1",
"style-loader": "^0.21.0",
"webpack-dev-server": "3.2.1"
Expand Down
114 changes: 82 additions & 32 deletions src/actions/EventsActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {
getGroupEvents as getFirestoreGroupEvents,
getUserEvents as getFirestoreUserEvents,
getSpaces as getFirestoreSpaces,
watchEvents as watchFirestoreEvents,
watchEvents as watchFirestoreEvents
} from '../firestore/EventsClient'
import {
uploadFile as uploadFirebaseFile,
deleteFile as deleteFirebaseFile,
deleteFile as deleteFirebaseFile
} from '../firestore/FilesClient'
import {
createEvent as createGoogleEvent,
Expand All @@ -26,37 +26,43 @@ import { config } from '../resources/config'

//Create, Update and Delete

export function createEvent(firestore, firebase, event, callback = () => {}, errorCallback = () => {}) {
if(event.poster && !event.internal) {
uploadPoster(firebase, event.poster, (filePath) => {
export function createEvent(
firestore,
firebase,
event,
callback = () => {},
errorCallback = () => {}
) {
if (event.poster && !event.internal) {
uploadPoster(firebase, event.poster, filePath => {
event = {
...event,
poster: filePath,
poster: filePath
}

createGoogleEvent(event, (googleEntry) => {
createGoogleEvent(event, googleEntry => {
event = {
...event,
gCalID: googleEntry.id,
gCalID: googleEntry.id
}

createFirestoreEvent(firestore, event, callback, errorCallback)
})
})
} else if (event.poster) {
uploadPoster(firebase, event.poster, (filePath) => {
uploadPoster(firebase, event.poster, filePath => {
event = {
...event,
poster: filePath,
poster: filePath
}

createFirestoreEvent(firestore, event, callback, errorCallback)
})
} else if (!event.internal) {
createGoogleEvent(event, (googleEntry) => {
createGoogleEvent(event, googleEntry => {
event = {
...event,
gCalID: googleEntry.id,
gCalID: googleEntry.id
}

createFirestoreEvent(firestore, event, callback, errorCallback)
Expand All @@ -66,56 +72,84 @@ export function createEvent(firestore, firebase, event, callback = () => {}, err
}
}

export function updateEvent(firestore, firebase, event, originalEvent, callback = () => {}, errorCallback = () => {}) {
const actionHandleGCal = (firestore, firebase, event, originalEvent, callback) => {
export function updateEvent(
firestore,
firebase,
event,
originalEvent,
callback = () => {},
errorCallback = () => {}
) {
const actionHandleGCal = (
firestore,
firebase,
event,
originalEvent,
callback
) => {
//If there are any changes in whether the event is internal or external
//Else update GCal if it exist, and update Firestore
if(originalEvent.internal !== event.internal) {
if (originalEvent.internal !== event.internal) {
//If it is now internal, delete the GCal event and update
//Else it means, it is now not internal, create a GCal and update
if(event.internal) {
if (event.internal) {
deleteGoogleEvent(event, () => {
event = {
...event,
gCalID: null
}

updateFirestoreEvent(firestore, event, () => callback(event), errorCallback)
updateFirestoreEvent(
firestore,
event,
() => callback(event),
errorCallback
)
})
} else {
createGoogleEvent(event, (googleEntry) => {
createGoogleEvent(event, googleEntry => {
event = {
...event,
gCalID: googleEntry.id
}

updateFirestoreEvent(firestore, event, () => callback(event), errorCallback)
updateFirestoreEvent(
firestore,
event,
() => callback(event),
errorCallback
)
})
}
} else {
if(event.gCalID) {
if (event.gCalID) {
updateGoogleEvent(event, () => {})
}

updateFirestoreEvent(firestore, event, () => callback(event), errorCallback)
updateFirestoreEvent(
firestore,
event,
() => callback(event),
errorCallback
)
}
}

//If there are changes in the poster
//Else just update GCal and firestoreReducer
if(originalEvent.poster !== event.poster) {
if (originalEvent.poster !== event.poster) {
//Delete the original poster file if it exists
if(originalEvent.poster) {
if (originalEvent.poster) {
deleteFirebaseFile(firebase, originalEvent.poster, () => {})
}

//If there is a new poster file. Upload it and then update GCal and Firestore
//Else just update GCal and Firestore
if(event.poster) {
uploadPoster(firebase, event.poster, (filePath) => {
if (event.poster) {
uploadPoster(firebase, event.poster, filePath => {
event = {
...event,
poster: filePath,
poster: filePath
}

actionHandleGCal(firestore, firebase, event, originalEvent, callback)
Expand All @@ -129,11 +163,11 @@ export function updateEvent(firestore, firebase, event, originalEvent, callback
}

export function deleteEvent(firestore, firebase, event, callback) {
if(event.poster) {
if (event.poster) {
deleteFirebaseFile(firebase, event.poster, () => {})
}

if(event.gCalID) {
if (event.gCalID) {
deleteGoogleEvent(event, callback)
}

Expand All @@ -149,11 +183,16 @@ export function getEvent(firestore, eventID, callback = () => {}) {
getFirestoreEvent(firestore, eventID, callback)
}

export function getEvents(firestore, callback = () => {}, month = null, spaceOnly = false) {
export function getEvents(
firestore,
callback = () => {},
month = null,
spaceOnly = false
) {
getEventTypes(firestore)
getSpaces(firestore)

if(month) {
if (month) {
getEventsByMonth(firestore, callback, month, spaceOnly)
} else {
getFirestoreEvents(firestore, callback, spaceOnly)
Expand All @@ -162,11 +201,22 @@ export function getEvents(firestore, callback = () => {}, month = null, spaceOnl
watchFirestoreEvents(firestore)
}

export function getEventVenueBookingsAfter(firestore, venueID, date, alias = 'venueBookings', callback = () => {}) {
export function getEventVenueBookingsAfter(
firestore,
venueID,
date,
alias = 'venueBookings',
callback = () => {}
) {
getFirestoreEventVenueBookingsAfter(firestore, venueID, date, alias, callback)
}

export function getEventsByMonth(firestore, callback = () => {}, month, spaceOnly = false) {
export function getEventsByMonth(
firestore,
callback = () => {},
month,
spaceOnly = false
) {
getFirestoreEvents(firestore, callback, month, spaceOnly, true)
getFirestoreEvents(firestore, callback, month, spaceOnly, false)
watchFirestoreEvents(firestore)
Expand Down
11 changes: 4 additions & 7 deletions src/actions/FilesActions.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import {
getFile as getFirestoreFile,
uploadFile as uploadFirebaseFile,
uploadFiles as uploadFirebaseFiles,
deleteFile as deleteFirebaseFile,
uploadFiles as uploadFirebaseFiles
} from '../firestore/FilesClient'

const imageCache = {}

export function getFile(firebase, path, callback) {

if(!imageCache.path) {
getFirestoreFile(firebase, path, (url) => {
if (!imageCache.path) {
getFirestoreFile(firebase, path, url => {
imageCache[path] = url

callback(url)
})
} else {
callback(imageCache.path)
}

}

export function uploadFile(firebase, path, file, callback = () => {}) {
Expand Down
4 changes: 1 addition & 3 deletions src/actions/GeneralActions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
submitFeedback as submitFirestoreFeedback
} from '../firestore/GeneralClient'
import { submitFeedback as submitFirestoreFeedback } from '../firestore/GeneralClient'

export function submitFeedback(firestore, feedback, callback = () => {}) {
submitFirestoreFeedback(firestore, feedback, callback)
Expand Down
Loading