Skip to content
This repository has been archived by the owner on May 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #130 from h-be/fix-crashes
Browse files Browse the repository at this point in the history
Fix crashes that relate to PriorityPicker (and reset ExpandedViewMode)
  • Loading branch information
pegahvaezi authored Mar 4, 2020
2 parents 1c77406 + 9a44a7d commit 30726c2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ export default function ExpandedViewModeContent({
const [content, setContent] = useState(goalContent)
const [description, setDescription] = useState(goalDescription)

// reset
useEffect(() => {
if (!goalAddress) {
setActiveTab('comments')
setEditSquirrels(false)
setSquirrelInfoPopup(null)
setEditTimeframe(false)
}
}, [goalAddress])

// handle change of goal
useEffect(() => {
setContent(goalContent)
Expand Down
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 './ExpandedViewModeHeader.css'

import Icon from '../../Icon/Icon'
Expand All @@ -16,6 +16,12 @@ export default function ExpandedViewModeHeader({
}
const [viewsOpen, setViews] = useState(defaultViews)

useEffect(() => {
if (!goalAddress) {
setViews({ ...defaultViews })
}
}, [goalAddress])

const updateGoalStatus = status => {
updateGoal(
{
Expand Down
8 changes: 7 additions & 1 deletion src/components/ExpandedViewMode/RightMenu/RightMenu.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 moment from 'moment'
import './RightMenu.css'

Expand Down Expand Up @@ -31,6 +31,12 @@ export default function RightMenu({ goalAddress, goal, updateGoal }) {

const [viewsOpen, setViews] = useState(defaultViews)

useEffect(() => {
if (!goalAddress) {
setViews({ ...defaultViews })
}
}, [goalAddress])

const rightMenuPriorityClass = viewsOpen.priority ? 'active' : ''
const rightMenuHelpClass = viewsOpen.help ? 'active' : ''

Expand Down
2 changes: 1 addition & 1 deletion src/components/PriorityPicker/PriorityPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ function Priority({
)}

{/* Weigh In / Vote */}
{openMyVote && (
{openMyVote && myVote && (
<div className='my_vote'>
<WeighIn myVote={myVote} onUpdate={onUpdateVote} />
<div className='priority_wrapper_button'>
Expand Down

0 comments on commit 30726c2

Please sign in to comment.