Skip to content

Commit

Permalink
Remove code that would make chats disappear when a new message is sent
Browse files Browse the repository at this point in the history
  • Loading branch information
jmicko committed Jul 16, 2024
1 parent 0a0bc56 commit 58abf85
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client/src/components/Messages/MessageSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function MessageSection({
}
}, [messages, initialRender, mobileCollapsed, header]);

console.log(messages, 'messages ' + header);
// console.log(messages, 'messages ' + header);


return (
Expand Down
12 changes: 6 additions & 6 deletions server/modules/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ class Messenger {


// check and limit the number of stored messages
if (this.messages.length > 1000) {
this.messages.length = 1000;
}
// if (this.messages.length > 1000) {
// this.messages.length = 1000;
// }
// tell user to update messages
const jsonMsg = JSON.stringify(message);
console.log(jsonMsg, 'jsonMsg');
Expand All @@ -293,9 +293,9 @@ class Messenger {
this.messageCount++;
this.chatMessageCount++;
// check and limit the number of stored messages
if (this.messages.length > 1000) {
this.messages.length = 1000;
}
// if (this.messages.length > 1000) {
// this.messages.length = 1000;
// }
// tell user to update messages
const jsonMsg = JSON.stringify(message);
this.sockets.forEach(socket => {
Expand Down
1 change: 1 addition & 0 deletions server/modules/coinbaseClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ class Coinbase {
async getFills(params) {
return new Promise(async (resolve, reject) => {
try {
await sleep(100);
// data should just be blank
const data = null;
const API = {
Expand Down
14 changes: 14 additions & 0 deletions server/modules/database/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,18 @@ export async function deleteMessage(userID, messageID) {
reject(err);
}
})
}

export async function deletePrevious30DaysMessages() {
return new Promise(async (resolve, reject) => {
try {
const sqlText = `
DELETE FROM "messages"
WHERE "type" != 'chat' AND "timestamp" < NOW() - INTERVAL '30 days';`;
const result = await pool.query(sqlText);
resolve(result);
} catch (err) {
reject(err);
}
})
}

0 comments on commit 58abf85

Please sign in to comment.