From 32eb669f9644ea7a3aee97316865f9627f2073b5 Mon Sep 17 00:00:00 2001 From: shockrah Date: Tue, 27 Apr 2021 13:40:12 -0700 Subject: [PATCH] * messages.recent_messages now uses the /message/recent This should be more clear in its intentions and basically gives the behavior you expect when looking at this method --- freechat-client/src/messages.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/freechat-client/src/messages.js b/freechat-client/src/messages.js index 38c235c..dc79576 100644 --- a/freechat-client/src/messages.js +++ b/freechat-client/src/messages.js @@ -109,16 +109,28 @@ function push_message(message) { * @param {u64} auth.id user | id required by most/all endpoints * * @param {String} server.url | HTTP URL - * @param {String} server.wsurl | Websocket URL * - * @param {String} channel.description | Description of channel - * @params {u64} channel.id | channel id to query + * @params {u64} channel_id | channel id to query * @returns void */ -exports.recent_messages = async function (auth, server, channel, start_time, end_time, limit) { +exports.recent_messages = async function recent_messages(auth, server, channel_id, limit) { $('#messages-list').html('') - const messages = await get_range(auth, server, channel['id'], start_time, end_time, limit) + try { + const response = await got(server.url + '/message/recent',{ + searchParams: { + jwt: auth.jwt, + channel_id: channel_id, + limit: 80 + }, + responseType: 'json' + }) + const messages = response.body['messages'] + for(const message of messages) { + } + } catch (err) { + } + const messages = await get_range(auth, server, channel['id'], limit) for(const message of messages) { console.log(message)