Skip to content

Commit a59114e

Browse files
committed
Overview: Last Month in review will show new badge if it is no older than 1 week since pubDate.
1 parent f3c6ede commit a59114e

5 files changed

Lines changed: 82 additions & 68 deletions

File tree

community-app/frontend/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
</div>
5858
<div id="community">
5959
<div id="Community-app" class="container">
60-
<div class="spinner-border" role="status">
60+
<div class="spinner-border m-4" role="status">
6161
<span class="sr-only">Loading...</span>
6262
</div>
6363
</div>

community-app/frontend/src/components/overview/LastMonth.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ import SectionTitle from './SectionTitle.vue'
99
1010
const loading = ref(false);
1111
const router = useRouter();
12+
const isNew = ref(false);
1213
1314
const store = useLastMonthStore();
1415
16+
const oneWeek = 7 * 24 * 60 * 60 * 1000;
17+
1518
onMounted(async ()=>{
1619
1720
try
@@ -26,6 +29,11 @@ onMounted(async ()=>{
2629
finally{
2730
loading.value = false;
2831
}
32+
33+
console.log (Date.now());
34+
console.log (store.date + oneWeek);
35+
36+
isNew.value = store.date ? Date.now() < store.date + oneWeek : false;
2937
3038
})
3139
@@ -35,11 +43,13 @@ onMounted(async ()=>{
3543
<div v-if="store.link" class="section pr-4 lastMonth">
3644
<div class="row border-bottom pb-3 align-items-start">
3745
<div class="col-1 px-0 py-1">
38-
<img :src="store.thumb" class="img-fluid"/>
46+
<NBadge value="new" type="success" :show="isNew">
47+
<img :src="store.thumb" class="img-fluid"/>
48+
</NBadge>
3949
</div>
4050
<div class="col-11 py-0 pl-4 no-gutter">
4151
<strong><a :href="store.link">{{ store.title }}</a></strong>
42-
<div class="text-muted second">Last month in review</div>
52+
<div class="text-muted second">{{ store.description }}</div>
4353
</div>
4454
</div>
4555
</div>

community-app/frontend/src/components/overview/LastMonthStore.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export const useLastMonthStore = defineStore ('lastMonth',{
99
title: "",
1010
link:"",
1111
thumb:"",
12+
date: null,
13+
description:"",
1214
fetched: false
1315
}
1416
},
@@ -23,6 +25,8 @@ export const useLastMonthStore = defineStore ('lastMonth',{
2325
this.link = rss.link;
2426
this.thumb = rss.thumb;
2527
this.fetched = true;
28+
this.description = rss.description;
29+
this.date = new Date(rss.pubDate).getTime()
2630
}
2731
catch (error){
2832
this.fetched = false;
@@ -33,9 +37,6 @@ export const useLastMonthStore = defineStore ('lastMonth',{
3337
})
3438

3539
async function fetchRSS(){
36-
37-
// const imageParamsAvatars = "?withoutEnlargement=true&quality=90&fit=cover&height=60&width=60";
38-
// const limit = 10;
3940

4041
const url = Constants.OVERVIEW_RSS;
4142

@@ -59,8 +60,9 @@ async function fetchRSS(){
5960
title: getItem(item, 'title'),
6061
link: getItem(item, 'link'),
6162
category: getItem(item, 'category'),
63+
thumb: getItem(item, 'thumb'),
6264
description: getItem(item, 'description'),
63-
thumb: getItem(item, 'thumb')
65+
pubDate: getItem(item, 'pubDate')
6466
}
6567
)
6668
));
@@ -75,7 +77,9 @@ async function fetchRSS(){
7577
return {
7678
title: lastMonth.title,
7779
link: lastMonth.link,
78-
thumb: latestMonthThumb
80+
thumb: latestMonthThumb,
81+
description: lastMonth.description,
82+
pubDate: lastMonth.pubDate
7983
}
8084
}
8185
else {

layouts/community/community.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{{ partial "nav" . }}
1010

1111
<div id="Community-app" class="container {{ .Params.theme }}">
12-
<div class="spinner-border" role="status">
12+
<div class="spinner-border m-4" role="status">
1313
<span class="sr-only">Loading...</span>
1414
</div>
1515
</div>

static/js/vue/app.js

Lines changed: 59 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)