mirror of
https://github.com/danbulant/Nertivia-Client
synced 2026-07-04 10:30:37 +00:00
Scroll up to load more. (needs more work.)
This commit is contained in:
parent
305ec450ab
commit
6f65d1291d
5 changed files with 54 additions and 10 deletions
|
|
@ -125,6 +125,7 @@ export default {
|
||||||
typingRecipients: {},
|
typingRecipients: {},
|
||||||
showEmojiPanel: false,
|
showEmojiPanel: false,
|
||||||
scrolledDown: true,
|
scrolledDown: true,
|
||||||
|
scrolledTop: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -458,6 +459,7 @@ export default {
|
||||||
scrollEvent(event) {
|
scrollEvent(event) {
|
||||||
const { currentTarget: { scrollTop, clientHeight, scrollHeight} } = event;
|
const { currentTarget: { scrollTop, clientHeight, scrollHeight} } = event;
|
||||||
this.scrolledDown = Math.abs(scrollHeight - scrollTop - clientHeight) <= 3.0;
|
this.scrolledDown = Math.abs(scrollHeight - scrollTop - clientHeight) <= 3.0;
|
||||||
|
this.scrolledTop = scrollTop === 0;
|
||||||
},
|
},
|
||||||
scrollDown() {
|
scrollDown() {
|
||||||
if (!this.scrolledDown) return;
|
if (!this.scrolledDown) return;
|
||||||
|
|
@ -467,6 +469,25 @@ export default {
|
||||||
},
|
},
|
||||||
onResize(dimentions) {
|
onResize(dimentions) {
|
||||||
this.scrollDown();
|
this.scrollDown();
|
||||||
|
},
|
||||||
|
async loadMoreMessages() {
|
||||||
|
const msgLogs = this.$refs['msg-logs'];
|
||||||
|
const scrollTop = msgLogs.scrollTop;
|
||||||
|
const scrollHeight = msgLogs.scrollHeight;
|
||||||
|
|
||||||
|
const continueMessageID = this.selectedChannelMessages[0].messageID;
|
||||||
|
|
||||||
|
const {ok, result, error} = await messagesService.get(this.selectedChannelID, continueMessageID)
|
||||||
|
if (ok) {
|
||||||
|
if (!result.data.messages.length) return
|
||||||
|
this.$store.dispatch('addMessages', result.data.messages)
|
||||||
|
this.$nextTick(_ => {
|
||||||
|
msgLogs.scrollTop = msgLogs.scrollHeight - scrollHeight;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scrolledUpEvent() {
|
||||||
|
this.loadMoreMessages();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
@ -548,6 +569,10 @@ export default {
|
||||||
},
|
},
|
||||||
getWindowWidth(dimentions) {
|
getWindowWidth(dimentions) {
|
||||||
this.onResize();
|
this.onResize();
|
||||||
|
},
|
||||||
|
scrolledTop(scrolledTop) {
|
||||||
|
if (scrolledTop)
|
||||||
|
this.scrolledUpEvent();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,9 @@ export default {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
|
.information {
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
}
|
||||||
.heading.latest {
|
.heading.latest {
|
||||||
background: rgba(38, 139, 255, 0.87);
|
background: rgba(38, 139, 255, 0.87);
|
||||||
}
|
}
|
||||||
|
|
@ -140,12 +143,4 @@ export default {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 840px) {
|
|
||||||
.news {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
.todo-list {
|
|
||||||
margin-left: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ import {instance, wrapper} from './Api';
|
||||||
import filesize from "filesize";
|
import filesize from "filesize";
|
||||||
export default {
|
export default {
|
||||||
// TODO: add ?continue=id
|
// TODO: add ?continue=id
|
||||||
get ( channelID ) {
|
get ( channelID, continueMessageID ) {
|
||||||
return wrapper(instance().get(`messages/channels/${channelID}`));
|
return wrapper(instance().get(`messages/channels/${channelID}${continueMessageID ? '?continue=' + continueMessageID : ''}`));
|
||||||
},
|
},
|
||||||
delete ( messageID, channelID ) {
|
delete ( messageID, channelID ) {
|
||||||
return wrapper(instance().delete(`messages/${messageID}/channels/${channelID}`));
|
return wrapper(instance().delete(`messages/${messageID}/channels/${channelID}`));
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,14 @@ const actions = {
|
||||||
// send notification if message is not ours
|
// send notification if message is not ours
|
||||||
context.commit("addMessage", data);
|
context.commit("addMessage", data);
|
||||||
},
|
},
|
||||||
|
addMessages(context, messagesArr){
|
||||||
|
const channelID = messagesArr[0].channelID;
|
||||||
|
const messages = context.state.messages[channelID];
|
||||||
|
|
||||||
|
const join = [ ...messagesArr.reverse(), ...messages, ];
|
||||||
|
|
||||||
|
context.commit('messages', {messages: join, channelID});
|
||||||
|
},
|
||||||
replaceMessage(context, data) {
|
replaceMessage(context, data) {
|
||||||
context.commit("replaceMessage", data);
|
context.commit("replaceMessage", data);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,22 @@
|
||||||
|
|
||||||
const config = [
|
const config = [
|
||||||
|
|
||||||
|
{
|
||||||
|
version: 6.1,
|
||||||
|
title: "Download button, bug fixes",
|
||||||
|
shortTitle: "",
|
||||||
|
date: "13/08/2019",
|
||||||
|
headColor: "rgba(205, 80, 87, 0.77)",
|
||||||
|
new: [
|
||||||
|
"Added download button.",
|
||||||
|
|
||||||
|
],
|
||||||
|
fix: [
|
||||||
|
"Fixed emoji size (2emx2em).",
|
||||||
|
"Fixed a mistake in tag in profile panel.",
|
||||||
|
"Fixed a bug where when logging out, the local storage data used to be present."
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
version: 6.0,
|
version: 6.0,
|
||||||
title: "Desktop app!",
|
title: "Desktop app!",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue