-
Notifications
You must be signed in to change notification settings - Fork 733
feat: standardize frontend segments calls (CM-189) #4013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -380,7 +380,7 @@ const fetchActivities = async ({ reset } = { reset: false }) => { | |
| offset: offset.value, | ||
| segments: selectedSegment.value | ||
| ? [selectedSegment.value] | ||
| : segments.value.map((s) => s.id), | ||
| : [selectedProjectGroup.value.id], | ||
| }); | ||
|
Comment on lines
381
to
384
|
||
|
|
||
| loading.value = false; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| import authAxios from '@/shared/axios/auth-axios'; | ||
| import { AuthService } from '@/modules/auth/services/auth.service'; import { storeToRefs } from 'pinia'; | ||
| import { useLfSegmentsStore } from '@/modules/lf/segments/store'; | ||
| import { getSegmentsFromProjectGroup } from '@/utils/segments'; | ||
|
|
||
| const getSelectedProjectGroup = () => { | ||
| const lsSegmentsStore = useLfSegmentsStore(); | ||
|
|
@@ -216,10 +215,9 @@ export class OrganizationService { | |
| } | ||
|
|
||
| static async fetchMergeSuggestions(limit, offset, query) { | ||
| const segments = [ | ||
| ...getSegmentsFromProjectGroup(getSelectedProjectGroup()), | ||
| getSelectedProjectGroup().id, | ||
| ]; | ||
| const segments = getSelectedProjectGroup()?.id | ||
| ? [getSelectedProjectGroup().id] | ||
| : []; | ||
|
Comment on lines
+218
to
+220
|
||
|
|
||
| const data = { | ||
| limit, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,5 @@ | ||||||
| import authAxios from '@/shared/axios/auth-axios'; | ||||||
| import { Organization } from '@/modules/organization/types/Organization'; | ||||||
| import { getSegmentsFromProjectGroup } from '@/utils/segments'; | ||||||
| import { useLfSegmentsStore } from '@/modules/lf/segments/store'; | ||||||
| import { storeToRefs } from 'pinia'; | ||||||
|
|
||||||
|
|
@@ -30,13 +29,7 @@ export class OrganizationApiService { | |||||
| } | ||||||
|
|
||||||
| static async fetchMergeSuggestions(limit: number = 20, offset: number = 0, query: any = {}) { | ||||||
| const lsSegmentsStore = useLfSegmentsStore(); | ||||||
| const { selectedProjectGroup } = storeToRefs(lsSegmentsStore); | ||||||
|
|
||||||
| const segments = [ | ||||||
| ...getSegmentsFromProjectGroup(selectedProjectGroup.value), | ||||||
| selectedProjectGroup.value?.id, | ||||||
| ]; | ||||||
| const segments = getSelectedProjectGroupId() ?? []; | ||||||
|
||||||
| const segments = getSelectedProjectGroupId() ?? []; | |
| const segments = getSelectedProjectGroupId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing null check on selectedProjectGroup causes runtime crash
High Severity
selectedProjectGroup.value.idlacks a null/undefined guard. The previous code usedsegments.value.map((s) => s.id)which was backed by a computed that gracefully returned[]whenselectedProjectGroup.valuewas null (viagetSegmentsFromProjectGroup's null check). The new code directly dereferences.idwithout optional chaining, causing aTypeErrorif no project group is selected. Every other file in this same PR applies a null check (e.g.?.id,if (projectGroup), ternary guard).Reviewed by Cursor Bugbot for commit a5dcec9. Configure here.