Time stamp display rules for chat IM

Source: Internet
Author: User

======================================================

The following rules are inferred after the experience operation, there may be some inaccurate statements

======================================================

Reference Datum

When chatting, the chat content is more important than the chat time, try to avoid the time and send status of the chat content interference, simplify the interface, only the core information: sender, send content.

Badge (number of unread messages)

When the number of messages reaches three digits (that is, the number of messages > 99), the display ... Rather than numbers, relieve/relieve psychological stress in obsessive-compulsive disorder patients

Time Stamp Display

Timestamps are handled by the client itself, the display of timestamps is displayed according to different scenarios, and there are several typical usage scenarios, but no matter how it is displayed, the time stamp must be displayed for more than 5 minutes between messages.

# # #点击聊天列表, enter chat details (single or group chat)

1) Get the data

Get up to 20 recent data (20 for one page of data, more than 20 for the last 20, less than 20 when the number is taken)

2) Display data

Gets the time the first message was received, then inserts the timestamp into the interface and logs it (assuming that the variable lastshowtimestamp is used), and then appends the message to the interface in timestamp (from small to large, old message in the previous new message), but with the time stamp display rule.

When iterating through each message, you need to determine when the message is received and the last time the timestamp is displayed, and when it is greater than 5 minutes (300ms), append a timestamp and update the value of Lastshowtimestamp.

# # #时间戳的显示规则

Messages in one day are displayed as: "Yesterday: Minutes"

Two days to seven days shown as: "Week x: Minutes"

When greater than 7 days is displayed as: "YYYY year x month x day: Minute"

When, points less than two, the front with 0 to fill, the month, the day less than two bit is not padded. such as: July 13, 2016 09:22, note that the calculation of days is to calculate the day, can not take milliseconds to compare. Otherwise, the news of yesterday morning will become "Week x 09:10" In this afternoon, the correct should be "Yesterday 09:10"

Examples are as follows:

# # #聊天ing

When a new message is received, the interval between the currently received message and the Lastshowtimestamp is judged to be greater than 5 minutes and the timestamp is displayed while the value of Lastshowtimestamp is updated to the timestamp that the current new message received.

There is a situation where the message volume reaches 100 in 5 minutes, and there is no time stamp in the middle of the 1000 data. If you exit the chat screen and then re-enter, refer to the first rule.

Example:

# # #当向下拉取消息时

When you pull up a message up, get up to 20 data (how many times a page is less than one page), and then display it according to the rules of the first rule.

The timestamp is displayed first, and then each timestamp is compared with the timestamp of the last display, the new timestamp is displayed when the interval is greater than 5 minutes, and the only difference from the first rule is that the value of Lastshowtimestamp is not updated at this time. Because the value of lastshowtimestamp is used to judge the new message, the old message needs to be judged by using a temporary variable record, pulling and displaying a page of data is discarded.

In the event that you pull up a message up, you will encounter a time stamp for each message sent within the same minute, and the timestamp is the same. The reason for this is that the message is within two pages.

Examples are as follows:

# # #删除单条消息时

When a message is deleted, the time stamp is deleted when the message is deleted with a timestamp and the next one is not a message record.

This can lead to a situation where the timestamp is removed, the lastshowtimestamp is not updated, and if a new message is received at this time, it will no longer display a timestamp. The timestamp is not displayed again until the new message exceeds the 5-minute interval and the value of the Lastshowtimestamp is updated. Checks the current number of messages after the message is deleted, and automatically reloads the previous page of data when there is less than one page until no message is available to load.

Examples are as follows (the first picture is normal, the second picture is abnormal, exit chat re-enter or wait 5 minutes to return to normal):

# # #批量删除消息时

A rule is similar to a single delete, except that a row must be traversed up and down when it is selected.

Go up over the duration:

If the previous message is unchecked, abort the search upward;

If the previous message is selected, continue looking up until the unchecked message (abort) is found, the timestamp is found (where the timestamp is recorded, and then traversed down);

Go down over the duration:

If the next message is unchecked, the timestamp location of the record is cleared, and the downward lookup is aborted;

If the next message is selected, continue looking down until the unchecked message is found (abort and clear), find the timestamp (successfully found, that is, forward is a timestamp, the back is a timestamp, or the last message also records the timestamp of the upward lookup)

Note: When deleting batches, you can delete up to 100 data at a time. After the message is deleted, it is necessary to determine whether the current number of messages is enough for a page (20), and then load up one page of data (20);

When you click Delete, the deletion is done once, avoiding the traversal affecting performance.

Examples are as follows:

Time stamp display rules for chat IM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.