diff --git a/packages/fakeyou.com/src/v2/api/category/GetComputedTtsCategoryAssignments.ts b/packages/components/src/api/category/GetComputedTtsCategoryAssignments.ts similarity index 100% rename from packages/fakeyou.com/src/v2/api/category/GetComputedTtsCategoryAssignments.ts rename to packages/components/src/api/category/GetComputedTtsCategoryAssignments.ts diff --git a/packages/fakeyou.com/src/App.tsx b/packages/fakeyou.com/src/App.tsx index 82de5edf05..e99c4c3ac8 100644 --- a/packages/fakeyou.com/src/App.tsx +++ b/packages/fakeyou.com/src/App.tsx @@ -38,7 +38,7 @@ import { GetRetrievalJobStatus, GetRetrievalJobStatusIsOk, } from "@storyteller/components/src/api/retrieval/GetRetrievalJobStatus"; -import { GetComputedTtsCategoryAssignmentsSuccessResponse } from "./v2/api/category/GetComputedTtsCategoryAssignments"; +import { GetComputedTtsCategoryAssignmentsSuccessResponse } from "@storyteller/components/src/api/category/GetComputedTtsCategoryAssignments"; i18n .use(initReactI18next) // passes i18n down to react-i18next @@ -75,7 +75,9 @@ interface Props { setAllTtsModels: (allTtsModels: TtsModelListItem[]) => void; computedTtsCategoryAssignments?: GetComputedTtsCategoryAssignmentsSuccessResponse; - setComputedTtsCategoryAssignments: (categoryAssignments: GetComputedTtsCategoryAssignmentsSuccessResponse) => void; + setComputedTtsCategoryAssignments: ( + categoryAssignments: GetComputedTtsCategoryAssignmentsSuccessResponse + ) => void; allTtsCategoriesByTokenMap: Map; allTtsModelsByTokenMap: Map; @@ -708,8 +710,12 @@ class App extends React.Component { setTtsModels={this.props.setAllTtsModels} allTtsCategories={this.props.allTtsCategories} setAllTtsCategories={this.props.setAllTtsCategories} - computedTtsCategoryAssignments={this.props.computedTtsCategoryAssignments} - setComputedTtsCategoryAssignments={this.props.setComputedTtsCategoryAssignments} + computedTtsCategoryAssignments={ + this.props.computedTtsCategoryAssignments + } + setComputedTtsCategoryAssignments={ + this.props.setComputedTtsCategoryAssignments + } allTtsCategoriesByTokenMap={ this.props.allTtsCategoriesByTokenMap } diff --git a/packages/fakeyou.com/src/AppWrapper.tsx b/packages/fakeyou.com/src/AppWrapper.tsx index a13bc1d3f3..f65c9c7fab 100644 --- a/packages/fakeyou.com/src/AppWrapper.tsx +++ b/packages/fakeyou.com/src/AppWrapper.tsx @@ -1,19 +1,19 @@ -import React, { useEffect, useState } from 'react'; -import { TtsCategory } from './v2/api/category/ListTtsCategories'; -import { TtsModelListItem } from '@storyteller/components/src/api/tts/ListTtsModels'; -import { App } from './App'; -import { v4 as uuidv4 } from 'uuid'; -import { GetComputedTtsCategoryAssignmentsSuccessResponse } from './v2/api/category/GetComputedTtsCategoryAssignments'; +import React, { useEffect, useState } from "react"; +import { TtsCategory } from "./v2/api/category/ListTtsCategories"; +import { TtsModelListItem } from "@storyteller/components/src/api/tts/ListTtsModels"; +import { App } from "./App"; +import { v4 as uuidv4 } from "uuid"; +import { GetComputedTtsCategoryAssignmentsSuccessResponse } from "@storyteller/components/src/api/category/GetComputedTtsCategoryAssignments"; interface Props { // Certan browsers (iPhone) have pitiful support for drawing APIs. Worse yet, - // they seem to lose the "touch event sandboxing" that allows for audio to be + // they seem to lose the "touch event sandboxing" that allows for audio to be // played after user interaction if the XHRs delivering the audio don't do so // as actual audio mimetypes. (Decoding from base64 and trying to play fails.) - enableSpectrograms: boolean, + enableSpectrograms: boolean; // Whether or not to inform users that the name of the website has changed. - flashVocodesNotice: boolean, + flashVocodesNotice: boolean; } // Special synthetic categories created on the frontend. @@ -26,7 +26,11 @@ export class SyntheticCategory { ttsModels: Set; - constructor(name: string, token?: string, maybe_super_category_token?: string) { + constructor( + name: string, + token?: string, + maybe_super_category_token?: string + ) { this.name = name; this.name_for_dropdown = name; this.category_token = !!token ? token : `syn:${uuidv4()}`; @@ -35,146 +39,163 @@ export class SyntheticCategory { } } -export type TtsCategoryType = TtsCategory|SyntheticCategory; +export type TtsCategoryType = TtsCategory | SyntheticCategory; export function AppWrapper(props: Props) { // Caches of all objects queried // These may be triggered by a different page than the user initially lands on. - const [allTtsCategories, setAllTtsCategories] = useState([]); + const [allTtsCategories, setAllTtsCategories] = useState( + [] + ); const [allTtsModels, setAllTtsModels] = useState([]); - const [computedTtsCategoryAssignments, setComputedTtsCategoryAssignments] = useState(undefined); + const [computedTtsCategoryAssignments, setComputedTtsCategoryAssignments] = + useState( + undefined + ); // Precalculated maps for lookup by primary key - const [allCategoriesByTokenMap, setAllCategoriesByTokenMap] = useState>(new Map()); - const [allTtsModelsByTokenMap, setAllTtsModelsByTokenMap] = useState>(new Map()); + const [allCategoriesByTokenMap, setAllCategoriesByTokenMap] = useState< + Map + >(new Map()); + const [allTtsModelsByTokenMap, setAllTtsModelsByTokenMap] = useState< + Map + >(new Map()); // Precalculated map for lookup by foreign key // A TTS voice is attached to every category up the tree from the leaf. - // We recursively build this, 1) to ensure we can access a voice at all levels + // We recursively build this, 1) to ensure we can access a voice at all levels // of specificity, and 2) to prune empty categories. - const [ttsModelsByCategoryToken, setTtsModelsByCategoryToken] = useState>>(new Map()); + const [ttsModelsByCategoryToken, setTtsModelsByCategoryToken] = useState< + Map> + >(new Map()); // Calculated dropdown options for every level of categories. // Outer array has length of at least one, one element per