Skip to content

Comments

[NEW] Add activity indicators for Uploading and Recording using new API; Support thread context; Deprecate the old typing API#22392

Merged
rodrigok merged 34 commits intoRocketChat:developfrom
sumukhah:thread-activity-indicator
Sep 23, 2021
Merged

[NEW] Add activity indicators for Uploading and Recording using new API; Support thread context; Deprecate the old typing API#22392
rodrigok merged 34 commits intoRocketChat:developfrom
sumukhah:thread-activity-indicator

Conversation

@sumukhah
Copy link
Contributor

@sumukhah sumukhah commented Jun 17, 2021

New statuses for user actions/events (Typing 2.0)

Rocket chat sponsored GSoC Project
Mentor: Rodrigo Nascimento
student: Sumukha Hegde

Primary tasks of this project:

  • To implement Recording, and uploading activity indicators
  • To implement thread statuses

Implementation of Recording and Uploading activity indicators

Showing activity indicators (such as typing, recording, uploading) improves overall user experience and offers a live chat experience to users who may expect quick response times. For this reason, many chat applications have used these activity indicators.
I have implemented recording and uploading indicators in mobile and in the web application(live chat remaining). We have used a separate activity type (named user-activity) that would handle all three activity indicators. We would pass the (typing, recording, uploading) action types as actionType parameter while calling the streamer to broadcast these user events.
But the new activity type (user-activity) supports only on the web and mobile platform and does not support live chat, bot, e.t.c,. The backend fires the new event when receives the old one and fires the old event when receives the new one, firing both events allows old clients to stay compatible until the next breaking change.

Implementation of thread statuses

In the previous app, Thread activities were not displaying on the thread but on the main channel. This issue is fixed in this Project, we used a parameter extra that would take thread id (tmid) as a value if the user is performing on a thread. Both the mobile and web applications can show these improvements.

Formats

Old events

// Sending event
{
  "msg": "method",
  "id": "1",
  "method": "stream-notify-room",
  "params": [
    "GENERAL/typing",
    "username",
    true, // true when typing, false when not typing
    {
      "token": "cu4B8Aab4ZbowqiwX" // When livechat
    }
  ]
}

// Receiving event
{
  "msg": "changed",
  "collection": "stream-notify-room",
  "id": "id",
  "fields": {
    "eventName": "GENERAL/typing",
    "args": [
      "username",
      true,
      {
        "token": "defaYPat68LevQpLm" // When livechat
      }
    ]
  }
}

New events

// Sendind event
{
  "msg": "method",
  "id": "1",
  "method": "stream-notify-room",
  "params": [
    "GENERAL/user-activity",
    "username",
    ["user-typing"], // Can be multiple events ["user-typing", "user-recording", "user-uploading"]. Remove the event to stop, pass empty array to stop all
    {
      "tmid": "cu4B8Aab4ZbowqiwX", // When thread
      "token": "defaYPat68LevQpLm" // When livechat
    }
  ]
}

// Receiving event
{
  "msg": "changed",
  "collection": "stream-notify-room",
  "id": "id",
  "fields": {
    "eventName": "GENERAL/user-activity",
    "args": [
      "username",
      ["user-typing"], // Can be single, multiple or empty
      {
        "tmid": "cu4B8Aab4ZbowqiwX", // When thread
        "token": "defaYPat68LevQpLm" // When livechat
      }
    ]
  }
}

References

#22392 web app PR
#3243 mobile PR
#139 SDK support for mobile

extras

https://user-images.githubusercontent.com/23723464/121769591-0a10eb00-cb82-11eb-96d8-241486dbccd4.mov
https://user-images.githubusercontent.com/23723464/122437728-9aeb2a80-cfb7-11eb-945a-dd9131f9df74.mov

@sumukhah sumukhah changed the title [New] Added Thread activity indicator [New] Add additional activity indicators (Typing 2.0) Jul 9, 2021
@sumukhah sumukhah changed the title [New] Add additional activity indicators (Typing 2.0) [New] Add additional activity indicators Jul 9, 2021
sumukhah and others added 3 commits July 12, 2021 18:19
minor fix: It was using two different instance of the template with slight different args.
(i.e pass tmid if present else pass rid). But we can use a single template and pass both the args
to the same template. Then we can filter them.
@sumukhah sumukhah force-pushed the thread-activity-indicator branch from a488883 to 8fb9c66 Compare July 17, 2021 15:05
Copy link
Member

@rodrigok rodrigok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you convert the new files to typescript?

sumukhah added 6 commits July 19, 2021 16:36
when a user A is typing while another user B is also typing, This will show them
as "userA/B also typing". Many other platforms are not using this feature, and also
it is not so useful.
Used a single dictionary to store all user activities. removed notifyUserActivity template.
@sumukhah sumukhah force-pushed the thread-activity-indicator branch from 8eb3ee4 to 709fafe Compare July 22, 2021 08:23
Co-authored-by: Rodrigo Nascimento <rodrigoknascimento@gmail.com>
changed object data structure to map data structure.
use 'OR' operator instead of ternary operation
@sumukhah sumukhah force-pushed the thread-activity-indicator branch from 3e3d5cd to 82aeec1 Compare August 6, 2021 07:39
@sumukhah
Copy link
Contributor Author

sumukhah commented Aug 10, 2021

I have converted the UserAction.js file to TS. Other than this I had also converted userActionIndicator to TS. But it was a helper method for the userActionIndicator template, and cannot be imported on another template file. So I did not include the file.

…dicator

# Conflicts:
#	app/ui-message/client/messageBox/messageBoxAudioMessage.js
#	app/ui-message/client/messageBox/messageBoxTyping.js
#	app/ui/client/lib/fileUpload.js
@sumukhah sumukhah marked this pull request as ready for review September 23, 2021 12:19
@rodrigok rodrigok force-pushed the thread-activity-indicator branch from 2188e18 to 5adf209 Compare September 23, 2021 17:37
- Fix typing layout
- Change event format to be more compatible with old one
- Remove setting
- Make the backend emit compatibility events
- Other small improvements
@rodrigok rodrigok force-pushed the thread-activity-indicator branch from 5adf209 to 3a4f6e7 Compare September 23, 2021 17:44
rodrigok
rodrigok previously approved these changes Sep 23, 2021
@rodrigok rodrigok changed the title [New] Add additional activity indicators [NEW] Add activity indicators for Uploading and Recording using new API; Deprecated the old typing API Sep 23, 2021
@rodrigok rodrigok changed the title [NEW] Add activity indicators for Uploading and Recording using new API; Deprecated the old typing API [NEW] Add activity indicators for Uploading and Recording using new API; Deprecate the old typing API Sep 23, 2021
@rodrigok rodrigok changed the title [NEW] Add activity indicators for Uploading and Recording using new API; Deprecate the old typing API [NEW] Add activity indicators for Uploading and Recording using new API; Support thread context; Deprecate the old typing API Sep 23, 2021
@rodrigok rodrigok force-pushed the thread-activity-indicator branch 2 times, most recently from f17b0c9 to 3191aab Compare September 23, 2021 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants