fix: show dialog before deleting group
also deal with leave/delete group silent retries on 401pull/3281/head
parent
8c41db515e
commit
a8372f1b8c
@ -1,42 +1,53 @@
|
|||||||
function sharedEnabled({
|
function sharedEnabled({
|
||||||
isGroup,
|
isGroup,
|
||||||
|
isPublic,
|
||||||
isMessageRequestShown,
|
isMessageRequestShown,
|
||||||
}: Pick<Parameters<typeof showLeaveGroupItem>[0], 'isGroup' | 'isMessageRequestShown'>) {
|
}: Pick<
|
||||||
return isGroup && !isMessageRequestShown;
|
Parameters<typeof showLeaveGroupItem>[0],
|
||||||
|
'isGroup' | 'isMessageRequestShown' | 'isPublic'
|
||||||
|
>) {
|
||||||
|
return isGroup && !isMessageRequestShown && !isPublic;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* We can try leave a group if
|
||||||
|
* - we are an admin of the group (that group would be marked as destroyed on delete)
|
||||||
|
* and
|
||||||
|
* - we are a **not kicked** member (if we are kicked without knowing about it and try to leave, we will silently remove the group)
|
||||||
|
*
|
||||||
|
* Note: Those actions are hidden if the group is a group request (as we have other buttons to accept/decline a group request).
|
||||||
|
*
|
||||||
|
* Note: If we fail to leave the group but that error is retryable, we will keep the group displaying the "leave" option.
|
||||||
|
*/
|
||||||
export function showLeaveGroupItem({
|
export function showLeaveGroupItem({
|
||||||
isGroup,
|
isGroup,
|
||||||
|
isPublic,
|
||||||
isKickedFromGroup,
|
isKickedFromGroup,
|
||||||
isMessageRequestShown,
|
isMessageRequestShown,
|
||||||
lastMessageIsLeaveError,
|
isGroupDestroyed,
|
||||||
}: {
|
}: {
|
||||||
isGroup: boolean;
|
isGroup: boolean;
|
||||||
|
isPublic: boolean;
|
||||||
isMessageRequestShown: boolean;
|
isMessageRequestShown: boolean;
|
||||||
lastMessageIsLeaveError: boolean;
|
|
||||||
isKickedFromGroup: boolean;
|
isKickedFromGroup: boolean;
|
||||||
|
isGroupDestroyed: boolean;
|
||||||
}) {
|
}) {
|
||||||
// we can't try to leave the group if we were kicked from it, or if we've already tried to (lastMessageIsLeaveError is true)
|
|
||||||
return (
|
return (
|
||||||
sharedEnabled({ isGroup, isMessageRequestShown }) &&
|
sharedEnabled({ isGroup, isMessageRequestShown, isPublic }) &&
|
||||||
!isKickedFromGroup &&
|
!isKickedFromGroup &&
|
||||||
!lastMessageIsLeaveError
|
!isGroupDestroyed
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function showDeleteGroupItem({
|
/**
|
||||||
isGroup,
|
* We can try to delete a group only if the `showLeaveGroupItem` returns false.
|
||||||
isKickedFromGroup,
|
* Note: those actions are hidden if the group is a group request (as we have other buttons to accept/decline a group request)
|
||||||
isMessageRequestShown,
|
*/
|
||||||
lastMessageIsLeaveError,
|
export function showDeleteGroupItem(args: {
|
||||||
}: {
|
|
||||||
isGroup: boolean;
|
isGroup: boolean;
|
||||||
|
isPublic: boolean;
|
||||||
isMessageRequestShown: boolean;
|
isMessageRequestShown: boolean;
|
||||||
lastMessageIsLeaveError: boolean;
|
|
||||||
isKickedFromGroup: boolean;
|
isKickedFromGroup: boolean;
|
||||||
|
isGroupDestroyed: boolean;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return sharedEnabled(args) && !showLeaveGroupItem(args);
|
||||||
sharedEnabled({ isGroup, isMessageRequestShown }) &&
|
|
||||||
(isKickedFromGroup || lastMessageIsLeaveError)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue