0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor(console): refresh preview on custom phrases updated (#2083)

This commit is contained in:
Xiao Yijun 2022-10-10 10:00:37 +08:00 committed by GitHub
parent 691bdb3ac9
commit a2d59cd0ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -27,6 +27,7 @@ const useUiLanguages = () => {
);
return {
customPhrases: customPhraseList,
languages,
error,
isLoading: !customPhraseList && !error,

View file

@ -33,6 +33,7 @@ const Preview = ({ signInExperience, className }: Props) => {
const [platform, setPlatform] = useState<'desktopWeb' | 'mobile' | 'mobileWeb'>('desktopWeb');
const { data: allConnectors } = useSWR<ConnectorResponse[], RequestError>('/api/connectors');
const previewRef = useRef<HTMLIFrameElement>(null);
const { customPhrases } = useUiLanguages();
const { languages } = useUiLanguages();
@ -109,7 +110,7 @@ const Preview = ({ signInExperience, className }: Props) => {
}, [allConnectors, language, mode, platform, signInExperience]);
const postPreviewMessage = useCallback(() => {
if (!config) {
if (!config || !customPhrases) {
return;
}
@ -117,7 +118,7 @@ const Preview = ({ signInExperience, className }: Props) => {
{ sender: 'ac_preview', config },
window.location.origin
);
}, [config]);
}, [config, customPhrases]);
useEffect(() => {
postPreviewMessage();