When loading VirtualLottery we fetch default size of messages from /api/chat/history and append to local chatHistory.
This commit is contained in:
16
src/api.js
16
src/api.js
@@ -222,6 +222,19 @@ const register = (username, password) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const getChatHistory = (skip=null, take=null) => {
|
||||||
|
const url = new URL("/api/chat/history", BASE_URL);
|
||||||
|
if (!isNaN(skip))
|
||||||
|
url.searchParams.append("skip", skip);
|
||||||
|
if (!isNaN(take))
|
||||||
|
url.searchParams.append("take", take);
|
||||||
|
|
||||||
|
return fetch(url.href)
|
||||||
|
.then(resp => resp.json())
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
statistics,
|
statistics,
|
||||||
colorStatistics,
|
colorStatistics,
|
||||||
@@ -243,5 +256,6 @@ export {
|
|||||||
winners,
|
winners,
|
||||||
winnersSecure,
|
winnersSecure,
|
||||||
deleteWinners,
|
deleteWinners,
|
||||||
deleteAttendees
|
deleteAttendees,
|
||||||
|
getChatHistory
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { page, event } from "vue-analytics";
|
import { page, event } from "vue-analytics";
|
||||||
import { attendees, winners } from "@/api";
|
import { attendees, winners, getChatHistory } from "@/api";
|
||||||
import Chat from "@/ui/Chat";
|
import Chat from "@/ui/Chat";
|
||||||
import Vipps from "@/ui/Vipps";
|
import Vipps from "@/ui/Vipps";
|
||||||
import Attendees from "@/ui/Attendees";
|
import Attendees from "@/ui/Attendees";
|
||||||
@@ -61,6 +61,10 @@ export default {
|
|||||||
emitUsernameOnConnect: false
|
emitUsernameOnConnect: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
getChatHistory()
|
||||||
|
.then(messages => this.chatHistory = messages)
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.track();
|
this.track();
|
||||||
this.getAttendees();
|
this.getAttendees();
|
||||||
|
|||||||
Reference in New Issue
Block a user