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

View file

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

View file

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

View file

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