unify variable names
This commit is contained in:
+24
-25
@@ -22,7 +22,7 @@ export interface ChatMessage {
|
|||||||
body: string;
|
body: string;
|
||||||
isoDate: string;
|
isoDate: string;
|
||||||
|
|
||||||
messageObject?: string;
|
messageObjectString?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// object
|
// object
|
||||||
@@ -154,17 +154,16 @@ export class Chat {
|
|||||||
if (data.subscribed != undefined) this.handleSubscription(data.subscribed);
|
if (data.subscribed != undefined) this.handleSubscription(data.subscribed);
|
||||||
|
|
||||||
if (!data.messageBody) return;
|
if (!data.messageBody) return;
|
||||||
const { sender, body, channel, isoDate, messageObject } = JSON.parse(
|
const message: ChatMessage = JSON.parse(data.messageBody);
|
||||||
data.messageBody
|
const { sender, body, channel, isoDate, messageObjectString } = message;
|
||||||
);
|
|
||||||
|
|
||||||
if (messageObject) {
|
if (messageObjectString) {
|
||||||
const decrypted = await decryptString(
|
const decryptedMessageObjectString = await decryptString(
|
||||||
messageObject,
|
messageObjectString,
|
||||||
this.encryptionKey.value
|
this.encryptionKey.value
|
||||||
);
|
);
|
||||||
const object = JSON.parse(decrypted);
|
const messageObject = JSON.parse(decryptedMessageObjectString);
|
||||||
if (object.id && object.title) return this.handleMessageObject(object);
|
if (messageObject.id && messageObject.title) return this.handleMessageObject(messageObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.handleMessage({
|
this.handleMessage({
|
||||||
@@ -199,10 +198,10 @@ export class Chat {
|
|||||||
const isSent = await this.sendMessage(message);
|
const isSent = await this.sendMessage(message);
|
||||||
if (isSent == true) this.outbox.remove(message);
|
if (isSent == true) this.outbox.remove(message);
|
||||||
});
|
});
|
||||||
this.objectOutbox.value.forEach(async (object) => {
|
this.objectOutbox.value.forEach(async (messageObject) => {
|
||||||
const chatMessage = await this.createChatMessage("", object);
|
const chatMessage = await this.createChatMessage("", messageObject);
|
||||||
const isSent = await this.sendMessage(chatMessage);
|
const isSent = await this.sendMessage(chatMessage);
|
||||||
if (isSent == true) this.objectOutbox.remove(object.id);
|
if (isSent == true) this.objectOutbox.remove(messageObject.id);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -230,7 +229,7 @@ export class Chat {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (messageObject)
|
if (messageObject)
|
||||||
chatMessage.messageObject = await encryptString(
|
chatMessage.messageObjectString = await encryptString(
|
||||||
JSON.stringify(messageObject),
|
JSON.stringify(messageObject),
|
||||||
this.encryptionKey.value
|
this.encryptionKey.value
|
||||||
);
|
);
|
||||||
@@ -307,25 +306,25 @@ export class Chat {
|
|||||||
};
|
};
|
||||||
|
|
||||||
updateObject = (id: string, contents: MessageObjectContent): void => {
|
updateObject = (id: string, contents: MessageObjectContent): void => {
|
||||||
const object = this.objects.value.get(id);
|
const messageObject = this.objects.value.get(id);
|
||||||
if (!object) return;
|
if (!messageObject) return;
|
||||||
object.contentVersions.push(contents);
|
messageObject.contentVersions.push(contents);
|
||||||
this.sendObject(object);
|
this.sendObject(messageObject);
|
||||||
};
|
};
|
||||||
|
|
||||||
addObjectAndSend = (object: MessageObject): void => {
|
addObjectAndSend = (messageObject: MessageObject): void => {
|
||||||
this.addObject(object);
|
this.addObject(messageObject);
|
||||||
this.sendObject(object);
|
this.sendObject(messageObject);
|
||||||
};
|
};
|
||||||
|
|
||||||
sendObject = (object: MessageObject): void => {
|
sendObject = (messageObject: MessageObject): void => {
|
||||||
this.objectOutbox.set(object.id, object);
|
this.objectOutbox.set(messageObject.id, messageObject);
|
||||||
this.sendMessagesInOutbox();
|
this.sendMessagesInOutbox();
|
||||||
};
|
};
|
||||||
|
|
||||||
deleteObject = (object: MessageObject): void => {
|
deleteObject = (messageObject: MessageObject): void => {
|
||||||
this.objects.remove(object.id);
|
this.objects.remove(messageObject.id);
|
||||||
this.objectOutbox.remove(object.id);
|
this.objectOutbox.remove(messageObject.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
resendObjects = (): void => {
|
resendObjects = (): void => {
|
||||||
|
|||||||
Reference in New Issue
Block a user