Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

[MM-9698] Fix routes to have basic info before rendering channel_view #1352

Closed
wants to merge 1 commit into from

Conversation

sudheerDev
Copy link
Contributor

Summary

Fix routes to have basic info before rendering channel_view.
Fixes duplicate call of posts on route switch.

Ticket Link

Related Issue
Related ticket

present routes.

  • Channel Route: /channels/{channel_name}
  • GM Route: /messages/{group_id}
  • DM Route: /messages/@{username}
  • Fallback Route: /channels/{default_channel_name}

legacy routes for redirection.

  • /channels/{channel_id} -> Channel Route
  • /channels/{id1}__{id2} -> DM Route
  • /messages/{user_id} -> DM Route
  • /messages/{user_email} -> DM Route
  • /channels/{group_id} -> GM Route

Checklist

[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]

  • Ran make check-style to check for style errors (required for all pull requests)
  • Ran make test to ensure unit and component tests passed
  • Added or updated unit tests (required for all new features)
  • Has UI changes
  • Touches critical sections of the codebase (auth, posting, etc.)

@sudheerDev sudheerDev requested a review from hmhealey June 19, 2018 13:40
@sudheerDev sudheerDev added the Work in Progress Not yet ready for review label Jun 19, 2018
@sudheerDev
Copy link
Contributor Author

@hmhealey Hey i have merged channel and group routes to remove duplicate code. It would be great if you can give some initial feedback.

From ticket

The bugs that have come up for the issue have either been because the URL rewriting failed or the URL rewriting was done without actually changing the channel internally, so it would be nice to make sure that those are always done

I made sure that the respective channel is loaded and saved before changing the URl or loading the channel_view so we dont load a wrong channel or make duplicate requests.

Let me know your thoughs on it.

} else if (identifier.length === LENGTH_OF_GROUP_ID) {
return (
<ChannelAndGroupRoute
asGroup={true}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i will add asGroup default param to false

Copy link
Member

@hmhealey hmhealey left a comment

Choose a reason for hiding this comment

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

Ensuring the user/channel is loaded before switching looks good, but I'm not entirely sure how this will make testing easier since that was the main thing I was hoping out of from this ticket. It's a good start though

const groupName = identifier.toLowerCase();
basicViewInfo = ChannelStore.getByName(groupName);
if (!basicViewInfo) {
basicViewInfoResponse = await joinChannel(UserStore.getCurrentId(), TeamStore.getCurrentId(), null, groupName)(dispatch, getState);
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be a getChannel API call since you can't join a group channel after its been created

const {team, identifier} = this.props.match.params;
if (this.props.byName) {
const channelName = identifier.toLowerCase();
basicViewInfo = ChannelStore.getByName(channelName);
Copy link
Member

Choose a reason for hiding this comment

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

If you make the part of this that gets the channel from the store into a redux action, you'll be able to avoid using ChannelStore here. That action would look something like

import {getChannel} from 'mattermost-redux/selectors/channels';

function getChannelByIdentifier(identifier, identifierType) {
    return async (dispatch, getState) => {
        let channel;
        if (identifierType === 'name') {
            channel = getChannelByName(getState(), identifier);

            if (!channel) {
                response = await joinChannel(...);
            }
        }

        if (channel) {
            return {data: channel};
        } else {
            return response;
        }
    };
}

if (identifier.length === LENGTH_OF_ID) {
// It's hard to tell an ID apart from a channel name of the same length, so check first if
// the identifier matches a channel that we have
if (ChannelStore.getByName(identifier)) {
Copy link
Member

Choose a reason for hiding this comment

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

It would also be nice to avoid the ChannelStore here as well

const username = identifier.slice(1, identifier.length).toLowerCase();

if (this.props.byName) {
user = UserStore.getProfileByUsername(username);
Copy link
Member

Choose a reason for hiding this comment

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

Similar feedback to the ChannelGroupRoute here with suggestions on how to refactor this

@sudheerDev sudheerDev closed this Nov 6, 2018
@sudheerDev sudheerDev deleted the MM-9686 branch November 6, 2018 18:01
@lindalumitchell lindalumitchell added the Tests/Not Needed Does not require new release tests label Nov 7, 2018
hmhealey added a commit that referenced this pull request Mar 18, 2021
* Locations (#1258)

* Add support to plugin integrations the same way as mobile

* Add selector

* Filter integrations by location

* First approach to apps

* Fix location url

* Remove locations on 404

* Revert "Remove locations on 404"

This reverts commit 9bb01f9f439ea885c5b319c909bc1464d264a86f.

* Fix lint

* Address feedback, adapt to new calls prs and renaming

* Improve variable name

* Refactor

* Update with webapp PR requests

* add constant

* Fix lint and reference error

Co-authored-by: Michael Kochell <[email protected]>

* Updated apps types to reflect server changes (#1287)

* Updated apps types to reflect server changes

* fixed getAppBindings to return the children

* remove exclamation point

* updates for app modals (#1292)

Co-authored-by: Michael Kochell <[email protected]>

* Some fixes to sync with lev-clenaup branch on apps (#1297)

* description should be optional (#1302)

* updates for app commands (#1303)

change import order

* Merge master into feature cloud-apps branch (#1328)

* [MM-27556] Add sys console ancillary permissions and ability to exclude roles (#1242)

* Add sys console ancillary permissions and ability to exclude roles

* Update userIsNotAdminOrGuest to only apply to system admin and guest

* MM-28533

* MM-28532

* Rename userAccessTokensForUser to userAccessTokensByUser and fix the type (#1263)

* [MM-28218] Redux hooks for updating company info and address (#1259)

* [MM-28218] Redux hooks for updating company info and address

* Update type to make changed customer parameters optional

* Added user_actual_id to rudder page event (#1264)

* [MM-28214][MM-28216] Redux hooks for getting invoices (#1266)

* [MM-28214][MM-28216] Redux hooks for getting invoices

* Remove selector and add field for last invoice on Subscription

* Make last_invoice optional

* MM-29679 Add memoization to getCustomEmojis (#1260)

* Addition of filenames field in Post Component (#1261)

Co-authored-by: Vipul Kakkar <[email protected]>

* [MM-28214] Additional fields on the invoices (#1271)

* MM-27909: Add shared channel permission (#1246)

Adding the required constant to add the permission

* MM-22845 Fix quick switcher results (#1270)

* MM-22845 Fix quick switcher results
 * Change esiting searchprofiles selector to be searchProfilesStartingWithTerm
 * Add a new selector searchProfileMatchingWithTerm for substring mtaches

* FIx line formatting

* Abstract some filter code

* Change selectors to use memiosation

* improve memoisation

* Add feature flags to the admin config struct. (#1275)

* MM-29998 Add telemetry for in product notices (#1277)

* Add telemetry event notice_seen_NOTICEID

* MM-28833 Remove computed details from getChannel selector (#1257)

* MM-28833 Remove computed details from getChannel selector

* Update tests

* [MM-20481] Add 'link' as a possible PostEmbedType (#1272)

This is needed to finalize PR #6668
Server corresponding definition https://github.com/mattermost/mattermost-server/blob/a63684fcb5e3ba7b7522b35c29a4cb27779ba823/model/post_embed.go#L10

* [MM-20581] Update method signature for getGroupsAssociatedToChannel (#1281)

* MM-30090 Add ManagedResourcePaths setting (#1282)

* [MM-20581] Change `Groups` constant to `enum` (#1284)

* [MM-20581] Convert all redux constants to const

* Revert "[MM-20581] Convert all redux constants to const"

This reverts commit 5a2b5c3802bf8e8614358098e18fe63fba469aca.

* Rework to use enum

* MM-19509 Prioritize autocomplete results based on interactions and threads (#1279)

* MM-19509 Prioritize auto completer results based on interactions and threads

  * Add selector makeGetProfilesForThread for getting profiles for threds
  * Add selector makeAddLastViewAtToProfiles to add last_viewed_at for profiles if
    membership exists

* Update src/selectors/entities/posts.test.js

Co-authored-by: Harrison Healey <[email protected]>

* Change to use a get all channels instead if computed selector

* Capitalise ts def

Co-authored-by: Harrison Healey <[email protected]>
Co-authored-by: Mattermod <[email protected]>

* init commit (#1269)

* Fix ChannelModeration to be consistent with ChannelModerationRoles (#1291)

* add MANAGE_REMOTE_CLUSTERS permission (#1294)

Co-authored-by: Mattermod <[email protected]>

* DOPS-243 (#1299)

DOPS-243 (#1299)

* [MM-30158] Added method for moving multiple channels from any number of categories to one category. (#1295)

* [MM-30158] Added method for moving multiple channels from any number of categories to one category.

* Some extra test cases

* Fixed typos

* MM-20897 Add category muting (#1286)

* MM-20897 Add setCategoryMuted action

* Add constants for channel notify props

* MM-20897 Mute categories without waiting for websocket events

* Revert unintended change

* [MM-20423]: Update type. (#1298)

Co-authored-by: Mattermod <[email protected]>

* DOPS-243 (#1301)

DOPS-243 (#1301)

* MM-30087 Remove direct dependency between Client4 and Rudder (#1293)

* [MM-27927] - Add user preference for limit on dms and gms (#1300)

* [MM-27927] - Add user preference for limit on dms and gms

* Fix failing tests

* fix wrong preference naming

* Add tests and fix selector

* Resolve PR comments

* Fix tests

* call limit pref directly

Co-authored-by: Nevyana Angelova <[email protected]>
Co-authored-by: Nevyana Angelova <[email protected]>

* [MM-20400] Add IsDefaultMarketplace to ClientConfig (#1304)

* Add IsDefaultMarketplace to ClientConfig

* Add MarketplaceLabel

* Update MarketplacePlugin

* Empty commit

* Correctly mark optional fields

* [MM-30981] Require Plugin name in manifest (#1306)

* editor config trim trailing whitespace (#1307)

* Fix createComplianceReport action parameter type (#1289)

* add fields to config.ts (#1285)

Co-authored-by: Mattermod <[email protected]>

* Update isomorphic-fetch to 3.0.0 and make it a dev dependency (#1308)

Co-authored-by: Stefan Bley <[email protected]>

* Revert "[MM-27927] - Add user preference for limit on dms and gms (#1300)" (#1315)

This reverts commit aa69940.

Co-authored-by: Mattermod <[email protected]>

* [MM-31053] Optimistically update category order (#1314)

* Update eslint-plugin-mattermost (#1318)

* Update eslint-plugin-mattermost

* Fix cache (#1319)

Co-authored-by: Elisabeth Kulzer <[email protected]>

* [MM-30982] Add filter metadata to Marketplace response (#1309)

* Add filter metadata to Marketplace response

* Add metadata from mattermost/mattermost-marketplace#145

* [MM-31329] Enable @typescript-eslint/array-type (#1320)

* Add `message_source` field to `Post` type (#1321)

* add new anciliary permissions (#1325)

* MM-30443 Add shouldShowUnreadsCategory selector for new sidebar (#1326)

* Fix lint

Co-authored-by: Farhan Munshi <[email protected]>
Co-authored-by: Devin Binnie <[email protected]>
Co-authored-by: Maria A Nunez <[email protected]>
Co-authored-by: Harrison Healey <[email protected]>
Co-authored-by: Vipul Kakkar <[email protected]>
Co-authored-by: Vipul Kakkar <[email protected]>
Co-authored-by: Agniva De Sarker <[email protected]>
Co-authored-by: Sudheer <[email protected]>
Co-authored-by: Christopher Speller <[email protected]>
Co-authored-by: Nicolas Le Cam <[email protected]>
Co-authored-by: Mattermod <[email protected]>
Co-authored-by: Hossein Ahmadian-Yazdi <[email protected]>
Co-authored-by: Clément Collin <[email protected]>
Co-authored-by: Ibrahim Serdar Acikgoz <[email protected]>
Co-authored-by: Elisabeth Kulzer <[email protected]>
Co-authored-by: dizkek <[email protected]>
Co-authored-by: Nev Angelova <[email protected]>
Co-authored-by: Nevyana Angelova <[email protected]>
Co-authored-by: Nevyana Angelova <[email protected]>
Co-authored-by: Ben Schumacher <[email protected]>
Co-authored-by: Caleb Roseland <[email protected]>
Co-authored-by: Daniel Shuy <[email protected]>
Co-authored-by: Scott Bishel <[email protected]>
Co-authored-by: Stefan Bley <[email protected]>
Co-authored-by: Stefan Bley <[email protected]>
Co-authored-by: Guillermo Vayá <[email protected]>

* update types for dynamic modals (#1322)

* update types for dynamic modals

* Add AppFormValue and AppFormValues

* add fields to support opening modals and refreshing

* move presentation field from call to binding

* remove source_url, and make select value be an object instead of string

* add binding presentation

* add makeLookupCallPayload()

* remove presentation, rename type

* remove unused imports

* correct and update expand levels (#1341)

* [MM-32476] Apps in the Marketplace (#1352)

* Fix linter errors on feature/cloud-apps (#1371)

* Fix linter errors on feature/cloud-apps

* Include feedback

* [MM-31508] Rename URL to Path in Call (#1370)

* Add User Agent to call context (#1379)

* Add warning into code about using apps related code (#1380)

* Add warning into code about using apps related code

* Improve wording

* Change user agent property in get bindings query (#1388)

* [MM-33511] Apps might not have a RootURL (#1394)

* Change call type submit and call response ok to not be empty strings (#1391)

* Add binding validation on fetch bindings (#1381)

* Add binding validation on fetch bindings

* Fix lint

* Add documentation and rename fillandtrim

* Use call type on the path (#1406)

Co-authored-by: Michael Kochell <[email protected]>

* Temporarily re-add types that were moved or renamed

Co-authored-by: Daniel Espino García <[email protected]>
Co-authored-by: Michael Kochell <[email protected]>
Co-authored-by: Lev <[email protected]>
Co-authored-by: Jason Frerich <[email protected]>
Co-authored-by: Farhan Munshi <[email protected]>
Co-authored-by: Devin Binnie <[email protected]>
Co-authored-by: Maria A Nunez <[email protected]>
Co-authored-by: Vipul Kakkar <[email protected]>
Co-authored-by: Vipul Kakkar <[email protected]>
Co-authored-by: Agniva De Sarker <[email protected]>
Co-authored-by: Sudheer <[email protected]>
Co-authored-by: Christopher Speller <[email protected]>
Co-authored-by: Nicolas Le Cam <[email protected]>
Co-authored-by: Mattermod <[email protected]>
Co-authored-by: Hossein Ahmadian-Yazdi <[email protected]>
Co-authored-by: Clément Collin <[email protected]>
Co-authored-by: Ibrahim Serdar Acikgoz <[email protected]>
Co-authored-by: Elisabeth Kulzer <[email protected]>
Co-authored-by: dizkek <[email protected]>
Co-authored-by: Nev Angelova <[email protected]>
Co-authored-by: Nevyana Angelova <[email protected]>
Co-authored-by: Nevyana Angelova <[email protected]>
Co-authored-by: Ben Schumacher <[email protected]>
Co-authored-by: Caleb Roseland <[email protected]>
Co-authored-by: Daniel Shuy <[email protected]>
Co-authored-by: Scott Bishel <[email protected]>
Co-authored-by: Stefan Bley <[email protected]>
Co-authored-by: Stefan Bley <[email protected]>
Co-authored-by: Guillermo Vayá <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Tests/Not Needed Does not require new release tests Work in Progress Not yet ready for review
Projects
None yet
3 participants