App icon indicating copy to clipboard operation
App copied to clipboard

[HOLD for payment 2022-01-21] In #focus mode, active chats should show beneath pinned chats in the LHN

Open isagoico opened this issue 5 years ago • 54 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Set your LHN to #focus mode
  2. Pin 2+ chats
  3. Set your active chat to be a non-pinned chat, that alphabetically would not be the last chat in your LHN
  4. Observe the chat being placed within the pinned chats, instead of after them

Expected Result:

Pinned conversations should always be displayed on top of the LHN list. any other active chats should show beneath pinned chats in the LHN.

Actual Result:

Conversations are displayed on alphabetical order and non pinned chats are mixed with regular chats.

Workaround:

None needed, visual issue.

Platform:

Where is this issue occurring?

  • Web
  • iOS
  • Android
  • Desktop App
  • Mobile Web

Version Number: 1.1.17-0

Reproducible in staging?: Yes Reproducible in production?: Yes

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation

image

Upwork job: https://www.upwork.com/jobs/~01ff25496a7aa2449e

Issue reported by: @alex-mechler Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1638299485080700

View all open jobs on GitHub

isagoico avatar Dec 02 '21 18:12 isagoico

Triggered auto assignment to @robertjchen (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

MelvinBot avatar Dec 02 '21 18:12 MelvinBot

Thanks for the report! Looks like a great task for our contributors

robertjchen avatar Dec 07 '21 14:12 robertjchen

Triggered auto assignment to @michaelhaxhiu (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

MelvinBot avatar Dec 07 '21 14:12 MelvinBot

Update:

  • Just tested and this is legit 🐛
  • Updated the title in favor of clarity 🧼
  • Posted to upwork 💰 https://www.upwork.com/jobs/~01ff25496a7aa2449e

michaelhaxhiu avatar Dec 08 '21 18:12 michaelhaxhiu

Triggered auto assignment to @parasharrajat (Exported)

MelvinBot avatar Dec 08 '21 18:12 MelvinBot

Triggered auto assignment to @Luke9389 (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

MelvinBot avatar Dec 08 '21 18:12 MelvinBot

Hmm, I think we're double assigning CME's now. The Exported label does it, and so does the Help Wanted label.

Luke9389 avatar Dec 09 '21 00:12 Luke9389

Proposal

In our opinion, we should check if focusMode is enabled and sort result Array with isPinned value in SidebarLinks.js.

We have to add focusMode prop from onyx here:

withOnyx({
        focusMode : {
            key : ONYXKEYS.NVP_PRIORITY_MODE
        },

in propTypes :

/** The user's focusMode  */
focusMode: PropTypes.string,

and do something like this in getRecentReports(props) function :

static getRecentReports(props) {
        const activeReportID = parseInt(props.currentlyViewedReportID, 10);
        const sidebarOptions = OptionsListUtils.getSidebarOptions(
            props.reports,
            props.personalDetails,
            activeReportID,
            props.priorityMode,
            props.betas,
        );
        
        if (props.focusMode !== 'gsd') {
            return sidebarOptions.recentReports;
        } else {
            return sidebarOptions.recentReports.sort( (element, nextElement) => nextElement.isPinned - element.isPinned);
        }   
    }

Before Changes

https://user-images.githubusercontent.com/71173662/145391285-c2179259-aac5-473b-bb49-26f86af19983.mp4

After Changes

https://user-images.githubusercontent.com/71173662/145391379-ef6dff2e-748c-4fc6-8ccd-1231f951e42b.mp4

If you think that something is wrong, feel free to say us, we are open to discussion🙂.

developvsn avatar Dec 09 '21 11:12 developvsn

@developvsn Thanks for the proposal but I think it can be improved a lot and require more analysis of the code.

  1. It does not fix the real cause.
  2. Add sugar coating.
  3. Will cause side-effects. You are missing the behavior of the SideLinks.js component.
  4. Does not tell how will you do it. It's just bits and pieces.

e.g.

We have to add focusMode prop from onyx here and do something like this in getRecentReports(props) function :

Where will you do this?

parasharrajat avatar Dec 09 '21 13:12 parasharrajat

@parasharrajat

  1. Why do you think so? Data is coming in SideLink.js in correct way, we should only sort it and display.
  2. If you are talking about ternary operators, we changed it, thank you.
  3. We tried to check all situations, what we were possible to simulate.What do you mean?
  4. Changed.

developvsn avatar Dec 09 '21 13:12 developvsn

I'm testing something unrelated to this issue, and need to remove/re-add the Exported label real quick. Ignore me.

michaelhaxhiu avatar Dec 09 '21 15:12 michaelhaxhiu

Current assignee @parasharrajat is eligible for the Exported assigner, not assigning anyone new.

MelvinBot avatar Dec 09 '21 15:12 MelvinBot

Current assignee @Luke9389 is eligible for the Exported assigner, not assigning anyone new.

MelvinBot avatar Dec 09 '21 15:12 MelvinBot

Why do you think so? Data is coming in SideLink.js in correct way,

Data is coming in SideLink.js in correct way Then why are you sorting again. Sorting logic is already there.

parasharrajat avatar Dec 09 '21 18:12 parasharrajat

Why do you think so? Data is coming in SideLink.js in correct way,

Data is coming in SideLink.js in correct way Then why are you sorting again. Sorting logic is already there.

Look like it sort by unread messages and the existing sort works correctly only for non-focus mode, so can you please give us an example, when our code will work wrong. Thank you

developvsn avatar Dec 09 '21 19:12 developvsn

Proposal.

We forgot to add prioritizePinnedReports: true inside sideBarOptions in this code: https://github.com/Expensify/App/blob/d827b9b9abdee6dd8cedb520ce51f38e39dccf3e/src/libs/OptionsListUtils.js#L689-L694

Adding prioritizePinnedReports: true resolve the problem for me.

Basically onyx CONST.PRIORITY_MODE save priority mode option value. When we display LHN SidebarLinks, eventually getSidebarOptions will be called to get options on how we display OptionsList. CONST.PRIORITY_MODE.GSD is option for focus mode and we need prioritizePinnedReports: true to make pinned tabs always on top.

https://github.com/Expensify/App/blob/d827b9b9abdee6dd8cedb520ce51f38e39dccf3e/src/libs/OptionsListUtils.js#L677

K4tsuki avatar Dec 12 '21 07:12 K4tsuki

@parasharrajat? I am sorry, Is it not working? or not elaborate enough? I have edited the proposal.

K4tsuki avatar Dec 13 '21 02:12 K4tsuki

@K4tsuki It does not work.

parasharrajat avatar Dec 13 '21 07:12 parasharrajat

pinned_issue It doesn't work at all? It does works for me though.

K4tsuki avatar Dec 13 '21 11:12 K4tsuki

For case sensitive sorting issue: https://github.com/Expensify/App/blob/d827b9b9abdee6dd8cedb520ce51f38e39dccf3e/src/libs/OptionsListUtils.js#L502

lodashOrderBy is case sensitive, so to sort it case insensitively we callback const sortedPinnedReports = lodashOrderBy( pinnedReportOptions, [ report => report.text.toLowerCase()], ['asc']); Also on this:

https://github.com/Expensify/App/blob/d827b9b9abdee6dd8cedb520ce51f38e39dccf3e/src/libs/OptionsListUtils.js#L381

K4tsuki avatar Dec 13 '21 15:12 K4tsuki