handling user icons via HyperDrive

This commit is contained in:
Raven Scott
2024-06-14 15:09:54 -04:00
parent 1c6cc9a82e
commit db88b09ba5
7 changed files with 110 additions and 36 deletions

View File

@ -2,8 +2,8 @@ import Message from "./Message.js";
import b4a from "b4a";
class IconMessage extends Message {
constructor(peerName, peerAvatar, topic, timestamp) {
super("icon", peerName, peerAvatar, topic, timestamp);
constructor(peerName, peerAvatar, timestamp) {
super("icon", peerName, peerAvatar, null, timestamp);
}
toJsonString() {

View File

@ -10,7 +10,7 @@ class Message {
toJson() {
return {
type: this.type,
name: this.peerName,
username: this.peerName,
avatar: this.peerAvatar,
topic: this.topic,
timestamp: this.timestamp

View File

@ -1,21 +1,21 @@
import Message from "./Message.js";
class TextMessage extends Message {
constructor(peerName, peerAvatar, topic, timestamp, message) {
super("message", peerName, peerAvatar, topic, timestamp);
this.message = message;
}
constructor(peerName, peerAvatar, topic, timestamp, message) {
super("message", peerName, peerAvatar, topic, timestamp);
this.message = message;
}
toJsonString() {
return JSON.stringify({
...this.toJson(),
message: this.message,
});
}
toJsonString() {
return JSON.stringify({
...this.toJson(),
message: this.message,
});
}
static new(bot, message) {
return new TextMessage(bot.botName, bot.botAvatar, bot.currentTopic, Date.now(), message);
}
static new(bot, message) {
return new TextMessage(bot.botName, bot.botAvatar, bot.currentTopic, Date.now(), message);
}
}
export default TextMessage;