Fix db stuff and remove unneeded message function

pull/455/head
Beaudan Brown 6 years ago
parent 63293c5b03
commit 1b4105a3d0

@ -790,7 +790,7 @@ async function updateToLokiSchemaVersion1(currentVersion, instance) {
await instance.run(
`ALTER TABLE messages
ADD COLUMN serverId STRING;`
ADD COLUMN serverId INTEGER;`
);
await instance.run(
@ -2060,11 +2060,14 @@ async function removeMessage(id) {
);
}
async function getMessageByServerId(serverId) {
async function getMessageByServerId(serverId, conversationId) {
const row = await db.get(
'SELECT * FROM messages WHERE serverId = $serverId;',
`SELECT * FROM messages WHERE
serverId = $serverId AND
conversationId = $conversationId;`,
{
$serverId: serverId,
$conversationId: conversationId,
}
);

@ -357,9 +357,6 @@
onDestroy() {
this.cleanup();
},
deleteMessage() {
this.trigger('delete', this);
},
async cleanup() {
MessageController.unregister(this.id);
this.unload();
@ -1243,6 +1240,9 @@
Message: Whisper.Message,
});
},
getServerId() {
return this.get('serverId');
},
async setServerId(serverId) {
if (_.isEqual(this.get('serverId'), serverId)) return;

@ -908,8 +908,8 @@ async function _removeMessages(ids) {
await channels.removeMessage(ids);
}
async function getMessageByServerId(id, { Message }) {
const message = await channels.getMessageByServerId(id);
async function getMessageByServerId(serverId, conversationId, { Message }) {
const message = await channels.getMessageByServerId(serverId, conversationId);
if (!message) {
return null;
}

Loading…
Cancel
Save