Better url handling when connecting to socketio.

This commit is contained in:
2020-11-20 18:37:22 +01:00
parent 054ff69b27
commit 7096fbed86

View File

@@ -87,13 +87,15 @@ export default {
}; };
}, },
created() { created() {
getChatHistory(0, 100).then(messages => (this.chatHistory = messages)); getChatHistory(0, this.historyPageSize)
.then(messages => this.chatHistory = messages);
}, },
mounted() { mounted() {
this.track(); this.track();
this.getAttendees(); this.getAttendees();
this.getWinners(); this.getWinners();
this.socket = io(`${window.location.hostname}:${window.location.port}`); const BASE_URL = __APIURL__ || window.location.origin;
this.socket = io(`${BASE_URL}`);
this.socket.on("color_winner", msg => {}); this.socket.on("color_winner", msg => {});
this.socket.on("chat", msg => { this.socket.on("chat", msg => {
@@ -167,10 +169,11 @@ export default {
const { historyPage, historyPageSize } = this; const { historyPage, historyPageSize } = this;
const page = historyPage + 1; const page = historyPage + 1;
getChatHistory(page * historyPageSize, historyPageSize).then(messages => { getChatHistory(page * historyPageSize, historyPageSize)
this.chatHistory = messages.concat(this.chatHistory); .then(messages => {
this.historyPage = page; this.chatHistory = messages.concat(this.chatHistory);
}); this.historyPage = page;
});
}, },
getWinners: async function() { getWinners: async function() {
let response = await winners(); let response = await winners();