Fix code smells

This commit is contained in:
Nicolas Meienberger 2022-07-08 19:19:28 +02:00
parent 85b74c1463
commit c8680f0bd2
3 changed files with 5 additions and 5 deletions

View file

@ -15,7 +15,7 @@ export const sortTable = (data: AppTableData, col: keyof Pick<AppInfo, 'name'>,
});
if (categories.length > 0) {
return sortedData.filter((app) => app.categories.some((c) => categories.includes(c as AppCategoriesEnum))).filter((app) => app.name.toLowerCase().includes(search.toLowerCase()));
return sortedData.filter((app) => app.categories.some((c) => categories.includes(c))).filter((app) => app.name.toLowerCase().includes(search.toLowerCase()));
} else {
return sortedData.filter((app) => app.name.toLowerCase().includes(search.toLowerCase()));
}

View file

@ -3,6 +3,8 @@ import { checkAppRequirements, checkEnvFile, generateEnvFile, getAvailableApps,
import { AppInfo, AppStatusEnum, ListAppsResonse } from './apps.types';
import App from './app.entity';
const sortApps = (a: AppInfo, b: AppInfo) => a.name.localeCompare(b.name);
const startAllApps = async (): Promise<void> => {
const apps = await App.find({ where: { status: AppStatusEnum.RUNNING } });
@ -86,7 +88,7 @@ const listApps = async (): Promise<ListAppsResonse> => {
app.description = readFile(`/apps/${app.id}/metadata/description.md`);
});
return { apps: apps.sort((a, b) => a.name.localeCompare(b.name)), total: apps.length };
return { apps: apps.sort(sortApps), total: apps.length };
};
const updateAppConfig = async (id: string, form: Record<string, string>): Promise<App> => {

View file

@ -9,9 +9,7 @@ import User from './user.entity';
export default class AuthResolver {
@Query(() => User, { nullable: true })
async me(@Ctx() ctx: MyContext): Promise<User | null> {
const user = await AuthService.me(ctx.req.session.userId);
return user;
return AuthService.me(ctx.req.session.userId);
}
@Mutation(() => UserResponse)