Commit 625adf07 authored by Nev Angelova's avatar Nev Angelova Committed by Harrison Healey
Browse files

[MM-26023] - Add Category related websocket actions (#5924)



* WIP [MM-26023] - Add Category related websocket actions

* pick dc321d9 MM-24914 Attach sidebar logic to server (#1177)
add category ids to category updated event

* MM-26023 Add proper handling for sidebar websocket events

* Switch mattermost-redux to PR branch

* Update mattermost-redux to master

* Fix mattermost-redux commit
Co-authored-by: default avatarNevyana Angelova <nevyangelova@Nevyanas-MacBook-Pro-2.local>
Co-authored-by: default avatarHarrison Healey <harrisonmhealey@gmail.com>
parent 4776c093
...@@ -16,7 +16,7 @@ import { ...@@ -16,7 +16,7 @@ import {
PreferenceTypes, PreferenceTypes,
} from 'mattermost-redux/action_types'; } from 'mattermost-redux/action_types';
import {WebsocketEvents, General, Permissions} from 'mattermost-redux/constants'; import {WebsocketEvents, General, Permissions} from 'mattermost-redux/constants';
import {addChannelToInitialCategory} from 'mattermost-redux/actions/channel_categories'; import {addChannelToInitialCategory, fetchMyCategories, receivedCategoryOrder} from 'mattermost-redux/actions/channel_categories';
import { import {
getChannelAndMyMember, getChannelAndMyMember,
getMyChannelMember, getMyChannelMember,
...@@ -457,6 +457,22 @@ export function handleEvent(msg) { ...@@ -457,6 +457,22 @@ export function handleEvent(msg) {
handleWarnMetricStatusRemovedEvent(msg); handleWarnMetricStatusRemovedEvent(msg);
break; break;
case SocketEvents.SIDEBAR_CATEGORY_CREATED:
dispatch(handleSidebarCategoryCreated(msg));
break;
case SocketEvents.SIDEBAR_CATEGORY_UPDATED:
dispatch(handleSidebarCategoryUpdated(msg));
break;
case SocketEvents.SIDEBAR_CATEGORY_DELETED:
dispatch(handleSidebarCategoryDeleted(msg));
break;
case SocketEvents.SIDEBAR_CATEGORY_ORDER_UPDATED:
dispatch(handleSidebarCategoryOrderUpdated(msg));
break;
default: default:
} }
...@@ -1245,3 +1261,50 @@ function handleWarnMetricStatusReceivedEvent(msg) { ...@@ -1245,3 +1261,50 @@ function handleWarnMetricStatusReceivedEvent(msg) {
function handleWarnMetricStatusRemovedEvent(msg) { function handleWarnMetricStatusRemovedEvent(msg) {
store.dispatch({type: GeneralTypes.WARN_METRIC_STATUS_REMOVED, data: {id: msg.data.warnMetricId}}); store.dispatch({type: GeneralTypes.WARN_METRIC_STATUS_REMOVED, data: {id: msg.data.warnMetricId}});
} }
function handleSidebarCategoryCreated(msg) {
return (doDispatch, doGetState) => {
const state = doGetState();
if (msg.broadcast.team_id !== getCurrentTeamId(state)) {
// The new category will be loaded when we switch teams.
return;
}
// Fetch all categories, including ones that weren't explicitly updated, in case any other categories had channels
// moved out of them.
doDispatch(fetchMyCategories(msg.broadcast.team_id));
};
}
function handleSidebarCategoryUpdated(msg) {
return (doDispatch, doGetState) => {
const state = doGetState();
if (msg.broadcast.team_id !== getCurrentTeamId(state)) {
// The updated categories will be loaded when we switch teams.
return;
}
// Fetch all categories in case any other categories had channels moved out of them.
doDispatch(fetchMyCategories(msg.broadcast.team_id));
};
}
function handleSidebarCategoryDeleted(msg) {
return (doDispatch, doGetState) => {
const state = doGetState();
if (msg.broadcast.team_id !== getCurrentTeamId(state)) {
// The category will be removed when we switch teams.
return;
}
// Fetch all categories since any channels that were in the deleted category were moved to other categories.
doDispatch(fetchMyCategories(msg.broadcast.team_id));
};
}
function handleSidebarCategoryOrderUpdated(msg) {
return receivedCategoryOrder(msg.broadcast.team_id, msg.data.order);
}
...@@ -13301,7 +13301,10 @@ ...@@ -13301,7 +13301,10 @@
"version": "1.3.1", "version": "1.3.1",
"resolved": "https://registry.npmjs.org/full-icu/-/full-icu-1.3.1.tgz", "resolved": "https://registry.npmjs.org/full-icu/-/full-icu-1.3.1.tgz",
"integrity": "sha512-VMtK//85QJomhk3cXOCksNwOYaw1KWnYTS37GYGgyf7A3ajdBoPGhaJuJWAH2S2kq8GZeXkdKn+3Mfmgy11cVw==", "integrity": "sha512-VMtK//85QJomhk3cXOCksNwOYaw1KWnYTS37GYGgyf7A3ajdBoPGhaJuJWAH2S2kq8GZeXkdKn+3Mfmgy11cVw==",
"dev": true "dev": true,
"requires": {
"icu4c-data": "0.63.2"
}
}, },
"function-bind": { "function-bind": {
"version": "1.1.1", "version": "1.1.1",
...@@ -14313,6 +14316,12 @@ ...@@ -14313,6 +14316,12 @@
"postcss": "^7.0.14" "postcss": "^7.0.14"
} }
}, },
"icu4c-data": {
"version": "0.63.2",
"resolved": "https://registry.npmjs.org/icu4c-data/-/icu4c-data-0.63.2.tgz",
"integrity": "sha512-vT6/47CcBzDemlhRzkL7dZLoNvuUWjjiuKZHMt5T4dbkKAqLBh7ZQ33GU13ecC/aIcMlIdBOqtF4uIYTgWML4Q==",
"dev": true
},
"identity-obj-proxy": { "identity-obj-proxy": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/identity-obj-proxy/-/identity-obj-proxy-3.0.0.tgz", "resolved": "https://registry.npmjs.org/identity-obj-proxy/-/identity-obj-proxy-3.0.0.tgz",
...@@ -15038,7 +15047,7 @@ ...@@ -15038,7 +15047,7 @@
}, },
"into-stream": { "into-stream": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "http://registry.npmjs.org/into-stream/-/into-stream-3.1.0.tgz", "resolved": "https://registry.npmjs.org/into-stream/-/into-stream-3.1.0.tgz",
"integrity": "sha1-lvsKk2wSur1v8XUqF9BWFqvQlMY=", "integrity": "sha1-lvsKk2wSur1v8XUqF9BWFqvQlMY=",
"dev": true, "dev": true,
"optional": true, "optional": true,
...@@ -18109,8 +18118,8 @@ ...@@ -18109,8 +18118,8 @@
"integrity": "sha512-6qE4B9deFBIa9YSpOc9O0Sgc43zTeVYbgDT5veRKSlB2+ZuHNoVVxA1L/ckMUayV9Ay9y7Z/SZCLcGteW9i7bg==" "integrity": "sha512-6qE4B9deFBIa9YSpOc9O0Sgc43zTeVYbgDT5veRKSlB2+ZuHNoVVxA1L/ckMUayV9Ay9y7Z/SZCLcGteW9i7bg=="
}, },
"mattermost-redux": { "mattermost-redux": {
"version": "github:mattermost/mattermost-redux#d39679ad4df4d76b684dbfffffcd9737ec94ea92", "version": "github:mattermost/mattermost-redux#422f46b16b3f4b0a9e6acada344c2404aa634e53",
"from": "github:mattermost/mattermost-redux#d39679ad4df4d76b684dbfffffcd9737ec94ea92", "from": "github:mattermost/mattermost-redux#422f46b16b3f4b0a9e6acada344c2404aa634e53",
"requires": { "requires": {
"core-js": "3.6.4", "core-js": "3.6.4",
"form-data": "3.0.0", "form-data": "3.0.0",
...@@ -26693,4 +26702,4 @@ ...@@ -26693,4 +26702,4 @@
"integrity": "sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ==" "integrity": "sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ=="
} }
} }
} }
\ No newline at end of file
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
"localforage-observable": "2.0.1", "localforage-observable": "2.0.1",
"mark.js": "8.11.1", "mark.js": "8.11.1",
"marked": "github:mattermost/marked#87769262aa02e1784570f61f4f962050e07cc335", "marked": "github:mattermost/marked#87769262aa02e1784570f61f4f962050e07cc335",
"mattermost-redux": "github:mattermost/mattermost-redux#d39679ad4df4d76b684dbfffffcd9737ec94ea92", "mattermost-redux": "github:mattermost/mattermost-redux#422f46b16b3f4b0a9e6acada344c2404aa634e53",
"moment-timezone": "0.5.31", "moment-timezone": "0.5.31",
"p-queue": "^6.4.0", "p-queue": "^6.4.0",
"pdfjs-dist": "2.0.489", "pdfjs-dist": "2.0.489",
...@@ -243,4 +243,4 @@ ...@@ -243,4 +243,4 @@
"build-storybook": "build-storybook -s ./storybook/static", "build-storybook": "build-storybook -s ./storybook/static",
"check-types": "tsc" "check-types": "tsc"
} }
} }
\ No newline at end of file
...@@ -361,6 +361,10 @@ export const SocketEvents = { ...@@ -361,6 +361,10 @@ export const SocketEvents = {
RECEIVED_GROUP_NOT_ASSOCIATED_TO_CHANNEL: 'received_group_not_associated_to_channel', RECEIVED_GROUP_NOT_ASSOCIATED_TO_CHANNEL: 'received_group_not_associated_to_channel',
WARN_METRIC_STATUS_RECEIVED: 'warn_metric_status_received', WARN_METRIC_STATUS_RECEIVED: 'warn_metric_status_received',
WARN_METRIC_STATUS_REMOVED: 'warn_metric_status_removed', WARN_METRIC_STATUS_REMOVED: 'warn_metric_status_removed',
SIDEBAR_CATEGORY_CREATED: 'sidebar_category_created',
SIDEBAR_CATEGORY_UPDATED: 'sidebar_category_updated',
SIDEBAR_CATEGORY_DELETED: 'sidebar_category_deleted',
SIDEBAR_CATEGORY_ORDER_UPDATED: 'sidebar_category_order_updated',
}; };
export const TutorialSteps = { export const TutorialSteps = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment