diff --git a/backend/src/main/java/com/thughari/jobtrackerpro/service/CareerResourceService.java b/backend/src/main/java/com/thughari/jobtrackerpro/service/CareerResourceService.java index eace175..90c42a6 100644 --- a/backend/src/main/java/com/thughari/jobtrackerpro/service/CareerResourceService.java +++ b/backend/src/main/java/com/thughari/jobtrackerpro/service/CareerResourceService.java @@ -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() diff --git a/frontend/src/app/components/resources/resources.component.ts b/frontend/src/app/components/resources/resources.component.ts index b36b2a3..36a2d88 100644 --- a/frontend/src/app/components/resources/resources.component.ts +++ b/frontend/src/app/components/resources/resources.component.ts @@ -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); } } } \ No newline at end of file