Refactor getLanguage

This commit is contained in:
Jed Fox 2020-04-01 13:48:38 -04:00
parent cba0a57ce3
commit e0e1e4fde7
No known key found for this signature in database
GPG key ID: 0B61D18EA54B47E1
4 changed files with 3 additions and 8 deletions

View file

@ -76,7 +76,7 @@ import { actions } from "../actions/register";
import { ActionResult } from "../actions/types"; import { ActionResult } from "../actions/types";
import { getDefaultAppState } from "../appState"; import { getDefaultAppState } from "../appState";
import { t, getLanguage } from "../i18n"; import { t } from "../i18n";
import { import {
copyToAppClipboard, copyToAppClipboard,
@ -194,7 +194,6 @@ export class App extends React.Component<any, AppState> {
return !element.isDeleted; return !element.isDeleted;
})} })}
setElements={this.setElements} setElements={this.setElements}
language={getLanguage()}
onRoomCreate={this.createRoom} onRoomCreate={this.createRoom}
onRoomDestroy={this.destroyRoom} onRoomDestroy={this.destroyRoom}
onLockToggle={this.toggleLock} onLockToggle={this.toggleLock}

View file

@ -4,7 +4,7 @@ import * as i18n from "../i18n";
export function LanguageList({ export function LanguageList({
onChange, onChange,
languages = i18n.languages, languages = i18n.languages,
currentLanguage = i18n.getLanguage(), currentLanguage = i18n.getLanguage().lng,
floating, floating,
}: { }: {
languages?: { lng: string; label: string }[]; languages?: { lng: string; label: string }[];

View file

@ -30,7 +30,6 @@ interface LayerUIProps {
canvas: HTMLCanvasElement | null; canvas: HTMLCanvasElement | null;
setAppState: any; setAppState: any;
elements: readonly ExcalidrawElement[]; elements: readonly ExcalidrawElement[];
language: string;
setElements: (elements: readonly ExcalidrawElement[]) => void; setElements: (elements: readonly ExcalidrawElement[]) => void;
onRoomCreate: () => void; onRoomCreate: () => void;
onRoomDestroy: () => void; onRoomDestroy: () => void;
@ -44,7 +43,6 @@ export const LayerUI = React.memo(
setAppState, setAppState,
canvas, canvas,
elements, elements,
language,
setElements, setElements,
onRoomCreate, onRoomCreate,
onRoomDestroy, onRoomDestroy,
@ -191,7 +189,6 @@ export const LayerUI = React.memo(
setAppState({}); setAppState({});
}} }}
languages={languages} languages={languages}
currentLanguage={language}
floating floating
/> />
{appState.scrolledOutside && ( {appState.scrolledOutside && (
@ -228,7 +225,6 @@ export const LayerUI = React.memo(
const keys = Object.keys(prevAppState) as (keyof Partial<AppState>)[]; const keys = Object.keys(prevAppState) as (keyof Partial<AppState>)[];
return ( return (
prev.language === next.language &&
prev.elements === next.elements && prev.elements === next.elements &&
keys.every((key) => prevAppState[key] === nextAppState[key]) keys.every((key) => prevAppState[key] === nextAppState[key])
); );

View file

@ -42,7 +42,7 @@ export function setLanguage(newLng: string | undefined) {
} }
export function getLanguage() { export function getLanguage() {
return currentLanguage.lng; return currentLanguage;
} }
function findPartsForData(data: any, parts: string[]) { function findPartsForData(data: any, parts: string[]) {