Reset invalid state

SCI-5306
This commit is contained in:
Urban Rotnik 2020-12-17 19:48:23 +01:00
parent 63a41b123d
commit 7c967d32f1
2 changed files with 6 additions and 6 deletions

View file

@ -14,6 +14,7 @@ class ProjectsController < ApplicationController
before_action :check_manage_permissions, only: :edit
before_action :set_inline_name_editing, only: %i(show)
before_action :load_exp_sort_var, only: %i(show experiment_archive)
before_action :reset_invalid_view_state, only: %i(index cards)
layout 'fluid'
@ -286,6 +287,11 @@ class ProjectsController < ApplicationController
.any? { |param_name| params.dig(param_name).present? }
end
def reset_invalid_view_state
view_state = current_team.current_view_state(current_user)
view_state.destroy unless view_state.valid?
end
def log_activity(type_of, message_items = {})
message_items = { project: @project.id }.merge(message_items)

View file

@ -8,12 +8,6 @@ class ProjectsOverviewService
@params = params
@view_state = @team.current_view_state(@user)
# Default state changed, reset invalid state
unless @view_state.valid?
@view_state.destroy
@view_state = @team.current_view_state(@user)
end
# Update view_mode if changed
if @view_state.state.dig('projects', 'view_mode') != @params[:filter] &&
%w(active archived).include?(@params[:filter])