projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixing attempt: clients now track tmpIds to know who is online/onfocus. Bug fixed...
[vchess.git]
/
client
/
src
/
views
/
News.vue
diff --git
a/client/src/views/News.vue
b/client/src/views/News.vue
index
1aebbd3
..
a4ce579
100644
(file)
--- a/
client/src/views/News.vue
+++ b/
client/src/views/News.vue
@@
-26,10
+26,10
@@
main
:class="{margintop:idx>0}"
)
span.ndt {{ formatDatetime(n.added) }}
:class="{margintop:idx>0}"
)
span.ndt {{ formatDatetime(n.added) }}
-
div
(v-if="devs.includes(st.user.id)")
+
.dev-buttons
(v-if="devs.includes(st.user.id)")
button(@click="editNews(n)") {{ st.tr["Edit"] }}
button(@click="deleteNews(n)") {{ st.tr["Delete"] }}
button(@click="editNews(n)") {{ st.tr["Edit"] }}
button(@click="deleteNews(n)") {{ st.tr["Delete"] }}
-
p
(v-html="parseHtml(n.content)")
+
.news-content
(v-html="parseHtml(n.content)")
button#loadMoreBtn(
v-if="hasMore"
@click="loadMore()"
button#loadMoreBtn(
v-if="hasMore"
@click="loadMore()"
@@
-48,8
+48,10
@@
export default {
return {
devs: [1], //for now the only dev is me
st: store.state,
return {
devs: [1], //for now the only dev is me
st: store.state,
- cursor: 0, //ID of last showed news
- hasMore: true, //a priori there could be more news to load
+ // timestamp of oldest showed news:
+ cursor: Number.MAX_SAFE_INTEGER,
+ // hasMore == TRUE: a priori there could be more news to load
+ hasMore: true,
curnews: { id: 0, content: "" },
newsList: [],
infoMsg: ""
curnews: { id: 0, content: "" },
newsList: [],
infoMsg: ""
@@
-62,14
+64,20
@@
export default {
{
data: { cursor: this.cursor },
success: (res) => {
{
data: { cursor: this.cursor },
success: (res) => {
- this.newsList = res.newsList.sort((n1, n2) => n2.added - n1.added);
+ // The returned list is sorted from most recent to oldest
+ this.newsList = res.newsList;
const L = res.newsList.length;
const L = res.newsList.length;
- if (L > 0) this.cursor = this.newsList[0].id;
+ if (L > 0) this.cursor = res.newsList[L - 1].added;
+ else this.hasMore = false;
}
}
);
},
mounted: function() {
}
}
);
},
mounted: function() {
+ // Mark that I've read the news:
+ localStorage.setItem("newsRead", Date.now());
+ if (this.st.user.id > 0) ajax("/newsread", "PUT");
+ document.getElementById("newsMenu").classList.remove("somenews");
document
.getElementById("newnewsDiv")
.addEventListener("click", processModalClick);
document
.getElementById("newnewsDiv")
.addEventListener("click", processModalClick);
@@
-162,10
+170,10
@@
export default {
{
data: { cursor: this.cursor },
success: (res) => {
{
data: { cursor: this.cursor },
success: (res) => {
- if (res.newsList.length > 0) {
+ const L = res.newsList.length;
+ if (L > 0) {
this.newsList = this.newsList.concat(res.newsList);
this.newsList = this.newsList.concat(res.newsList);
- const L = res.newsList.length;
- if (L > 0) this.cursor = res.newsList[L - 1].id;
+ this.cursor = res.newsList[L - 1].added;
} else this.hasMore = false;
}
}
} else this.hasMore = false;
}
}
@@
-175,7
+183,7
@@
export default {
};
</script>
};
</script>
-<style lang="sass"
scoped
>
+<style lang="sass">
[type="checkbox"].modal+div .card
max-width: 767px
max-height: 100%
[type="checkbox"].modal+div .card
max-width: 767px
max-height: 100%
@@
-203,8
+211,16
@@
span.ndt
.news
padding-top: 10px
.news
padding-top: 10px
- & >
div
+ & >
.dev-buttons
display: inline-block
display: inline-block
+ & > .news-content
+ margin: var(--universal-margin)
+ & > p
+ margin: 10px 0
+ & > br
+ display: block
+ margin-top: 10px
+ content: " "
.margintop
margin-top: 25px
.margintop
margin-top: 25px