Skip to content
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

Fixed infinite api calls in a story #112

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: Bug report
about: Create a report to help us improve
title: ""
labels: "Type: Bug"
assignees: ""
title: ''
labels: 'Type: Bug'
assignees: ''
---

## Describe the bug
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
blank_issues_enabled: true
blank_issues_enabled: true
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ""
labels: "Type: Enhancement"
assignees: ""
title: ''
labels: 'Type: Enhancement'
assignees: ''
---

## Is your feature request related to a problem? Please describe.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/github-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: Test SCSS
run: npm run test:scss

- name: Test JS
run: npm run test:js

Expand All @@ -40,7 +40,7 @@ jobs:
- name: Create config.json
run: echo $TEST_CONFIG_JSON > src/config.json
env:
TEST_CONFIG_JSON: "{ \"apiURL\": \"http://localhost:1337\", \"APP_ENV\": \"prod\" }"
TEST_CONFIG_JSON: '{ "apiURL": "http://localhost:1337", "APP_ENV": "prod" }'

- name: Test Cypress
uses: cypress-io/github-action@v2
Expand Down
5 changes: 1 addition & 4 deletions cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@
"testStoryProduct": "EOS Icons",
"testCategory": "Documentation"
},
"testFiles": [
"user_story.spec.js",
"test_filters.spec.js"
]
"testFiles": ["user_story.spec.js", "test_filters.spec.js"]
}
5 changes: 3 additions & 2 deletions cypress/integration/test_filters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ describe('Test the filters and search for stories in Home page', () => {
}

const selectProduct = (productName) => {
cy.get(`[data-cy=${productName.split(' ').join('-')}-card]`)
.click({ force: true })
cy.get(`[data-cy=${productName.split(' ').join('-')}-card]`).click({
force: true
})
}

const setDropdown = (dropdown, value) => {
Expand Down
6 changes: 4 additions & 2 deletions src/components/CommentForm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import React, { useState, useEffect } from 'react'
import { useForm } from 'react-hook-form'
import { EOS_ATTACHMENT } from 'eos-icons-react'

Expand Down Expand Up @@ -29,7 +29,9 @@ const CommentForm = (props) => {
setUsers(response.data?.data?.users ?? [])
}

fetchUsers()
useEffect(() => {
fetchUsers()
}, [])

const displayTransform = (id, display) => {
return `@${display}`
Expand Down
5 changes: 2 additions & 3 deletions src/components/Notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ const Notifications = () => {

const [notifications, setNotifications] = useState([])

const [notificationsDropdownState, setNotificationsDropdownState] = useState(
false
)
const [notificationsDropdownState, setNotificationsDropdownState] =
useState(false)

const [notificationCount, setNotificationCount] = useState(0)

Expand Down
14 changes: 8 additions & 6 deletions src/components/StoryPageTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,21 @@ const StoryPageTimeline = (props) => {
(id) => id !== JSON.stringify(userId)
)
const response = await userStory.updateVotes(story.id, updatedFollowerIds)
updatedFollowerIds = response.data.data.updateUserStory.userStory.followers.map(
(follower) => JSON.stringify(follower.id)
)
updatedFollowerIds =
response.data.data.updateUserStory.userStory.followers.map((follower) =>
JSON.stringify(follower.id)
)
setFollowers(updatedFollowerIds)
setVoted(false)
setVotes((votes) => votes - 1)
} else {
followers.push(JSON.stringify(userId))
let updatedFollowerIds = followers
const response = await userStory.updateVotes(story.id, updatedFollowerIds)
updatedFollowerIds = response.data.data.updateUserStory.userStory.followers.map(
(follower) => JSON.stringify(follower.id)
)
updatedFollowerIds =
response.data.data.updateUserStory.userStory.followers.map((follower) =>
JSON.stringify(follower.id)
)
setFollowers(updatedFollowerIds)
setVoted(true)
setVotes((votes) => votes + 1)
Expand Down
14 changes: 8 additions & 6 deletions src/components/Vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ const Vote = (props) => {
(id) => id !== JSON.stringify(userId)
)
const response = await userStory.updateVotes(story.id, updatedFollowerIds)
updatedFollowerIds = response.data.data.updateUserStory.userStory.followers.map(
(follower) => JSON.stringify(follower.id)
)
updatedFollowerIds =
response.data.data.updateUserStory.userStory.followers.map((follower) =>
JSON.stringify(follower.id)
)
setFollowers(updatedFollowerIds)
setVoted(false)
setVotes((votes) => votes - 1)
} else {
followers.push(JSON.stringify(userId))
let updatedFollowerIds = followers
const response = await userStory.updateVotes(story.id, updatedFollowerIds)
updatedFollowerIds = response.data.data.updateUserStory.userStory.followers.map(
(follower) => JSON.stringify(follower.id)
)
updatedFollowerIds =
response.data.data.updateUserStory.userStory.followers.map((follower) =>
JSON.stringify(follower.id)
)
setFollowers(updatedFollowerIds)
setVoted(true)
setVotes((votes) => votes + 1)
Expand Down