Skip to content
Merged
Changes from all 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
33 changes: 20 additions & 13 deletions frontend/web/components/pages/FeaturesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ const FeaturesPage = class extends Component {
ES6Component(this)
this.projectId = this.props.routeContext.projectId
const { filters } = this.state
this.fetchFeatures(filters)
}

fetchFeatures = (filters = this.state.filters, page = filters.page) => {
AppActions.getFeatures(
this.projectId,
this.props.match.params.environmentId,
true,
filters.search,
filters.sort,
filters.page,
page,
getServerFilter(filters),
)
}
Expand Down Expand Up @@ -73,6 +77,17 @@ const FeaturesPage = class extends Component {
projectId: params.projectId,
}),
)

// Add window focus listener to refetch features
this.handleWindowFocus = () => {
this.fetchFeatures()
}
window.addEventListener('focus', this.handleWindowFocus)
}

componentWillUnmount = () => {
// Clean up the window focus listener
window.removeEventListener('focus', this.handleWindowFocus)
}

newFlag = () => {
Expand Down Expand Up @@ -119,15 +134,7 @@ const FeaturesPage = class extends Component {
)
}
if (page) {
AppActions.getFeatures(
this.projectId,
this.props.match.params.environmentId,
true,
f.search,
f.sort,
page,
getServerFilter(f),
)
this.fetchFeatures(f, page)
} else {
AppActions.searchFeatures(
this.projectId,
Expand Down Expand Up @@ -207,13 +214,13 @@ const FeaturesPage = class extends Component {

return (
<div className='features-page'>
{(isLoading || !this.state.loadedOnce) &&
{!this.state.loadedOnce &&
(!projectFlags || !projectFlags.length) && (
<div className='centered-container'>
<Loader />
</div>
)}
{(!isLoading || this.state.loadedOnce) && (
{this.state.loadedOnce && (
<div>
{this.state.loadedOnce ||
((this.state.filters.is_archived ||
Expand Down Expand Up @@ -283,7 +290,7 @@ const FeaturesPage = class extends Component {
</PageTitle>
<FormGroup
className={classNames('mb-4', {
'opacity-50': isSaving,
'opacity-50': isSaving || isLoading,
})}
>
<PanelSearch
Expand Down
Loading