mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
* trigger `UnableToSyncModal` on refresh * trigger `UnableToSyncModal` without refresh * show success toast when offline edits sync * always show out of sync modal as the final backup GitOrigin-RevId: 3ed300fef9e6d2ff81e17868309f80ffa40e0576
35 lines
839 B
TypeScript
35 lines
839 B
TypeScript
import { useTranslation } from 'react-i18next'
|
|
import { GlobalToastGeneratorEntry } from '@/features/ide-react/components/global-toasts'
|
|
|
|
const CONNECTION_RESTORED_TOAST_HANDLE = 'connection-restored'
|
|
|
|
const ConnectionRestoredToastContent = () => {
|
|
const { t } = useTranslation()
|
|
return <span>{t('youre_back_online')}</span>
|
|
}
|
|
|
|
const generators: GlobalToastGeneratorEntry[] = [
|
|
{
|
|
key: 'connection-restored',
|
|
generator: () => ({
|
|
content: <ConnectionRestoredToastContent />,
|
|
type: 'success',
|
|
autoHide: true,
|
|
delay: 5000,
|
|
}),
|
|
},
|
|
]
|
|
|
|
export default generators
|
|
|
|
export const showConnectionRestoredToast = () => {
|
|
window.dispatchEvent(
|
|
new CustomEvent('ide:show-toast', {
|
|
detail: {
|
|
key: 'connection-restored',
|
|
handle: CONNECTION_RESTORED_TOAST_HANDLE,
|
|
},
|
|
})
|
|
)
|
|
}
|