MM-62613 - remove scheduled messages on ws reconnect (#29875)
* remove scheduled messages on reconnect * loop over values * prune partial state and reload in team change * specifically define when to prune the data
Этот коммит содержится в:
@@ -240,7 +240,7 @@ export function reconnect() {
|
||||
}
|
||||
|
||||
dispatch(fetchAllMyTeamsChannels());
|
||||
dispatch(fetchTeamScheduledPosts(currentTeamId, true));
|
||||
dispatch(fetchTeamScheduledPosts(currentTeamId, true, true));
|
||||
dispatch(fetchAllMyChannelMembers());
|
||||
dispatch(fetchMyCategories(currentTeamId));
|
||||
loadProfilesForSidebar();
|
||||
|
||||
@@ -31,7 +31,7 @@ export function createSchedulePost(schedulePost: ScheduledPost, teamId: string,
|
||||
};
|
||||
}
|
||||
|
||||
export function fetchTeamScheduledPosts(teamId: string, includeDirectChannels: boolean) {
|
||||
export function fetchTeamScheduledPosts(teamId: string, includeDirectChannels: boolean, prune?: false) {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
let scheduledPosts;
|
||||
|
||||
@@ -41,6 +41,7 @@ export function fetchTeamScheduledPosts(teamId: string, includeDirectChannels: b
|
||||
type: ScheduledPostTypes.SCHEDULED_POSTS_RECEIVED,
|
||||
data: {
|
||||
scheduledPostsByTeamId: scheduledPosts.data,
|
||||
prune,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
@@ -175,8 +175,8 @@ function errorsByTeamId(state: ScheduledPostsState['errorsByTeamId'] = {}, actio
|
||||
function byChannelOrThreadId(state: ScheduledPostsState['byChannelOrThreadId'] = {}, action: MMReduxAction) {
|
||||
switch (action.type) {
|
||||
case ScheduledPostTypes.SCHEDULED_POSTS_RECEIVED: {
|
||||
const {scheduledPostsByTeamId} = action.data;
|
||||
const newState = {...state};
|
||||
const {scheduledPostsByTeamId, prune} = action.data;
|
||||
const newState = prune ? {} : {...state};
|
||||
|
||||
Object.keys(scheduledPostsByTeamId).forEach((teamId: string) => {
|
||||
if (Object.hasOwn(scheduledPostsByTeamId, teamId)) {
|
||||
|
||||
Ссылка в новой задаче
Block a user