Skip to content

Commit

Permalink
fix: Update QuickStart state when preferred organization changes (#2806)
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCizmar authored Jan 6, 2025
1 parent 4b9f16b commit 0413889
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package io.tolgee.service
import io.tolgee.component.demoProject.DemoProjectCreator
import io.tolgee.dtos.cacheable.UserAccountDto
import io.tolgee.dtos.queryResults.organization.QuickStartView
import io.tolgee.exceptions.NotFoundException
import io.tolgee.model.Organization
import io.tolgee.model.QuickStart
import io.tolgee.model.UserAccount
import io.tolgee.repository.QuickStartRepository
import org.springframework.context.ApplicationContext
import org.springframework.data.crossstore.ChangeSetPersister
import org.springframework.stereotype.Component

@Component
Expand Down Expand Up @@ -44,7 +44,7 @@ class QuickStartService(
): QuickStart {
val quickStart =
quickStartRepository.findByUserAccountId(userAccount.id)
?: throw ChangeSetPersister.NotFoundException()
?: throw NotFoundException()
quickStart.finished = finished
quickStartRepository.save(quickStart)
return quickStart
Expand All @@ -56,7 +56,7 @@ class QuickStartService(
): QuickStart {
val quickStart =
quickStartRepository.findByUserAccountId(userAccount.id)
?: throw ChangeSetPersister.NotFoundException()
?: throw NotFoundException()
quickStart.open = open
quickStartRepository.save(quickStart)
return quickStart
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/globalContext/useInitialDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const useInitialDataService = () => {
const [announcement, setAnnouncement] = useState<AnnouncementDto | undefined>(
initialDataLoadable.data?.announcement
);

const [quickStart, setQuickStart] = useState<QuickStartModel | undefined>(
initialDataLoadable.data?.preferredOrganization?.quickStart
);
Expand Down Expand Up @@ -153,6 +154,7 @@ export const useInitialDataService = () => {

// load new preferred organization
const data = await preferredOrganizationLoadable.mutateAsync({});
setQuickStart(data.quickStart);
setOrganization(data);
} finally {
setOrganizationLoading(false);
Expand Down

0 comments on commit 0413889

Please sign in to comment.