Actually fix version list order

This commit is contained in:
Nassim Jahnke 2022-07-17 14:13:10 +02:00
parent e467c51153
commit d2058d5e17
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 4 additions and 5 deletions

View File

@ -53,9 +53,6 @@ const requestOptions = computed(() => {
const channels = await useProjectChannels(route.params.user as string, route.params.project as string).catch((e) => handleRequestError(e, ctx, i18n));
const versions = await useProjectVersions(route.params.user as string, route.params.project as string).catch((e) => handleRequestError(e, ctx, i18n));
if (versions && versions.value) {
versions.value.result.reverse();
}
if (channels) {
filter.channels.push(...(channels.value?.map((c) => c.name) || []));
@ -84,7 +81,6 @@ watch(
).catch((e) => handleRequestError(e, ctx, i18n));
if (newVersions) {
versions.value = newVersions;
versions.value.result.reverse();
}
},
{ deep: true }

View File

@ -55,7 +55,10 @@ public class VersionsApiService extends HangarComponent {
public PaginatedResult<Version> getVersions(String author, String slug, RequestPagination pagination) {
boolean canSeeHidden = getGlobalPermissions().has(Permission.SeeHidden);
List<Version> versions = versionsApiDAO.getVersions(author, slug, canSeeHidden, getHangarUserId(), pagination).entrySet().stream().map(entry -> versionDependencyService.addDependencies(entry.getKey(), entry.getValue())).collect(Collectors.toList());
List<Version> versions = versionsApiDAO.getVersions(author, slug, canSeeHidden, getHangarUserId(), pagination).entrySet().stream()
.map(entry -> versionDependencyService.addDependencies(entry.getKey(), entry.getValue()))
.sorted((v1, v2) -> v2.getCreatedAt().compareTo(v1.getCreatedAt()))
.collect(Collectors.toList());
Long versionCount = versionsApiDAO.getVersionCount(author, slug, canSeeHidden, getHangarUserId(), pagination);
return new PaginatedResult<>(new Pagination(versionCount == null ? 0 : versionCount, pagination), versions);
}