Page MenuHomePhabricator

[web] Introduce `chat-creation` mode in `navInfo`
ClosedPublic

Authored by jacek on Jul 6 2022, 7:05 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 12, 1:10 AM
Unknown Object (File)
Tue, Nov 12, 1:10 AM
Unknown Object (File)
Tue, Nov 12, 1:10 AM
Unknown Object (File)
Tue, Nov 12, 1:10 AM
Unknown Object (File)
Tue, Nov 12, 1:10 AM
Unknown Object (File)
Tue, Nov 12, 1:10 AM
Unknown Object (File)
Tue, Nov 12, 1:09 AM
Unknown Object (File)
Tue, Nov 12, 1:09 AM

Details

Summary

The diff extends navInfo object with new chat-mode - which is an enum - 'view' or 'create', and`selectedUserList` containing list of users read from URL.
The aim is to keep URL while creating (or finding existing) thread look like /chat/thread/new/<list_of_added_users_separated_by_comma>.
So for example /chat/thread/new/1,7,48/ is going to redirect user to chat creation screen with selected three users with IDs 1,7 and 48.
Empty list will create URL look like /chat/thread/new/

Test Plan

The change doesn't affect current navigation. New paths are not used in application yet. I tested the navigation after introducing more thread creation logic (in next diffs)

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

ashoat requested changes to this revision.Jul 7 2022, 6:34 AM

Can you provide some more context for why we need a new tab type for this? It seems pretty confusing to me... in the UI, we have just three tabs. It would seem like chat creation should be part of the chat tab?

This revision now requires changes to proceed.Jul 7 2022, 6:34 AM

Can you provide some more context for why we need a new tab type for this? It seems pretty confusing to me... in the UI, we have just three tabs. It would seem like chat creation should be part of the chat tab?

Yes, it's in fact confusing... The initial idea (before my exam break) was to support new app state - chat creation - with separate "tab", but as you notice, we will not create different tab in UI for it. The drawback is also that we lose the chat-creation state when switching between apps.
After discussion with @palys-swm, we concluded, it would be the best to support navigation state by introducing a separate field - chatMode in navInfo - and keep chat state in a way similar to settingsSection. We also agreed, that as a follow-up task it would be good to refactor the navigation to keep navigation state in more nested structure - so all chat-related fields (activeChatThreadID, pendingThread, selectedUserList and chatMode) would be put inside the e.g. ChatNavigationState object in navInfo.

So, I'm going to update this diff (and it's name) to replace the new tab with a separate field in navInfo.

Introduce chatMode field instead of creating new tab.

Agree with both of those conclusions!

We also agreed, that as a follow-up task it would be good to refactor the navigation to keep navigation state in more nested structure

We could create a new backlog task for this one.

This revision is now accepted and ready to land.Jul 11 2022, 6:25 AM

(Would like to make sure @palys-swm does a full pass)

This revision now requires review to proceed.Jul 11 2022, 6:25 AM
jacek retitled this revision from [web] Introduce `chat-creation` tab in `navInfo` to [web] Introduce `chat-creation` mode in `navInfo`.Jul 11 2022, 6:32 AM
jacek edited the summary of this revision. (Show Details)
abosh added inline comments.
web/url-utils.js
59–62 ↗(On Diff #14391)

Can simplify this with a ternary.

tomek requested changes to this revision.Jul 19 2022, 5:41 AM
tomek added inline comments.
lib/utils/url-utils.js
35 ↗(On Diff #14391)

What is the reason behind using commas in this url? We already have getLocallyUniqueThreadID where we use plus signs instead - can we do the same here to keep it consistent?

web/url-utils.js
126–131 ↗(On Diff #14391)

We're modifying the newNavInfo so there's no benefit in destructuring it.

We can also modify the urlInfo.settings code to use the same pattern

This revision now requires changes to proceed.Jul 19 2022, 5:41 AM
lib/utils/url-utils.js
35 ↗(On Diff #14391)

I think there is no special reason for that and it could be + signs as well. When we were discussing the solution in June I think we agreed to ,, but I can easily change it to + to make it more consistent with other URLs.

web/url-utils.js
126–131 ↗(On Diff #14391)

Thanks for catching

rebase & follow review comments

Looks good.

(Adding unit tests for infoFromURL(...) seems like it could be a quick thing?)

web/url-utils.js
59

We could be more explicit here with users.length > 0 instead of relying on truthiness but don't feel strongly, up to you

59

We could maybe rename this to something like potentiallyTrailingSlash so it still makes sense when it's set to the empty string?

117–120

could maybe do

const chatMode = urlInfo.threadCreation ? 'create' : 'view';

or something

tomek added inline comments.
lib/utils/url-utils.js
37 ↗(On Diff #14752)

Couls we modify the regex so that thread/new/++++ is not a valid one?

73 ↗(On Diff #14752)

With the current regex it is possible to have consecutive plus signs, so maybe a filter(Boolean) is a good idea? (Updating the regex should also suffice)

This revision is now accepted and ready to land.Jul 25 2022, 4:26 AM

modified regex so it support only non-empty IDs

lib/utils/url-utils.js
37 ↗(On Diff #14831)

Found out that wrapping + into square brackets [+] could be used instead of double escape: \\+

This revision is now accepted and ready to land.Jul 25 2022, 6:23 AM

Defer to other reviewers, but this looks good to me!

Agree with both of those conclusions!

We also agreed, that as a follow-up task it would be good to refactor the navigation to keep navigation state in more nested structure

We could create a new backlog task for this one.

Created follow-up task: https://linear.app/comm/issue/ENG-1458/refactor-navinfo-in-web-to-support-nested-navigation-structure