Skip to content

Commit 2c8922f

Browse files
committed
fix set viewed news in program
1 parent f59c972 commit 2c8922f

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

projects/social_platform/src/app/office/program/detail/main/main.component.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ export class ProgramDetailMainComponent implements OnInit, OnDestroy {
149149
if (news.results?.length) {
150150
this.news.set(news.results);
151151
this.totalNewsCount.set(news.count);
152+
153+
setTimeout(() => {
154+
this.setupNewsObserver();
155+
}, 100);
152156
}
153157

154158
this.loadingService.hide();
@@ -205,6 +209,10 @@ export class ProgramDetailMainComponent implements OnInit, OnDestroy {
205209
} else {
206210
this.fetchPage.update(p => p + 1);
207211
}
212+
213+
setTimeout(() => {
214+
this.setupNewsObserver();
215+
}, 100);
208216
})
209217
);
210218
}
@@ -310,6 +318,18 @@ export class ProgramDetailMainComponent implements OnInit, OnDestroy {
310318
this.descriptionExpandable = descElement.scrollHeight > descElement.clientHeight;
311319
}
312320

321+
private setupNewsObserver(): void {
322+
const observer = new IntersectionObserver(this.onNewsInVew.bind(this), {
323+
root: document.querySelector(".office__body"),
324+
rootMargin: "0px 0px 0px 0px",
325+
threshold: 0,
326+
});
327+
328+
document.querySelectorAll(".news__item").forEach(element => {
329+
observer.observe(element);
330+
});
331+
}
332+
313333
program?: Program;
314334
registerDateExpired!: boolean;
315335
descriptionExpandable!: boolean;

projects/social_platform/src/app/office/program/shared/program-card/program-card.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
'card__registration--ended': registerDateExpired,
1818
}"
1919
>
20+
<!-- ? "Регистрация до:" + " " + (program.datetimeRegistrationEnds | date: "dd MMMM") -->
2021
{{
2122
!registerDateExpired && (!program.isUserMember || !program.isUserManager)
22-
? "Регистрация до:" + " " + (program.datetimeRegistrationEnds | date: "dd MMMM")
23+
? "Подача проектов до:" + " " + (program.datetimeRegistrationEnds | date: "dd MMMM")
2324
: registerDateExpired
2425
? "регистрация завершена"
2526
: "ты уже участвуешь!"

0 commit comments

Comments
 (0)