Store chat username on send
This commit is contained in:
@@ -8,7 +8,8 @@ define(
|
||||
this.author = ko.observable(model.author);
|
||||
this.body = ko.observable(model.body);
|
||||
} else {
|
||||
this.author = ko.observable("Anonymous");
|
||||
const storedAuthor = localStorage.author || "Viewer" + (Math.floor(Math.random() * 42) + 1)
|
||||
this.author = ko.observable(storedAuthor);
|
||||
this.body = ko.observable("");
|
||||
}
|
||||
this.image = ko.observable("https://robohash.org/" + this.author() + "?set=set3&size=50x50")
|
||||
|
||||
@@ -17,12 +17,13 @@ define(
|
||||
var message = new Message();
|
||||
message.author(model.author);
|
||||
message.image("https://robohash.org/" + model.author);
|
||||
console.log("https://robohash.org/" + model.author)
|
||||
this.editingMessage(message);
|
||||
|
||||
localStorage.author = model.author
|
||||
console.log(model.author)
|
||||
};
|
||||
|
||||
ws.onmessage = function (e) {
|
||||
console.log("on message")
|
||||
var model = $.evalJSON(e.data);
|
||||
var msg = new Message(model);
|
||||
that.messages.push(msg);
|
||||
|
||||
Reference in New Issue
Block a user