Skip to content

Loading child messages when opening the TMF

Tomas Vik requested to merge 2202-endpoint-returning-child-messages into develop

Part of #2202 (closed)

Purpose of this MR is to be able to load child messages when opening TMF.

What has been done:

  • covered the chatService with more tests
  • converted findChatMessagesForTroupe to async-await
  • covered the apiClient with some tests
  • new function chatService.findThreadChatMessages
  • exposing the child messages on /api/v1/rooms/{roomId}/chatMessages/{parentId}/thread
  • fetching child messages upon opening TMF
  • style Loading and error messages
  • log error if there is one during loading child messages (done by apiClient)
  • if we proceed with using the VuexApiRequest:
    • write tests
    • in a separate MR: convert the left menu code to use it
  • make sure that integration of VuexApiRequest with the store is tested

UX reference

Error Loading Success
Screenshot_2019-08-05_at_08.41.59 Kapture_2019-08-05_at_8.41.24 Screenshot_2019-08-05_at_08.40.32

Testing

The threaded-conversations toggle should be on. http://localhost:5000/api_web/features/threaded-conversations/1

  1. Open a thread message feed
  2. create 2 messages using the TMF chat input
  3. refresh the page and start a thread from the same parent message
  4. you should see the messages being fetched

Index:

  1. I've tested that the schema change results in the correct index being created: parentId_1_sent_-1
    ChatMessageSchema.index(
      { parentId: 1, sent: -1 },
      {
        partialFilterExpression: { parentId: { $exists: true } },
        background: true
      }
    );
    results in:
    troupeSet:PRIMARY> db.chatmessages.getIndexes()
    [
    ...
    {
    	"v" : 1,
    	"key" : {
    		"parentId" : 1,
    		"sent" : -1
    	},
    	"name" : "parentId_1_sent_-1",
    	"ns" : "gitter.chatmessages",
    	"partialFilterExpression" : {
    		"parentId" : {
    			"$exists" : true
    		}
    	},
    	"background" : true
    }
    ]
Edited by Tomas Vik

Merge request reports