2021-02-18 08:40:26 -08:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-10-26 14:15:33 -05:00
|
|
|
import type { ReactElement } from 'react';
|
|
|
|
import React, { useCallback, useState } from 'react';
|
2021-02-18 08:40:26 -08:00
|
|
|
|
2021-10-26 14:15:33 -05:00
|
|
|
import type { LocalizerType } from '../../types/Util';
|
2021-02-18 08:40:26 -08:00
|
|
|
|
2021-08-26 16:51:55 -04:00
|
|
|
import { Button, ButtonSize, ButtonVariant } from '../Button';
|
2021-09-07 14:55:03 -05:00
|
|
|
import { SystemMessage } from './SystemMessage';
|
2021-02-18 08:40:26 -08:00
|
|
|
import { ChatSessionRefreshedDialog } from './ChatSessionRefreshedDialog';
|
2022-12-20 19:25:10 -08:00
|
|
|
import { openLinkInWebBrowser } from '../../util/openLinkInWebBrowser';
|
|
|
|
import { mapToSupportLocale } from '../../util/mapToSupportLocale';
|
2021-02-18 08:40:26 -08:00
|
|
|
|
|
|
|
type PropsHousekeepingType = {
|
|
|
|
i18n: LocalizerType;
|
|
|
|
};
|
|
|
|
|
2022-12-20 19:25:10 -08:00
|
|
|
export type PropsType = PropsHousekeepingType;
|
2021-02-18 08:40:26 -08:00
|
|
|
|
|
|
|
export function ChatSessionRefreshedNotification(
|
|
|
|
props: PropsType
|
|
|
|
): ReactElement {
|
2022-12-20 19:25:10 -08:00
|
|
|
const { i18n } = props;
|
2021-02-18 08:40:26 -08:00
|
|
|
const [isDialogOpen, setIsDialogOpen] = useState<boolean>(false);
|
|
|
|
|
|
|
|
const openDialog = useCallback(() => {
|
|
|
|
setIsDialogOpen(true);
|
|
|
|
}, [setIsDialogOpen]);
|
|
|
|
const closeDialog = useCallback(() => {
|
|
|
|
setIsDialogOpen(false);
|
|
|
|
}, [setIsDialogOpen]);
|
|
|
|
|
|
|
|
const wrappedContactSupport = useCallback(() => {
|
|
|
|
setIsDialogOpen(false);
|
2022-12-20 19:25:10 -08:00
|
|
|
|
|
|
|
const baseUrl =
|
|
|
|
'https://support.signal.org/hc/LOCALE/requests/new?desktop&chat_refreshed';
|
2023-08-07 13:28:09 -07:00
|
|
|
const locale = window.SignalContext.getResolvedMessagesLocale();
|
2022-12-20 19:25:10 -08:00
|
|
|
const supportLocale = mapToSupportLocale(locale);
|
|
|
|
const url = baseUrl.replace('LOCALE', supportLocale);
|
|
|
|
|
|
|
|
openLinkInWebBrowser(url);
|
|
|
|
}, [setIsDialogOpen]);
|
2021-02-18 08:40:26 -08:00
|
|
|
|
|
|
|
return (
|
2021-09-07 14:55:03 -05:00
|
|
|
<>
|
|
|
|
<SystemMessage
|
2023-03-29 17:03:25 -07:00
|
|
|
contents={i18n('icu:ChatRefresh--notification')}
|
2021-09-07 14:55:03 -05:00
|
|
|
button={
|
|
|
|
<Button
|
|
|
|
onClick={openDialog}
|
|
|
|
size={ButtonSize.Small}
|
|
|
|
variant={ButtonVariant.SystemMessage}
|
|
|
|
>
|
2023-03-29 17:03:25 -07:00
|
|
|
{i18n('icu:ChatRefresh--learnMore')}
|
2021-09-07 14:55:03 -05:00
|
|
|
</Button>
|
|
|
|
}
|
|
|
|
icon="session-refresh"
|
|
|
|
/>
|
2021-02-18 08:40:26 -08:00
|
|
|
{isDialogOpen ? (
|
2021-05-28 12:11:19 -07:00
|
|
|
<ChatSessionRefreshedDialog
|
|
|
|
onClose={closeDialog}
|
|
|
|
contactSupport={wrappedContactSupport}
|
|
|
|
i18n={i18n}
|
|
|
|
/>
|
2021-02-18 08:40:26 -08:00
|
|
|
) : null}
|
2021-09-07 14:55:03 -05:00
|
|
|
</>
|
2021-02-18 08:40:26 -08:00
|
|
|
);
|
|
|
|
}
|