Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public CareerResourcePageResponse getResourcePage(int page, int size, String que
String normalizedCategory = normalizeFilter(category);
String normalizedType = normalizeType(type);

var pageable = PageRequest.of(sanitizedPage, sanitizedSize, Sort.by(Sort.Direction.DESC, "createdAt"));
var pageable = PageRequest.of(sanitizedPage, sanitizedSize, Sort.by(Sort.Order.asc("category"), Sort.Order.asc("title")));
var resourcePage = resourceRepository.findAll(buildResourceFilter(normalizedQuery, normalizedCategory, normalizedType), pageable);

var content = resourcePage.getContent().stream()
Expand Down
16 changes: 10 additions & 6 deletions frontend/src/app/components/resources/resources.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,23 @@ export class ResourcesComponent implements OnDestroy {
onModeChange(mode: 'link' | 'file') { this.contributionMode = mode; }
formatFileSize(s?: number) { return s ? (s < 1048576 ? `${Math.ceil(s/1024)}KB` : `${(s/1048576).toFixed(1)}MB`) : ''; }

@HostListener('window:scroll')
@HostListener('window:scroll', [])
onWindowScroll() {
if (this.viewMode() === 'mine' || this.showAddResourceModal() || this.showDeleteConfirm()) return;
if (this.viewMode() !== 'community') return;
if (this.showAddResourceModal() || this.showDeleteConfirm()) return;
if (!this.hasNext() || this.isLoading() || this.isLoadingMore()) return;

const pos = (document.documentElement.scrollTop || document.body.scrollTop) + document.documentElement.offsetHeight;
const max = document.documentElement.scrollHeight;
if (max - pos < 300) {
const scrollTop = window.scrollY || document.documentElement.scrollTop;
const viewportHeight = window.innerHeight;
const fullHeight = document.documentElement.scrollHeight;

const distanceFromBottom = fullHeight - (scrollTop + viewportHeight);
if (distanceFromBottom <= 120) {
if (this.scrollLoadDebounceRef) return;
this.scrollLoadDebounceRef = setTimeout(() => {
this.scrollLoadDebounceRef = null;
this.loadResources();
}, 400);
}, 300);
}
}
}