Skip to content

Commit 8479b48

Browse files
committed
iterate
1 parent 37ed5df commit 8479b48

70 files changed

Lines changed: 217 additions & 2820 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

TODO.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Now
22

33
- [x] Finish removing redux/redux-form
4+
- [x] Remove react-redux
5+
- [ ] Remove legacy sockets
46
- [ ] Handle errors properly, with toasts. There are many console.error('Failed to delete comment:', error) in the codebase.
57
- [ ] Setting speaker when editing statement doesn't work.
68
- [ ] Speaker focus in speakers list

app/API/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export { default as HttpApi } from './http_api'
2-
export { default as SocketApi } from './socket_api'

app/API/socket_api.js

Lines changed: 0 additions & 97 deletions
This file was deleted.

app/App.jsx

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { ApolloProvider } from '@apollo/client'
77
import React from 'react'
88
import { I18nextProvider } from 'react-i18next'
99
import { Configure, Index, InstantSearch } from 'react-instantsearch-dom'
10-
import { Provider as ReduxProvider } from 'react-redux'
1110
import { polyfill as smoothScrollPolyfill } from 'smoothscroll-polyfill'
1211

1312
// Import APIs so they can load their configurations
@@ -22,43 +21,39 @@ import i18n from './i18n/i18n'
2221
import { ALGOLIA_INDEXES_NAMES, searchClient } from './lib/algolia'
2322
// Import router
2423
import CFRouter from './router'
25-
// Load store
26-
import store from './state'
2724

2825
// Activate polyfills
2926
smoothScrollPolyfill()
3027

3128
const App = () => (
3229
<ToastProvider>
33-
<ReduxProvider store={store}>
34-
<ApolloProvider client={GraphQLClient}>
35-
<I18nextProvider i18n={i18n}>
36-
<ThemeProvider>
37-
<UserPreferencesProvider>
38-
<TooltipProvider>
39-
<UserProvider>
40-
<InstantSearch
41-
searchClient={searchClient}
42-
indexName={ALGOLIA_INDEXES_NAMES[ENTITY_VIDEO]}
43-
>
44-
<Index indexName={ALGOLIA_INDEXES_NAMES[ENTITY_VIDEO]}>
45-
<Configure hitsPerPage={16} />
46-
</Index>
47-
<Index indexName={ALGOLIA_INDEXES_NAMES[ENTITY_SPEAKER]}>
48-
<Configure hitsPerPage={32} />
49-
</Index>
50-
<Index indexName={ALGOLIA_INDEXES_NAMES[ENTITY_STATEMENT]}>
51-
<Configure hitsPerPage={24} />
52-
</Index>
53-
<CFRouter />
54-
</InstantSearch>
55-
</UserProvider>
56-
</TooltipProvider>
57-
</UserPreferencesProvider>
58-
</ThemeProvider>
59-
</I18nextProvider>
60-
</ApolloProvider>
61-
</ReduxProvider>
30+
<ApolloProvider client={GraphQLClient}>
31+
<I18nextProvider i18n={i18n}>
32+
<ThemeProvider>
33+
<UserPreferencesProvider>
34+
<TooltipProvider>
35+
<UserProvider>
36+
<InstantSearch
37+
searchClient={searchClient}
38+
indexName={ALGOLIA_INDEXES_NAMES[ENTITY_VIDEO]}
39+
>
40+
<Index indexName={ALGOLIA_INDEXES_NAMES[ENTITY_VIDEO]}>
41+
<Configure hitsPerPage={16} />
42+
</Index>
43+
<Index indexName={ALGOLIA_INDEXES_NAMES[ENTITY_SPEAKER]}>
44+
<Configure hitsPerPage={32} />
45+
</Index>
46+
<Index indexName={ALGOLIA_INDEXES_NAMES[ENTITY_STATEMENT]}>
47+
<Configure hitsPerPage={24} />
48+
</Index>
49+
<CFRouter />
50+
</InstantSearch>
51+
</UserProvider>
52+
</TooltipProvider>
53+
</UserPreferencesProvider>
54+
</ThemeProvider>
55+
</I18nextProvider>
56+
</ApolloProvider>
6257
</ToastProvider>
6358
)
6459

app/components/App/LanguageSelector.jsx

Lines changed: 0 additions & 81 deletions
This file was deleted.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { Globe } from 'lucide-react'
2+
import React from 'react'
3+
import { useTranslation } from 'react-i18next'
4+
5+
import {
6+
Select,
7+
SelectContent,
8+
SelectItem,
9+
SelectTrigger,
10+
SelectValue,
11+
} from '@/components/ui/select'
12+
import { cn } from '@/lib/css-utils'
13+
14+
const defaultLocales: Record<string, string> = {
15+
en: 'English',
16+
fr: 'Français',
17+
ar: 'العربية',
18+
es: 'Español',
19+
eo: 'Esperanto',
20+
ru: 'Русский',
21+
pt_BR: 'Português (Brasil)',
22+
}
23+
24+
interface LanguageSelectorProps {
25+
value?: string
26+
handleChange?: (value: string) => void
27+
id?: string
28+
className?: string
29+
withIcon?: boolean
30+
additionalOptions?: Record<string, string>
31+
}
32+
33+
const renderIcon = (value: string) => {
34+
if (value === 'fr') {
35+
return '🇫🇷'
36+
} else if (value === 'en') {
37+
return '🇬🇧'
38+
} else if (value === 'ar') {
39+
return '🇩🇿'
40+
} else if (value === 'pt_BR') {
41+
return '🇧🇷'
42+
} else if (value === 'es') {
43+
return '🇪🇸'
44+
} else if (value === 'eo') {
45+
return '🌍'
46+
} else if (value === 'ru') {
47+
return '🇷🇺'
48+
}
49+
return <Globe size={32} />
50+
}
51+
52+
const LanguageSelector: React.FC<LanguageSelectorProps> = ({
53+
value,
54+
handleChange,
55+
id,
56+
className,
57+
withIcon,
58+
additionalOptions,
59+
}) => {
60+
// Force waiting for translations to be loaded
61+
useTranslation()
62+
63+
const options = React.useMemo(() => {
64+
const merged: Record<number, React.ReactNode> = {
65+
...defaultLocales,
66+
...(additionalOptions || {}),
67+
}
68+
// Sort by key
69+
return Object.keys(merged)
70+
.sort()
71+
.reduce(
72+
(acc, key) => {
73+
acc[key] = !withIcon ? (
74+
merged[key]
75+
) : (
76+
<>
77+
{renderIcon(key)}&nbsp;&nbsp;{merged[key]}
78+
</>
79+
)
80+
return acc
81+
},
82+
{} as Record<string, string>,
83+
)
84+
}, [additionalOptions, withIcon])
85+
86+
return (
87+
<div className={cn('flex items-center min-w-24', className)} data-cy="language-selector">
88+
<Select onValueChange={handleChange} value={value}>
89+
<SelectTrigger className="w-full md:min-w-32 min-w-12" id={id}>
90+
<SelectValue />
91+
</SelectTrigger>
92+
<SelectContent data-cy="language-selector-options">
93+
{Object.entries(options).map(([key, label]) => (
94+
<SelectItem key={key} value={key}>
95+
{label}
96+
</SelectItem>
97+
))}
98+
</SelectContent>
99+
</Select>
100+
</div>
101+
)
102+
}
103+
104+
export default LanguageSelector

app/components/App/Layout.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { checkExtensionInstall } from '@/lib/browser-extension'
55
import { cn } from '@/lib/css-utils'
66

77
import { useUserPreferences } from '../../contexts/UserPreferencesContext'
8-
import { MainModalContainer } from '../Modal/MainModalContainer'
98
import { Toaster } from '../ui/toaster'
109
import PublicAchievementUnlocker from '../Users/PublicAchievementUnlocker'
1110
import CrashReportPage from './CrashReportPage'
@@ -51,7 +50,6 @@ class Layout extends React.PureComponent {
5150
<React.Fragment>
5251
<div lang={locale}>
5352
{this.renderMetadata()}
54-
<MainModalContainer />
5553
<Navbar />
5654
<Sidebar />
5755
<div

0 commit comments

Comments
 (0)