Add loading history message on initial MAM request
This prevents scrolling to top and initiating another MAM request while still fetching the initial one. Also free timestamp object in database.c
This commit is contained in:
@@ -246,7 +246,8 @@ log_database_get_previous_chat(const gchar* const contact_barejid, char* start_t
|
||||
|
||||
// Flip order when querying older pages
|
||||
gchar* sort = !flip ? "ASC" : "DESC";
|
||||
gchar* end_date_fmt = end_time ? end_time : g_date_time_format_iso8601(g_date_time_new_now_local());
|
||||
GDateTime* now = g_date_time_new_now_local();
|
||||
gchar* end_date_fmt = end_time ? end_time : g_date_time_format_iso8601(now);
|
||||
gchar* start_date_fmt = start_time ? start_time : NULL;
|
||||
query = sqlite3_mprintf("SELECT * FROM (SELECT `message`, `timestamp`, `from_jid`, `type` from `ChatLogs` WHERE ((`from_jid` = '%q' AND `to_jid` = '%q') OR (`from_jid` = '%q' AND `to_jid` = '%q')) AND `timestamp` < '%q' AND (%Q IS NULL OR `timestamp` > %Q) ORDER BY `timestamp` DESC LIMIT %d) ORDER BY `timestamp` %s;", contact_barejid, myjid->barejid, myjid->barejid, contact_barejid, end_date_fmt, start_date_fmt, start_date_fmt, MESSAGES_TO_RETRIEVE, sort);
|
||||
if (!query) {
|
||||
@@ -254,6 +255,7 @@ log_database_get_previous_chat(const gchar* const contact_barejid, char* start_t
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_date_time_unref(now);
|
||||
g_free(end_date_fmt);
|
||||
|
||||
jid_destroy(myjid);
|
||||
|
||||
Reference in New Issue
Block a user