Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
Signed-off-by: Harry Chen <[email protected]>
  • Loading branch information
Harry-Chen committed Feb 19, 2020
1 parent dd7ac65 commit f435165
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ class App extends React.PureComponent<AppProps, typeof initialState> {
<Typography variant="body1" className={styles.app_error_text}>
错误信息:
<br />
<code>{this.state.lastError.stack ?? `${this.state.lastError.name}: ${this.state.lastError.message}`}</code>
<code>
{this.state.lastError.stack ??
`${this.state.lastError.name}: ${this.state.lastError.message}`}
</code>
</Typography>
<Typography variant="body1" className={styles.app_error_text}>
错误组件:
Expand Down
9 changes: 6 additions & 3 deletions src/redux/actions/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import { getStoredCredential, storeCredential } from '../../utils/storage';
// 2. explicit login in LoginDialog, then login dialog should still be shown
export function login(username: string, password: string, save: boolean) {
return async (dispatch, getState) => {

dispatch(toggleLoginDialogProgress(true));
const helperState = getState()[STATE_HELPER] as HelperState;
const helper = helperState.helper as Learn2018Helper;
Expand All @@ -56,7 +55,12 @@ export function login(username: string, password: string, save: boolean) {
await Promise.race([helper.login(username, password), timeout]);
} catch (e) {
const error = e as FailReason;
dispatch(showSnackbar(`登录失败:${failReasonToString(error) ?? error ?? '未知错误'}`, SnackbarType.ERROR));
dispatch(
showSnackbar(
`登录失败:${failReasonToString(error) ?? error ?? '未知错误'}`,
SnackbarType.ERROR,
),
);
dispatch(loginEnd());
return Promise.reject(`login failed: ${error}`);
}
Expand Down Expand Up @@ -109,7 +113,6 @@ export function refresh() {
const helper = helperState.helper as Learn2018Helper;

try {

// login on every refresh
const credential = await getStoredCredential();
await helper.login(credential.username, credential.password);
Expand Down
5 changes: 3 additions & 2 deletions src/redux/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { DataState } from './reducers/data';
import { ContentInfo } from '../types/data';
import { CardListProps } from '../types/ui';


let oldType: ContentType;
let oldCourse: CourseInfo;
let allContent: ContentInfo[];
Expand Down Expand Up @@ -57,7 +56,9 @@ export const generateCardList = (
newCards = newCards.filter(l => l.courseId === course.id);
} else {
// in summary list, respect all ignore marks
newCards = newCards.filter(l => data.contentIgnore[l.courseId]?.[l.type] === false && !l.ignored);
newCards = newCards.filter(
l => data.contentIgnore[l.courseId]?.[l.type] === false && !l.ignored,
);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export function formatDateTime(date?: Date): string {
return `${toDateString(date, true)} ${toTimeString(date)}`;
}


const FAIL_REASON_MAPPING = {
[FailReason.BAD_CREDENTIAL]: '用户名或密码错误',
[FailReason.ERROR_FETCH_FROM_ID]: '无法从 id.tsinghua.edu.cn 获取票据',
Expand Down

0 comments on commit f435165

Please sign in to comment.