Skip to content

Commit 222d754

Browse files
sayomakilinedoestrolling
authored andcommitted
Fix formatting through yarn format
1 parent d9e299e commit 222d754

File tree

10 files changed

+68
-65
lines changed

10 files changed

+68
-65
lines changed

src/commons/application/actions/SessionActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ import {
5050
FETCH_USER_AND_COURSE,
5151
LOGIN,
5252
LOGIN_GITHUB,
53-
LOGOUT_GITHUB,
5453
LOGIN_GOOGLE,
54+
LOGOUT_GITHUB,
5555
LOGOUT_GOOGLE,
5656
NotificationConfiguration,
5757
NotificationPreference,

src/commons/application/reducers/SessionsReducer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import {
1818
SET_COURSE_REGISTRATION,
1919
SET_GITHUB_ACCESS_TOKEN,
2020
SET_GITHUB_OCTOKIT_OBJECT,
21-
SET_GOOGLE_USER,
2221
SET_GOOGLE_ACCESS_TOKEN,
22+
SET_GOOGLE_USER,
2323
SET_NOTIFICATION_CONFIGS,
2424
SET_TOKENS,
2525
SET_USER,
@@ -60,7 +60,7 @@ export const SessionsReducer: Reducer<SessionState, SourceActionType> = (
6060
return {
6161
...state,
6262
googleAccessToken: action.payload
63-
}
63+
};
6464
case SET_TOKENS:
6565
return {
6666
...state,

src/commons/application/types/SessionTypes.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ export const REAUTOGRADE_SUBMISSION = 'REAUTOGRADE_SUBMISSION';
5353
export const REAUTOGRADE_ANSWER = 'REAUTOGRADE_ANSWER';
5454
export const REMOVE_GITHUB_OCTOKIT_OBJECT_AND_ACCESS_TOKEN =
5555
'REMOVE_GITHUB_OCTOKIT_OBJECT_AND_ACCESS_TOKEN';
56-
export const REMOVE_GOOGLE_USER_AND_ACCESS_TOKEN =
57-
'REMOVE_GOOGLE_USER_AND_ACCESS_TOKEN';
56+
export const REMOVE_GOOGLE_USER_AND_ACCESS_TOKEN = 'REMOVE_GOOGLE_USER_AND_ACCESS_TOKEN';
5857
export const UNSUBMIT_SUBMISSION = 'UNSUBMIT_SUBMISSION';
5958
export const UPDATE_ASSESSMENT_OVERVIEWS = 'UPDATE_ASSESSMENT_OVERVIEWS';
6059
export const UPDATE_TOTAL_XP = 'UPDATE_TOTAL_XP';

src/commons/controlBar/ControlBarGoogleDriveButtons.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ export const ControlBarGoogleDriveButtons: React.FC<Props> = props => {
4242
/>
4343
);
4444
const openButton = (
45-
<ControlButton
46-
label="Open"
47-
icon={IconNames.DOCUMENT_OPEN}
48-
onClick={props.onClickOpen}
45+
<ControlButton
46+
label="Open"
47+
icon={IconNames.DOCUMENT_OPEN}
48+
onClick={props.onClickOpen}
4949
isDisabled={props.loggedInAs ? false : true}
5050
/>
5151
);
@@ -59,8 +59,8 @@ export const ControlBarGoogleDriveButtons: React.FC<Props> = props => {
5959
/>
6060
);
6161
const saveAsButton = (
62-
<ControlButton
63-
label="Save as"
62+
<ControlButton
63+
label="Save as"
6464
icon={IconNames.SEND_TO}
6565
onClick={props.onClickSaveAs}
6666
isDisabled={props.loggedInAs ? false : true}

src/commons/sagas/PersistenceSaga.tsx

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import { AsyncReturnType } from '../utils/TypeHelper';
2828
import { safeTakeEvery as takeEvery, safeTakeLatest as takeLatest } from './SafeEffects';
2929

3030
const DISCOVERY_DOCS = ['https://www.googleapis.com/discovery/v1/apis/drive/v3/rest'];
31-
const SCOPES = 'profile https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/userinfo.email';
31+
const SCOPES =
32+
'profile https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/userinfo.email';
3233
const UPLOAD_PATH = 'https://www.googleapis.com/upload/drive/v3/files';
3334

3435
// Special ID value for the Google Drive API.
@@ -58,7 +59,7 @@ export function* persistenceSaga(): SagaIterator {
5859
// check for stored token
5960
const accessToken = yield select((state: OverallState) => state.session.googleAccessToken);
6061
if (accessToken) {
61-
yield call(gapi.client.setToken, {access_token: accessToken});
62+
yield call(gapi.client.setToken, { access_token: accessToken });
6263
yield call(handleUserChanged, accessToken);
6364
}
6465
});
@@ -324,43 +325,45 @@ const initialisationPromise: Promise<void> = new Promise(res => {
324325
startInitialisation = res;
325326
}).then(initialise);
326327

327-
async function initialise() { // only called once
328+
// only called once
329+
async function initialise() {
328330
// load GIS script
329331
// adapted from https://github.com/MomenSherif/react-oauth
330-
await new Promise<void> ((resolve, reject) => {
332+
await new Promise<void>((resolve, reject) => {
331333
const scriptTag = document.createElement('script');
332334
scriptTag.src = 'https://accounts.google.com/gsi/client';
333335
scriptTag.async = true;
334336
scriptTag.defer = true;
335337
scriptTag.onload = () => resolve();
336-
scriptTag.onerror = (ev) => {
338+
scriptTag.onerror = ev => {
337339
reject(ev);
338340
};
339341
document.body.appendChild(scriptTag);
340342
});
341343

342344
// load and initialize gapi.client
343-
await new Promise<void> ((resolve, reject) =>
344-
gapi.load('client', {
345-
callback: resolve,
346-
onerror: reject
345+
await new Promise<void>((resolve, reject) =>
346+
gapi.load('client', {
347+
callback: resolve,
348+
onerror: reject
347349
})
348350
);
349351
await gapi.client.init({
350352
discoveryDocs: DISCOVERY_DOCS
351353
});
352354

353355
// initialize GIS client
354-
await new Promise<google.accounts.oauth2.TokenClient> ((resolve, reject) => {
355-
resolve(window.google.accounts.oauth2.initTokenClient({
356-
client_id: Constants.googleClientId!,
357-
scope: SCOPES,
358-
callback: () => void 0 // will be updated in getToken()
359-
}));
360-
}).then((c) => {
361-
tokenClient = c;
362-
});
363-
356+
await new Promise<google.accounts.oauth2.TokenClient>((resolve, reject) => {
357+
resolve(
358+
window.google.accounts.oauth2.initTokenClient({
359+
client_id: Constants.googleClientId!,
360+
scope: SCOPES,
361+
callback: () => void 0 // will be updated in getToken()
362+
})
363+
);
364+
}).then(c => {
365+
tokenClient = c;
366+
});
364367
}
365368

366369
function* handleUserChanged(accessToken: string | null) {
@@ -386,7 +389,7 @@ function* getToken() {
386389
if (resp.error !== undefined) {
387390
reject(resp);
388391
}
389-
// GIS has already automatically updated gapi.client
392+
// GIS has already automatically updated gapi.client
390393
// with the newly issued access token by this point
391394
resolve(resp);
392395
};
@@ -403,7 +406,8 @@ function* ensureInitialised() {
403406
yield initialisationPromise;
404407
}
405408

406-
function* ensureInitialisedAndAuthorised() { // called multiple times
409+
// called multiple times
410+
function* ensureInitialisedAndAuthorised() {
407411
yield call(ensureInitialised);
408412
const currToken: GoogleApiOAuth2TokenObject = yield call(gapi.client.getToken);
409413

@@ -597,4 +601,4 @@ function generateBoundary(): string {
597601

598602
// End adapted part
599603

600-
export default persistenceSaga;
604+
export default persistenceSaga;

src/commons/sagas/__tests__/PersistenceSaga.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Chapter, Variant } from 'js-slang/dist/types';
22
import { expectSaga } from 'redux-saga-test-plan';
33

44
import { PLAYGROUND_UPDATE_PERSISTENCE_FILE } from '../../../features/playground/PlaygroundTypes';
5-
import { REMOVE_GOOGLE_USER_AND_ACCESS_TOKEN } from '../../application/types/SessionTypes';
65
import { ExternalLibraryName } from '../../application/types/ExternalTypes';
6+
import { REMOVE_GOOGLE_USER_AND_ACCESS_TOKEN } from '../../application/types/SessionTypes';
77
import { actions } from '../../utils/ActionsHelper';
88
import {
99
CHANGE_EXTERNAL_LIBRARY,
@@ -47,25 +47,25 @@ beforeAll(() => {
4747

4848
test('LOGOUT_GOOGLE results in REMOVE_GOOGLE_USER_AND_ACCESS_TOKEN being dispatched', async () => {
4949
await expectSaga(PersistenceSaga)
50-
.put({
51-
type: PLAYGROUND_UPDATE_PERSISTENCE_FILE,
52-
payload: undefined,
53-
meta: undefined,
54-
error: undefined
55-
})
56-
.put({
57-
type: REMOVE_GOOGLE_USER_AND_ACCESS_TOKEN,
58-
payload: undefined,
59-
meta: undefined,
60-
error: undefined
61-
})
62-
.provide({
63-
call(effect, next) {
64-
return;
65-
}
66-
})
67-
.dispatch(actions.logoutGoogle())
68-
.silentRun();
50+
.put({
51+
type: PLAYGROUND_UPDATE_PERSISTENCE_FILE,
52+
payload: undefined,
53+
meta: undefined,
54+
error: undefined
55+
})
56+
.put({
57+
type: REMOVE_GOOGLE_USER_AND_ACCESS_TOKEN,
58+
payload: undefined,
59+
meta: undefined,
60+
error: undefined
61+
})
62+
.provide({
63+
call(effect, next) {
64+
return;
65+
}
66+
})
67+
.dispatch(actions.logoutGoogle())
68+
.silentRun();
6969
});
7070

7171
describe('PERSISTENCE_OPEN_PICKER', () => {

src/features/persistence/PersistenceUtils.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
* @returns string if email field exists in JSON response, undefined if not
77
*/
88
export async function getUserProfileDataEmail(accessToken: string): Promise<string | undefined> {
9-
const headers = new Headers();
10-
headers.append('Authorization', `Bearer ${accessToken}`);
11-
const response = await fetch('https://www.googleapis.com/oauth2/v3/userinfo', {
12-
headers
13-
});
14-
const data = await response.json();
15-
return data.email;
16-
}
9+
const headers = new Headers();
10+
headers.append('Authorization', `Bearer ${accessToken}`);
11+
const response = await fetch('https://www.googleapis.com/oauth2/v3/userinfo', {
12+
headers
13+
});
14+
const data = await response.json();
15+
return data.email;
16+
}

src/pages/__tests__/createStore.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe('createStore() function', () => {
109109

110110
expect(received).toEqual(mockChangedState);
111111
expect(octokit).toBeDefined();
112-
expect(googleUser).toEqual("placeholder");
112+
expect(googleUser).toEqual('placeholder');
113113
localStorage.removeItem('storedState');
114114
});
115115
});

src/pages/createStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function loadStore(loadedStore: SavedState | undefined) {
5454
? generateOctokitInstance(loadedStore.session.githubAccessToken)
5555
: undefined
5656
},
57-
googleUser: loadedStore.session.googleAccessToken
57+
googleUser: loadedStore.session.googleAccessToken
5858
? 'placeholder' // updates in PersistenceSaga
5959
: undefined
6060
},

src/pages/playground/Playground.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import {
1919
} from 'src/commons/application/actions/InterpreterActions';
2020
import {
2121
loginGitHub,
22-
logoutGitHub,
2322
loginGoogle,
23+
logoutGitHub,
2424
logoutGoogle
2525
} from 'src/commons/application/actions/SessionActions';
2626
import {
@@ -272,7 +272,7 @@ const Playground: React.FC<PlaygroundProps> = props => {
272272
googleUser: persistenceUser,
273273
githubOctokitObject
274274
} = useTypedSelector(state => state.session);
275-
275+
276276
const dispatch = useDispatch();
277277
const {
278278
handleChangeExecTime,

0 commit comments

Comments
 (0)