Skip to content

Commit

Permalink
Nothing but reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
anther committed Oct 11, 2018
1 parent 38a00a1 commit 59bb190
Show file tree
Hide file tree
Showing 60 changed files with 2,000 additions and 2,152 deletions.
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
],
"singleQuote": true,
"useTabs": true,
"arrowParens": "always"
"arrowParens": "always",
"printWidth": 110
}
12 changes: 6 additions & 6 deletions app/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import LoginPage from './containers/LoginPage';
import BuildsPage from './containers/BuildsPage';

export default () => (
<App>
<Switch>
<Route path={routes.BUILDS} component={BuildsPage} />
<Route path={routes.HOME} component={LoginPage} />
</Switch>
</App>
<App>
<Switch>
<Route path={routes.BUILDS} component={BuildsPage}/>
<Route path={routes.HOME} component={LoginPage}/>
</Switch>
</App>
);
122 changes: 61 additions & 61 deletions app/actions/autoUpdates.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,68 +12,68 @@ export const UPDATE_DOWNLOAD_SUCCESS = 'UPDATE_DOWNLOAD_SUCCESS';
export const UPDATE_DOWNLOAD_FAIL = 'UPDATE_DOWNLOAD_FAIL';

export const startAutoUpdate = () => (dispatch, getState) => {
const state = getState();
if (!state.autoUpdates.updateAvailable) {
console.log('Cannot initiate download because no update was confirmed');
return dispatch({
type: UPDATE_DOWNLOAD_FAIL,
payload: 'No Update Available'
});
}
console.log('Triggering auto update start');
ipcRenderer.send('autoUpdate-start');
dispatch({
type: UPDATE_DOWNLOAD_BEGIN
});
const state = getState();
if (!state.autoUpdates.updateAvailable) {
console.log('Cannot initiate download because no update was confirmed');
return dispatch({
type: UPDATE_DOWNLOAD_FAIL,
payload: 'No Update Available'
});
}
console.log('Triggering auto update start');
ipcRenderer.send('autoUpdate-start');
dispatch({
type: UPDATE_DOWNLOAD_BEGIN
});
};
export const initializeAutoUpdater = () => dispatch => {
const listeners = {
'autoUpdate-initialized': () => {
console.log('received initialized signal back');
},
'autoUpdate-error': (event, error) => {
console.log('autoupdate error');
console.error(error);
let cause = '';
if (error === null) {
cause = 'unknown';
} else if (error.cause) {
cause = error.cause;
} else {
cause = 'Something went wrong';
}
dispatch({
type: CHECK_FOR_UPDATES_FAIL,
payload: cause
});
},
'autoUpdate-update-available': () => {
console.log('An update is available');
dispatch({
type: CHECK_FOR_UPDATES_FOUND_UPDATE
});
dispatch(startAutoUpdate());
},
'autoUpdate-update-not-available': () => {
console.log('An update is not available');
dispatch({
type: CHECK_FOR_UPDATES_NO_UPDATES
});
},
'autoUpdate-update-downloaded': () => {
console.log('An update downloaded');
dispatch({
type: UPDATE_DOWNLOAD_SUCCESS
});
}
};
_.forEach(listeners, (listenerFunction, listenerName) => {
ipcRenderer.removeAllListeners(listenerName);
ipcRenderer.on(listenerName, listenerFunction);
});
ipcRenderer.send('autoUpdate-initialize');
const listeners = {
'autoUpdate-initialized': () => {
console.log('received initialized signal back');
},
'autoUpdate-error': (event, error) => {
console.log('autoupdate error');
console.error(error);
let cause = '';
if (error === null) {
cause = 'unknown';
} else if (error.cause) {
cause = error.cause;
} else {
cause = 'Something went wrong';
}
dispatch({
type: CHECK_FOR_UPDATES_FAIL,
payload: cause
});
},
'autoUpdate-update-available': () => {
console.log('An update is available');
dispatch({
type: CHECK_FOR_UPDATES_FOUND_UPDATE
});
dispatch(startAutoUpdate());
},
'autoUpdate-update-not-available': () => {
console.log('An update is not available');
dispatch({
type: CHECK_FOR_UPDATES_NO_UPDATES
});
},
'autoUpdate-update-downloaded': () => {
console.log('An update downloaded');
dispatch({
type: UPDATE_DOWNLOAD_SUCCESS
});
}
};
_.forEach(listeners, (listenerFunction, listenerName) => {
ipcRenderer.removeAllListeners(listenerName);
ipcRenderer.on(listenerName, listenerFunction);
});
ipcRenderer.send('autoUpdate-initialize');

dispatch({
type: CHECK_FOR_UPDATES_BEGIN
});
dispatch({
type: CHECK_FOR_UPDATES_BEGIN
});
};
12 changes: 6 additions & 6 deletions app/actions/builds.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,24 +192,24 @@ const copyBuildSettings = (build: Build) => (dispatch, getState) => {
dispatch(startReplayBrowser());
})
.catch(error => {
dispatch(buildFailError(COPY_BUILD_SETTINGS_FAIL, build, error))
dispatch(buildFailError(COPY_BUILD_SETTINGS_FAIL, build, error));
});
}
};

export const setDefaultPreferableNewUserBuildOptions = (build) => (dispatch) => {
dispatch({
type: UPDATE_BUILD_TO_FULLSCREEN_BEGIN,
type: UPDATE_BUILD_TO_FULLSCREEN_BEGIN
});
DolphinConfigurationUpdater.setToFullScreen(build)
.then(()=>{
.then(() => {
dispatch({
type: UPDATE_BUILD_TO_FULLSCREEN_SUCCESS,
type: UPDATE_BUILD_TO_FULLSCREEN_SUCCESS
});
})
.catch((error)=>{
.catch((error) => {
dispatch({
type: UPDATE_BUILD_TO_FULLSCREEN_FAIL,
type: UPDATE_BUILD_TO_FULLSCREEN_FAIL
});
console.log(error);
});
Expand Down
169 changes: 83 additions & 86 deletions app/actions/dolphinStatus.js
Original file line number Diff line number Diff line change
@@ -1,103 +1,100 @@
import _ from 'lodash';
import getAuthenticationFromState from "../utils/getAuthenticationFromState";
import {endpoints} from "../utils/SmashLadderAuthentication";
import getAuthenticationFromState from '../utils/getAuthenticationFromState';
import { endpoints } from '../utils/SmashLadderAuthentication';

export const DOLPHIN_STATUS_SEND_BEGIN = 'DOLPHIN_STATUS_SEND_BEGIN';
export const DOLPHIN_STATUS_SEND_SUCCESS = 'DOLPHIN_STATUS_SEND_SUCCESS';
export const DOLPHIN_STATUS_SEND_FAIL = 'DOLPHIN_STATUS_SEND_FAIL';




export const parseDolphinPlayerList = (value = '') => (dispatch, getState) => {
const valueSplit = value.split(/\r?\n/);
const valueSplit = value.split(/\r?\n/);

const { dolphinPlayers } = getState().dolphinStatus;
const { dolphinPlayers } = getState().dolphinStatus;

const parsedUsernames = {};
valueSplit.forEach((current, index)=>{
if (!current.includes('[')) {
return;
}
const nextLine = parseInt(index, 10) + 1;
const pingLine = valueSplit[nextLine];
let ping = null;
if (pingLine) {
const pingTitle = pingLine.substring(0, pingLine.lastIndexOf(':'));
const pingSide = pingLine.substring(pingLine.lastIndexOf(':') + 1);
ping = Number.parseInt(pingSide, 10);
}
const parsedUsernames = {};
valueSplit.forEach((current, index) => {
if (!current.includes('[')) {
return;
}
const nextLine = parseInt(index, 10) + 1;
const pingLine = valueSplit[nextLine];
let ping = null;
if (pingLine) {
const pingTitle = pingLine.substring(0, pingLine.lastIndexOf(':'));
const pingSide = pingLine.substring(pingLine.lastIndexOf(':') + 1);
ping = Number.parseInt(pingSide, 10);
}

const usernameData = parseUsernameInfo(current);
usernameData.ports.forEach((port)=>{
parsedUsernames[port] = {
username: usernameData.username,
slot: port
};
});
});
if(_.isEqual(parsedUsernames, dolphinPlayers))
{
return;
}
const sendData = {
players: parsedUsernames
};
const authentication = getAuthenticationFromState(getState);
dispatch({
type: DOLPHIN_STATUS_SEND_BEGIN,
payload: parsedUsernames
});
authentication.apiPost(endpoints.DOLPHIN_PLAYER_JOINED, sendData)
.then((response)=>{
console.log(response);
dispatch({
type: DOLPHIN_STATUS_SEND_SUCCESS
});
})
.catch((error)=>{
console.error(error);
dispatch({
type: DOLPHIN_STATUS_SEND_FAIL,
payload: error
})
});
const usernameData = parseUsernameInfo(current);
usernameData.ports.forEach((port) => {
parsedUsernames[port] = {
username: usernameData.username,
slot: port
};
});
});
if (_.isEqual(parsedUsernames, dolphinPlayers)) {
return;
}
const sendData = {
players: parsedUsernames
};
const authentication = getAuthenticationFromState(getState);
dispatch({
type: DOLPHIN_STATUS_SEND_BEGIN,
payload: parsedUsernames
});
authentication.apiPost(endpoints.DOLPHIN_PLAYER_JOINED, sendData)
.then((response) => {
console.log(response);
dispatch({
type: DOLPHIN_STATUS_SEND_SUCCESS
});
})
.catch((error) => {
console.error(error);
dispatch({
type: DOLPHIN_STATUS_SEND_FAIL,
payload: error
});
});
};

const parseUsernameInfo = (current) => {
const usernameSide = current.substring(0, current.lastIndexOf(':'));
const systemInfoSide = current.substring(current.lastIndexOf(':') + 1);
const usernameSide = current.substring(0, current.lastIndexOf(':'));
const systemInfoSide = current.substring(current.lastIndexOf(':') + 1);

const ports = systemInfoSide
.substring(
systemInfoSide.indexOf('|') + 1,
systemInfoSide.lastIndexOf('|') - 1
)
.trim();
const systemInformation = systemInfoSide
.substring(0, systemInfoSide.indexOf('|'))
.trim();
const ports = systemInfoSide
.substring(
systemInfoSide.indexOf('|') + 1,
systemInfoSide.lastIndexOf('|') - 1
)
.trim();
const systemInformation = systemInfoSide
.substring(0, systemInfoSide.indexOf('|'))
.trim();

const portIndexes = [];
for (
let characterIndex = 0;
characterIndex < ports.length;
characterIndex++
) {
if (ports.charAt(characterIndex) === '-') {
continue;
}
portIndexes.push(characterIndex + 1);
}
let slot = null;
if (portIndexes.length) {
slot = portIndexes[0];
}
const username = usernameSide
.substring(0, usernameSide.lastIndexOf('['))
.trim();
return {
username,
ports: portIndexes
};
const portIndexes = [];
for (
let characterIndex = 0;
characterIndex < ports.length;
characterIndex++
) {
if (ports.charAt(characterIndex) === '-') {
continue;
}
portIndexes.push(characterIndex + 1);
}
let slot = null;
if (portIndexes.length) {
slot = portIndexes[0];
}
const username = usernameSide
.substring(0, usernameSide.lastIndexOf('['))
.trim();
return {
username,
ports: portIndexes
};
};
Loading

0 comments on commit 59bb190

Please sign in to comment.