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(fetchAllMyTeamsChannels());
|
||||||
dispatch(fetchTeamScheduledPosts(currentTeamId, true));
|
dispatch(fetchTeamScheduledPosts(currentTeamId, true, true));
|
||||||
dispatch(fetchAllMyChannelMembers());
|
dispatch(fetchAllMyChannelMembers());
|
||||||
dispatch(fetchMyCategories(currentTeamId));
|
dispatch(fetchMyCategories(currentTeamId));
|
||||||
loadProfilesForSidebar();
|
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) => {
|
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||||
let scheduledPosts;
|
let scheduledPosts;
|
||||||
|
|
||||||
@@ -41,6 +41,7 @@ export function fetchTeamScheduledPosts(teamId: string, includeDirectChannels: b
|
|||||||
type: ScheduledPostTypes.SCHEDULED_POSTS_RECEIVED,
|
type: ScheduledPostTypes.SCHEDULED_POSTS_RECEIVED,
|
||||||
data: {
|
data: {
|
||||||
scheduledPostsByTeamId: scheduledPosts.data,
|
scheduledPostsByTeamId: scheduledPosts.data,
|
||||||
|
prune,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -175,8 +175,8 @@ function errorsByTeamId(state: ScheduledPostsState['errorsByTeamId'] = {}, actio
|
|||||||
function byChannelOrThreadId(state: ScheduledPostsState['byChannelOrThreadId'] = {}, action: MMReduxAction) {
|
function byChannelOrThreadId(state: ScheduledPostsState['byChannelOrThreadId'] = {}, action: MMReduxAction) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case ScheduledPostTypes.SCHEDULED_POSTS_RECEIVED: {
|
case ScheduledPostTypes.SCHEDULED_POSTS_RECEIVED: {
|
||||||
const {scheduledPostsByTeamId} = action.data;
|
const {scheduledPostsByTeamId, prune} = action.data;
|
||||||
const newState = {...state};
|
const newState = prune ? {} : {...state};
|
||||||
|
|
||||||
Object.keys(scheduledPostsByTeamId).forEach((teamId: string) => {
|
Object.keys(scheduledPostsByTeamId).forEach((teamId: string) => {
|
||||||
if (Object.hasOwn(scheduledPostsByTeamId, teamId)) {
|
if (Object.hasOwn(scheduledPostsByTeamId, teamId)) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user