Skip to content

Commit 860bfca

Browse files
author
Himanshi Agrawal
committed
Bug9825 fix for Mohan's Bug
1 parent 3db1fc8 commit 860bfca

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

frontend/src/components/Sidebar/Sidebar.tsx

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ const Sidebar = (): JSX.Element => {
8585
const navigate = useNavigate()
8686
const location = useLocation()
8787
const [name, setName] = useState<string>('')
88+
useEffect(() => {
89+
if(appStateContext?.state.isRequestInitiated == true){
90+
NavigationButtonStates.Disabled
91+
}
92+
else{
93+
NavigationButtonStates.Active
94+
}
95+
})
8896

8997
useEffect(() => {
9098
if (!appStateContext) {
@@ -113,7 +121,12 @@ const Sidebar = (): JSX.Element => {
113121
}
114122

115123
const currentView = determineView()
116-
const isGenerating = appStateContext?.state.isGenerating
124+
// inactive, disabled, active
125+
var draftButtonState = NavigationButtonStates.Disabled
126+
if (appStateContext?.state.draftedDocument) {
127+
draftButtonState = currentView === 'draft' ? NavigationButtonStates.Active : NavigationButtonStates.Inactive
128+
}
129+
const isGenerating = appStateContext?.state.isRequestInitiated
117130

118131
return (
119132
<Stack className={styles.sidebarContainer}>
@@ -125,9 +138,9 @@ const Sidebar = (): JSX.Element => {
125138
text={'Browse'}
126139
buttonState={
127140
currentView === 'chat'
128-
? NavigationButtonStates.Active
129-
: appStateContext?.state.isGenerating
130-
? NavigationButtonStates.Disabled
141+
? NavigationButtonStates.Active
142+
: appStateContext?.state.isRequestInitiated
143+
? NavigationButtonStates.Disabled
131144
: NavigationButtonStates.Inactive
132145
}
133146
onClick={() => {
@@ -141,9 +154,10 @@ const Sidebar = (): JSX.Element => {
141154
buttonState={
142155
currentView === 'generate'
143156
? NavigationButtonStates.Active
144-
: appStateContext?.state.isGenerating
157+
: appStateContext?.state.isRequestInitiated
145158
? NavigationButtonStates.Disabled
146159
: NavigationButtonStates.Inactive
160+
147161
}
148162
onClick={() => {
149163
if (!isGenerating) {
@@ -153,17 +167,10 @@ const Sidebar = (): JSX.Element => {
153167
/>
154168
<NavigationButton
155169
text={'Draft'}
156-
buttonState={
157-
currentView === 'draft'
158-
? NavigationButtonStates.Active
159-
: appStateContext?.state.isGenerating
160-
? NavigationButtonStates.Disabled
161-
: NavigationButtonStates.Inactive
162-
}
170+
buttonState={draftButtonState}
171+
163172
onClick={() => {
164-
if (!isGenerating) {
165-
navigate('/draft')
166-
}
173+
navigate('/draft')
167174
}}
168175
/>
169176
</Stack>

0 commit comments

Comments
 (0)