fix: handle rejection for security token not found when opening projects (#441)

* fix: handle rejection for security token not found when opening projects

* fix: use longer auto close time for security token not found message

Co-authored-by: alex-krasn <64093224+alex-krasn@users.noreply.github.com>
Co-authored-by: kunzheng <58841788+kunzms@users.noreply.github.com>
This commit is contained in:
stew-ro 2020-07-24 17:26:49 -07:00 коммит произвёл GitHub
Родитель 1cb4133dca
Коммит 79264e3fdd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 11 добавлений и 4 удалений

Просмотреть файл

@ -156,9 +156,15 @@ export default class HomePage extends React.Component<IHomePageProps, IHomePageS
}
private loadSelectedProject = async (project: IProject, sharedToken?: {}) => {
const loadedProject = await this.props.actions.loadProject(project, sharedToken);
if (loadedProject !== null) {
this.props.history.push(`/projects/${project.id}/edit`);
try {
const loadedProject = await this.props.actions.loadProject(project, sharedToken);
if (loadedProject !== null) {
this.props.history.push(`/projects/${project.id}/edit`);
}
} catch (error) {
if (error instanceof AppError && error.errorCode === ErrorCode.SecurityTokenNotFound) {
toast.error(strings.errors.securityTokenNotFound.message, { autoClose: 5000 });
}
}
}
@ -168,7 +174,8 @@ export default class HomePage extends React.Component<IHomePageProps, IHomePageS
.find((securityToken) => securityToken.name === project.securityToken);
if (!projectToken) {
throw new AppError(ErrorCode.SecurityTokenNotFound, "Security Token Not Found");
toast.error(strings.errors.securityTokenNotFound.message, { autoClose: 3000 });
return;
}
// Load project from storage provider to keep the project in latest state