Mattermost-server: Removal of unused status flags in Preferences requests state object

Created on 1 Oct 2019  路  5Comments  路  Source: mattermost/mattermost-server

Remove unused status flags from https://github.com/mattermost/mattermost-redux/blob/master/src/reducers/requests/preferences.js

We have a pattern to track API requests success, failure and progress states by making respective redux actions like


export function getRolesByNames(rolesNames: Array<string>) {
    return bindClientFunc({
        clientFunc: Client4.getRolesByNames,
        onRequest: RoleTypes.ROLES*BY_NAMES*REQUEST,
        onSuccess: <RoleTypes.RECEIVED*ROLES, RoleTypes.ROLES_BY_NAMES*SUCCESS],
        onFailure: RoleTypes.ROLES*BY_NAMES*FAILURE,
        params: [
            rolesNames,
        >,
    });
}

which modify the redux state of requests object


export default (combineReducers({
    getRolesByNames,
    getRoleByName,
    getRole,
    editRole,
}): (RolesRequestsStatuses, GenericAction) => RolesRequestsStatuses);

Most of these state objects are not needed because we don't consume them either in webapp or in mobile app repo.

The proposed solution is to remove any dispatches with success, failure or progress along with the reducer and initial state entity by checking their dependency in both webapp and mobile app repos.

If the redux state for the request is used only in one component we can use react state instead of redux so, we can remove the entity

PR's for reference:
Redux PR: https://github.com/mattermost/mattermost-redux/pull/748
Mobile PR: https://github.com/mattermost/mattermost-mobile/pull/2490
Web PR: https://github.com/mattermost/mattermost-mobile/pull/2496


If you're interested please comment here and come join our "Contributors" community channel on our daily build server, where you can discuss questions with community members and the Mattermost core team. For technical advice or questions, please join our "Developers" community channel.

New contributors please see our Developer's Guide.

JIRA: https://mattermost.atlassian.net/browse/MM-18901

AreTechnical Debt Easy Help Wanted TecRedux

All 5 comments

Can I work on this?

@atulya-pandey Hey, How is this going? Is there anything i can help you with? Fell free to mention me if you need any help with the issue.

Hi @sudheerDev , Thanks for asking. I am working on this issue. If I have any questions, I will reach out to you.

Hi @sudheerDev , I checked the dependencies of status flags of preferences.ts file and non of them are being used in webapp and mobile app. Should I remove the complete file?

@atulya-pandey Yes, i cross checked we are not using them. You can go ahead and remove the file and the corresponding dispatches as well.

Was this page helpful?
0 / 5 - 0 ratings