Text Channel (UI)

From Revolt Wiki
Revision as of 14:09, 15 January 2023 by Insert (Sọ̀rọ̀ | contribs) (Created page with "=== Message Grouping Algorithm === Within this algorithm, '''tail''' refers to whether the message omits displaying the user's avatar / username. # Let '''L''' be the list of messages ordered from newest to oldest # Let '''E''' be the list of elements to be rendered # For each message '''M''' in '''L''': ## Let '''tail''' be true ## Let '''date''' be null ## Let '''next''' be the next item in list '''L''' ## If '''next''' is not null: ### Let '''adate''' and '''bdate'''...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Message Grouping Algorithm

Within this algorithm, tail refers to whether the message omits displaying the user's avatar / username.

  1. Let L be the list of messages ordered from newest to oldest
  2. Let E be the list of elements to be rendered
  3. For each message M in L:
    1. Let tail be true
    2. Let date be null
    3. Let next be the next item in list L
    4. If next is not null:
      1. Let adate and bdate be the times the message M and the next message were created respectively
      2. If adate and bdate are not the same day:
        1. Let date be adate
      3. Let tail be false if one of the following conditions is satisfied:
        • Message M and last do not have the same author
        • The difference between bdate and adate is equal to or over 7 minutes
        • The masquerades for message M and last do not match
        • Message M or last is a system message
        • Message M replies to one or more messages
    5. Else if next is null:
      1. Let tail be false
    6. Push the message to list E (type id: 0; cache key: message id:tail)
    7. If date is not null:
      1. Push date formatted as "MMMM D, YYYY" to list E (type id: 1; cache key: formatted date)

Note: the Revolt client also caches the objects produced for list E by pushing each object into a Map by their given cache key above, then retrieving them the next time the code is run OR creating a new object if one is not present. This prevents Solid.js from completely rebuilding the DOM whenever the message list updates.