Fix translation language badges not updating after auto-translation (#54)

Co-authored-by: hugo <hugoms@me.com>
This commit is contained in:
Georg Bauer
2026-03-13 18:47:04 +01:00
committed by GitHub
parent 9bd0114012
commit f03b087c13
4 changed files with 83 additions and 0 deletions

View File

@@ -167,6 +167,24 @@ const App: React.FC = () => {
}) || (() => {})
);
// Post translation events (refresh post to update availableLanguages for sidebar badges)
const handlePostTranslationChange = (data: unknown) => {
const translation = data as { translationFor?: string };
if (translation.translationFor) {
window.electronAPI?.posts.get(translation.translationFor).then((post) => {
if (post) {
updatePost((post as PostData).id, post as PostData);
}
});
}
};
unsubscribers.push(
window.electronAPI?.on('post:translationCreated', handlePostTranslationChange) || (() => {})
);
unsubscribers.push(
window.electronAPI?.on('post:translationUpdated', handlePostTranslationChange) || (() => {})
);
// Media events
unsubscribers.push(
window.electronAPI?.on('media:imported', (media: unknown) => {