simon | 26e79f7 | 2022-10-05 22:16:08 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 Savoir-faire Linux Inc. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU Affero General Public License as |
| 6 | * published by the Free Software Foundation; either version 3 of the |
| 7 | * License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU Affero General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Affero General Public |
| 15 | * License along with this program. If not, see |
| 16 | * <https://www.gnu.org/licenses/>. |
| 17 | */ |
simon | 218d3d1 | 2022-10-01 17:27:01 -0400 | [diff] [blame] | 18 | /// <reference types="webpack/module" /> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 19 | 'use strict'; |
| 20 | import './index.scss'; |
idillon | 5815c73 | 2022-09-16 13:54:45 -0400 | [diff] [blame] | 21 | import './i18n'; |
Larbi Gharib | e9af973 | 2021-03-31 15:08:01 +0100 | [diff] [blame] | 22 | |
idillon | 8e6c006 | 2022-09-16 13:34:43 -0400 | [diff] [blame] | 23 | // import config from "../sentry-client.config.json" |
idillon | 08f7717 | 2022-09-13 19:14:17 -0400 | [diff] [blame] | 24 | import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; |
simon | 07b4eb0 | 2022-09-29 17:50:26 -0400 | [diff] [blame] | 25 | import { StrictMode } from 'react'; |
simon | 218d3d1 | 2022-10-01 17:27:01 -0400 | [diff] [blame] | 26 | import { render } from 'react-dom'; |
simon | 07b4eb0 | 2022-09-29 17:50:26 -0400 | [diff] [blame] | 27 | import { createRoot } from 'react-dom/client'; |
| 28 | import { Provider } from 'react-redux'; |
| 29 | import { BrowserRouter as Router } from 'react-router-dom'; |
idillon | 322e4ac | 2022-09-14 12:48:43 -0400 | [diff] [blame] | 30 | import socketio from 'socket.io-client'; |
simon | 07b4eb0 | 2022-09-29 17:50:26 -0400 | [diff] [blame] | 31 | |
| 32 | import { store } from '../redux/store'; |
simon | 218d3d1 | 2022-10-01 17:27:01 -0400 | [diff] [blame] | 33 | import App from './App'; |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 34 | import { SocketProvider } from './contexts/Socket'; |
idillon | 08f7717 | 2022-09-13 19:14:17 -0400 | [diff] [blame] | 35 | |
| 36 | const queryClient = new QueryClient({ |
| 37 | defaultOptions: { |
| 38 | queries: { |
| 39 | cacheTime: Infinity, // websocket is responsible to tell when data needs to be updated |
| 40 | }, |
| 41 | }, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 42 | }); |
idillon | 5e89743 | 2022-09-16 13:28:09 -0400 | [diff] [blame] | 43 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 44 | const socket = socketio(); |
idillon | 322e4ac | 2022-09-14 12:48:43 -0400 | [diff] [blame] | 45 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 46 | const container = document.getElementById('root'); |
simon | 218d3d1 | 2022-10-01 17:27:01 -0400 | [diff] [blame] | 47 | if (!container) { |
| 48 | throw new Error('Failed to get the root element'); |
| 49 | } |
idillon | 169f64f | 2022-09-16 14:01:22 -0400 | [diff] [blame] | 50 | const root = createRoot(container); |
| 51 | root.render( |
| 52 | <Provider store={store}> |
Adrien Béraud | 023f7cf | 2022-09-18 14:57:53 -0400 | [diff] [blame] | 53 | <StrictMode> |
idillon | 08f7717 | 2022-09-13 19:14:17 -0400 | [diff] [blame] | 54 | <QueryClientProvider client={queryClient}> |
idillon | 322e4ac | 2022-09-14 12:48:43 -0400 | [diff] [blame] | 55 | <SocketProvider socket={socket}> |
| 56 | <Router> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 57 | <App /> |
idillon | 322e4ac | 2022-09-14 12:48:43 -0400 | [diff] [blame] | 58 | </Router> |
| 59 | </SocketProvider> |
idillon | 08f7717 | 2022-09-13 19:14:17 -0400 | [diff] [blame] | 60 | </QueryClientProvider> |
Adrien Béraud | 023f7cf | 2022-09-18 14:57:53 -0400 | [diff] [blame] | 61 | </StrictMode> |
idillon | 169f64f | 2022-09-16 14:01:22 -0400 | [diff] [blame] | 62 | </Provider> |
| 63 | ); |
Adrien Béraud | e74741b | 2021-04-19 13:22:54 -0400 | [diff] [blame] | 64 | |
idillon | d858c18 | 2022-09-16 13:18:26 -0400 | [diff] [blame] | 65 | if (import.meta.webpackHot) |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 66 | import.meta.webpackHot.accept('./App', () => { |
idillon | d858c18 | 2022-09-16 13:18:26 -0400 | [diff] [blame] | 67 | try { |
simon | 218d3d1 | 2022-10-01 17:27:01 -0400 | [diff] [blame] | 68 | render(<App />, container); |
idillon | d858c18 | 2022-09-16 13:18:26 -0400 | [diff] [blame] | 69 | } catch (e) { |
| 70 | location.reload(); |
| 71 | } |
| 72 | }); |