Fix incorrect message counter
| @@ -73,7 +73,7 @@ function formatBytes(bytes) { | |||
| 73 | function getPreviewMessage(messages) { | 73 | function getPreviewMessage(messages) { |
| 74 | const strlen = 300; | 74 | const strlen = 300; |
| 75 | const lastMessage = messages[messages.length - 1]?.mes; | 75 | const lastMessage = messages[messages.length - 1]?.mes; |
| 76 | 76 | ||
| 77 | if (!lastMessage) { | 77 | if (!lastMessage) { |
| 78 | return ''; | 78 | return ''; |
| 79 | } | 79 | } |
| @@ -609,13 +609,13 @@ router.post('/search', jsonParser, function (request, response) { | |||
| 609 | } | 609 | } |
| 610 | 610 | ||
| 611 | const results = []; | 611 | const results = []; |
| 612 | 612 | ||
| 613 | // Search logic | 613 | // Search logic |
| 614 | for (const chatFile of chatFiles) { | 614 | for (const chatFile of chatFiles) { |
| 615 | const data = fs.readFileSync(chatFile.path, 'utf8'); | 615 | const data = fs.readFileSync(chatFile.path, 'utf8'); |
| 616 | const messages = data.split('\n') | 616 | const messages = data.split('\n') |
| 617 | .map(line => { try { return JSON.parse(line); } catch (_) { return null; } }) | 617 | .map(line => { try { return JSON.parse(line); } catch (_) { return null; } }) |
| 618 | .filter(x => x); | 618 | .filter(x => x && typeof x.mes === 'string'); |
| 619 | 619 | ||
| 620 | if (messages.length === 0) { | 620 | if (messages.length === 0) { |
| 621 | continue; | 621 | continue; |
| @@ -662,4 +662,4 @@ router.post('/search', jsonParser, function (request, response) { | |||
| 662 | console.error('Chat search error:', error); | 662 | console.error('Chat search error:', error); |
| 663 | return response.status(500).json({ error: 'Search failed' }); | 663 | return response.status(500).json({ error: 'Search failed' }); |
| 664 | } | 664 | } |
| 665 | }); | ||
| 665 | \ No newline at end of file | \ No newline at end of file | |
| 665 | }); | ||