-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommunity-queue.component.ts
More file actions
70 lines (60 loc) · 2.23 KB
/
Copy pathcommunity-queue.component.ts
File metadata and controls
70 lines (60 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { DatePipe } from '@angular/common';
import { Component, Input, OnInit, ChangeDetectionStrategy } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { PopupCoordinatorService } from '../popup-coordinator.service';
import { PopupComponent } from '../popup/popup.component';
import { escapeHtml } from '../utility/escapeHtml';
import { VisibilityService } from '../visibility/visibility.service';
import { communityUserIds } from '../../../../shared/users';
@Component({
selector: 'app-community-queue',
templateUrl: './community-queue.component.html',
styleUrls: ['./community-queue.component.css'],
changeDetection: ChangeDetectionStrategy.Eager,
standalone: false
})
export class CommunityQueueComponent extends PopupComponent implements OnInit {
@Input() queue: any;
constructor(private sanitizer: DomSanitizer, popupCoordinator: PopupCoordinatorService, visibilityService: VisibilityService) {
super(popupCoordinator, visibilityService)
}
ngOnInit(): void {
this.popupId = 'community-contributions';
if(!this.gravityX) this.gravityX = 'right';
if(!this.gravityY) this.gravityY = 'top';
super.ngOnInit();
}
getQueueTopics() {
const pipe = new DatePipe('en');
const text =
'<ul>' +
this.queue?.reduce(
(text, topic) => {
let output = '';
let created = pipe.transform(topic.created_at, 'medium');
let last = pipe.transform(topic.last_posted_at, 'medium');
output +=
`<li>${created}: <b>${escapeHtml(topic.title)}</b> `+
`(<a href="https://community.software.sil.org/t/${topic.slug}/${topic.id}/${topic.highest_post_number}">#${topic.id}</a>), `+
`<i>last updated ${last}</i></li>\n`;
return text + output;
}, '') +
'</ul>';
return { content: text, type: 'text/html' };
}
isNewTopic(topic) {
return topic.posts_count == 1;
}
hasNewPost(topic) {
return !communityUserIds.includes(topic.last_post?.username);
}
hasNewTopics() {
return !!this.queue?.find(this.isNewTopic);
}
hasNewPosts() {
return !!this.queue?.find(this.hasNewPost);
}
countOfNewPosts() {
return this.queue?.filter(this.hasNewPost).length;
}
}