Merge branch 'master' into gek/current-stream-duration
This commit is contained in:
@@ -46,7 +46,6 @@ class Owncast {
|
||||
el: '#app-container',
|
||||
data: {
|
||||
isOnline: false,
|
||||
layout: hasTouchScreen() ? 'touch' : 'desktop',
|
||||
messages: [],
|
||||
overallMaxViewerCount: 0,
|
||||
sessionMaxViewerCount: 0,
|
||||
@@ -86,6 +85,8 @@ class Owncast {
|
||||
onError: this.handlePlayerError,
|
||||
});
|
||||
this.player.init();
|
||||
|
||||
this.getChatHistory();
|
||||
};
|
||||
|
||||
setConfigData(data) {
|
||||
@@ -132,17 +133,21 @@ class Owncast {
|
||||
return;
|
||||
}
|
||||
const message = new Message(model);
|
||||
const existing = this.vueApp.messages.filter(function (item) {
|
||||
return item.id === message.id;
|
||||
})
|
||||
if (existing.length === 0 || !existing) {
|
||||
this.vueApp.messages = [...this.vueApp.messages, message];
|
||||
}
|
||||
this.addMessage(message);
|
||||
};
|
||||
this.websocket = ws;
|
||||
this.messagingInterface.setWebsocket(this.websocket);
|
||||
};
|
||||
|
||||
addMessage(message) {
|
||||
const existing = this.vueApp.messages.filter(function (item) {
|
||||
return item.id === message.id;
|
||||
})
|
||||
if (existing.length === 0 || !existing) {
|
||||
this.vueApp.messages = [...this.vueApp.messages, message];
|
||||
}
|
||||
}
|
||||
|
||||
// fetch /config data
|
||||
getConfig() {
|
||||
fetch(URL_CONFIG)
|
||||
@@ -296,4 +301,18 @@ class Owncast {
|
||||
this.handleOfflineMode();
|
||||
// stop timers?
|
||||
};
|
||||
|
||||
async getChatHistory() {
|
||||
const url = "/chat";
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
const messages = data.map(function (message) {
|
||||
return new Message(message);
|
||||
})
|
||||
this.setChatHistory(messages);
|
||||
}
|
||||
|
||||
setChatHistory(messages) {
|
||||
this.vueApp.messages = messages.concat(this.vueApp.messages);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user