Skip to content

Commit

Permalink
[lib] Add staff-only alert for when notifsSessionReassignmentPromise …
Browse files Browse the repository at this point in the history
…reassigns a notif session

Summary: https://linear.app/comm/issue/ENG-9935/staff-only-alert-for-when-notifssessionreassignmentpromise-reassigns-a

Test Plan: Login on Safari

Reviewers: kamil, tomek

Reviewed By: kamil

Subscribers: ashoat

Differential Revision: https://phab.comm.dev/D13953
  • Loading branch information
graszka22 committed Nov 19, 2024
1 parent 7a60852 commit e39c5d3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/keyserver-conn/keyserver-connection-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '../selectors/keyserver-selectors.js';
import { isLoggedInToKeyserver } from '../selectors/user-selectors.js';
import { useInitialNotificationsEncryptedMessage } from '../shared/crypto-utils.js';
import { useStaffAlert } from '../shared/staff-utils.js';
import type { BaseSocketProps } from '../socket/socket.react.js';
import {
logInActionSources,
Expand Down Expand Up @@ -50,6 +51,8 @@ function KeyserverConnectionHandler(props: Props) {
const prevCookieRef = React.useRef(cookie);
const notifsSessionReassignmentPromise = React.useRef<?Promise<mixed>>(null);

const { showAlertToStaff } = useStaffAlert();

React.useEffect(() => {
const prevCookie = prevCookieRef.current;
prevCookieRef.current = cookie;
Expand All @@ -58,6 +61,13 @@ function KeyserverConnectionHandler(props: Props) {
return;
}

if (prevCookie) {
showAlertToStaff(
'Reassigning a notif session',
`prevCookie=${prevCookie} cookie=${cookie}`,
);
}

notifsSessionReassignmentPromise.current = (async () => {
await notifsSessionReassignmentPromise.current;
await olmAPI.reassignNotificationsSession?.(
Expand All @@ -66,7 +76,7 @@ function KeyserverConnectionHandler(props: Props) {
keyserverID,
);
})();
}, [cookie, keyserverID, olmAPI]);
}, [cookie, keyserverID, olmAPI, showAlertToStaff]);

const dataLoaded = useSelector(state => state.dataLoaded);

Expand Down

0 comments on commit e39c5d3

Please sign in to comment.