From: David Woodhouse Date: Tue, 31 Mar 2020 21:24:17 +0000 (+0100) Subject: Don't fetch all rooms at startup if we haven't been mentioned. X-Git-Tag: v1.4~22 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c1ab5fe2f90d9c272d1cae0f3a3eb32c61d1c3c7;p=pidgin-chime.git Don't fetch all rooms at startup if we haven't been mentioned. This takes a huge amount of time for new clients. --- diff --git a/prpl/chat.c b/prpl/chat.c index cead0c4..3601dd8 100644 --- a/prpl/chat.c +++ b/prpl/chat.c @@ -1041,12 +1041,18 @@ static void on_chime_new_room(ChimeConnection *cxn, ChimeRoom *room, PurpleConne const gchar *msg_time; GTimeVal msg_tv; - if (chime_read_last_msg(conn, CHIME_OBJECT(room), &msg_time, NULL) && - g_time_val_from_iso8601(msg_time, &msg_tv) && - (mention_tv.tv_sec < msg_tv.tv_sec || - (mention_tv.tv_sec == msg_tv.tv_sec && mention_tv.tv_usec <= msg_tv.tv_usec))) { - /* LastMentioned is older than we've already seen. Nothing to do. */ - return; + /* For a new installation which hasn't seen this room at all yet, + * use the server's idea of LastRead instead of the local one. Otherwise + * we end up spending hours fetching *all* old rooms and messages. */ + if ( (chime_read_last_msg(conn, CHIME_OBJECT(room), &msg_time, NULL) && + g_time_val_from_iso8601(msg_time, &msg_tv)) || + ((msg_time = chime_room_get_last_read(room)) && + g_time_val_from_iso8601(msg_time, &msg_tv)) ) { + if (mention_tv.tv_sec < msg_tv.tv_sec || + (mention_tv.tv_sec == msg_tv.tv_sec && mention_tv.tv_usec <= msg_tv.tv_usec)) { + /* LastMentioned is older than we've already seen. Nothing to do. */ + return; + } } /* We have been mentioned since we last looked at this room. Open it now. */