Stories/lists management for removed contact
This commit is contained in:
parent
7340ea64b9
commit
2601197888
3 changed files with 69 additions and 0 deletions
|
@ -965,6 +965,14 @@ export class ConversationModel extends window.Backbone
|
||||||
shouldSave: false,
|
shouldSave: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.reduxActions?.stories.removeAllContactStories(this.id);
|
||||||
|
const uuid = this.get('uuid');
|
||||||
|
if (uuid) {
|
||||||
|
window.reduxActions?.storyDistributionLists.removeMemberFromAllDistributionLists(
|
||||||
|
uuid
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Add notification
|
// Add notification
|
||||||
drop(this.queueJob('removeContact', () => this.maybeSetContactRemoved()));
|
drop(this.queueJob('removeContact', () => this.maybeSetContactRemoved()));
|
||||||
|
|
||||||
|
|
|
@ -1365,6 +1365,45 @@ function setStoriesDisabled(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeAllContactStories(
|
||||||
|
conversationId: string
|
||||||
|
): ThunkAction<void, RootStateType, unknown, NoopActionType> {
|
||||||
|
return async (dispatch, getState) => {
|
||||||
|
const logId = `removeAllContactStories(${conversationId})`;
|
||||||
|
const { stories } = getState().stories;
|
||||||
|
const messageIds = stories
|
||||||
|
.filter(item => item.conversationId === conversationId)
|
||||||
|
.map(({ messageId }) => messageId);
|
||||||
|
|
||||||
|
const messages = (
|
||||||
|
await Promise.all(
|
||||||
|
messageIds.map(async messageId => {
|
||||||
|
const message = await getMessageById(messageId);
|
||||||
|
|
||||||
|
if (!message) {
|
||||||
|
log.warn(`${logId}: no message found ${messageId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
).filter(isNotNil);
|
||||||
|
|
||||||
|
log.info(`${logId}: removing ${messages.length} stories`);
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
messages.map(m => m.cleanup()),
|
||||||
|
await dataInterface.removeMessages(messageIds),
|
||||||
|
]);
|
||||||
|
|
||||||
|
dispatch({
|
||||||
|
type: 'NOOP',
|
||||||
|
payload: null,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
deleteStoryForEveryone,
|
deleteStoryForEveryone,
|
||||||
loadStoryReplies,
|
loadStoryReplies,
|
||||||
|
@ -1386,6 +1425,7 @@ export const actions = {
|
||||||
setStoriesDisabled,
|
setStoriesDisabled,
|
||||||
setHasAllStoriesUnmuted,
|
setHasAllStoriesUnmuted,
|
||||||
setStorySending,
|
setStorySending,
|
||||||
|
removeAllContactStories,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useStoriesActions = (): BoundActionCreatorsMapObject<
|
export const useStoriesActions = (): BoundActionCreatorsMapObject<
|
||||||
|
|
|
@ -481,6 +481,26 @@ function updateStoryViewers(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeMemberFromAllDistributionLists(
|
||||||
|
member: UUIDStringType
|
||||||
|
): ThunkAction<void, RootStateType, null, ModifyListActionType> {
|
||||||
|
return async dispatch => {
|
||||||
|
const logId = `removeMemberFromAllDistributionLists(${member})`;
|
||||||
|
const lists = await dataInterface.getAllStoryDistributionsWithMembers();
|
||||||
|
|
||||||
|
const listsWithMember = lists.filter(({ members }) =>
|
||||||
|
members.includes(member)
|
||||||
|
);
|
||||||
|
log.info(
|
||||||
|
`${logId}: removing ${member} from ${listsWithMember.length} lists`
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const { id } of listsWithMember) {
|
||||||
|
dispatch(removeMembersFromDistributionList(id, [member]));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
allowsRepliesChanged,
|
allowsRepliesChanged,
|
||||||
createDistributionList,
|
createDistributionList,
|
||||||
|
@ -488,6 +508,7 @@ export const actions = {
|
||||||
hideMyStoriesFrom,
|
hideMyStoriesFrom,
|
||||||
modifyDistributionList,
|
modifyDistributionList,
|
||||||
removeMembersFromDistributionList,
|
removeMembersFromDistributionList,
|
||||||
|
removeMemberFromAllDistributionLists,
|
||||||
setMyStoriesToAllSignalConnections,
|
setMyStoriesToAllSignalConnections,
|
||||||
updateStoryViewers,
|
updateStoryViewers,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue