A few Delete For Everyone fixes

Co-authored-by: Sidney Keese <sidney@carbonfive.com>
This commit is contained in:
Chris Svenningsen 2020-10-08 15:26:57 -07:00 committed by Josh Perez
parent 0122cfd22a
commit 492bb283ee
2 changed files with 11 additions and 7 deletions

View file

@ -959,7 +959,7 @@
"description": "Text shown in the confirmation dialog for deleting a message locally" "description": "Text shown in the confirmation dialog for deleting a message locally"
}, },
"deleteForEveryoneWarning": { "deleteForEveryoneWarning": {
"message": "This message will be permanently deleted for everyone in the conversation. Members will be able to see that you deleted a message.", "message": "This message will be deleted for everyone in the conversation if theyre on a recent version of Signal. They will be able to see that you deleted a message.",
"description": "Text shown in the confirmation dialog for deleting a message for everyone" "description": "Text shown in the confirmation dialog for deleting a message for everyone"
}, },
"deleteThisMessage": { "deleteThisMessage": {

View file

@ -237,8 +237,6 @@ export class Message extends React.PureComponent<Props, State> {
public constructor(props: Props) { public constructor(props: Props) {
super(props); super(props);
const { canDeleteForEveryone } = props;
this.wideMl = window.matchMedia('(min-width: 926px)'); this.wideMl = window.matchMedia('(min-width: 926px)');
this.wideMl.addEventListener('change', this.handleWideMlChange); this.wideMl.addEventListener('change', this.handleWideMlChange);
@ -256,14 +254,20 @@ export class Message extends React.PureComponent<Props, State> {
isWide: this.wideMl.matches, isWide: this.wideMl.matches,
containerWidth: 0, containerWidth: 0,
canDeleteForEveryone, canDeleteForEveryone: props.canDeleteForEveryone,
}; };
} }
public static getDerivedStateFromProps(props: Props, state: State): State { public static getDerivedStateFromProps(props: Props, state: State): State {
const newState = {
...state,
canDeleteForEveryone:
props.canDeleteForEveryone && state.canDeleteForEveryone,
};
if (!props.isSelected) { if (!props.isSelected) {
return { return {
...state, ...newState,
isSelected: false, isSelected: false,
prevSelectedCounter: 0, prevSelectedCounter: 0,
}; };
@ -274,13 +278,13 @@ export class Message extends React.PureComponent<Props, State> {
props.isSelectedCounter !== state.prevSelectedCounter props.isSelectedCounter !== state.prevSelectedCounter
) { ) {
return { return {
...state, ...newState,
isSelected: props.isSelected, isSelected: props.isSelected,
prevSelectedCounter: props.isSelectedCounter, prevSelectedCounter: props.isSelectedCounter,
}; };
} }
return state; return newState;
} }
public handleWideMlChange = (event: MediaQueryListEvent): void => { public handleWideMlChange = (event: MediaQueryListEvent): void => {