-
Notifications
You must be signed in to change notification settings - Fork 560
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
[Bug] PageState.Site.Settings when setting is an empty string value #4095
Comments
@vnetonline I am fairly sure the bug is actually related to how the SetSetting() method is being called. The code:
is setting the IsPrivate parameter to true. The IsPrivate setting indicates whether a setting should be accessible in the client UI or not. Note that when you are logged in as an Administrator, you will have access to ALL settings in the client UI because your user account has the appropriate permissions. However, when you log out and access the UI, any settings which have IsPrivate set to True will NOT be available. I believe what is happening is that the Site Settings are using the default values set in the GetSetting() method because the settings are not in the collection passed to the client. Investigating further, it appears this problem exists in the ThemeSettings.razor of the default Oqtane theme - but only for the Site Settings - the Page Settings are fine because they do not specify the IsPrivate parameter when using SetSetting(). The default Theme template also has the problem. |
The Settings issue appears to be resolved by #4098 (removing IsPrivate parameter from SetSetting call in theme) |
@vnetonline were you able to verify the information I shared above? Does it resolve the problem you were experiencing? And can you please elaborate on the Sync Event comment? |
No it doesn't solve the problem I am having I will give you some more info today. |
@sbwalker I have changed the code as per your suggestion here is my UpdateSetting Method here is my LoadSettings Method When I change the scope to Site where the So it seems like when I hit save, the in regard to my comment regarding Syn Events can you please explain in the SIte Router the following code and why it only runs in
|
@vnetonline your UpdateSettings method contains conditional logic for the _hero field which only sets its value if it is not equal to empty string. As a result, if the value is set to empty string in the UI, the value will never be set in the database. You should remove the conditional check for the _hero field. You can see an example here: https://github.com/oqtane/Oqtane.Theme.Arsha/blob/main/Client/Themes/ThemeSettings.razor In regards to SyncEvents and Render Modes... In Interactive render mode the application is a SPA and retains state for the user session. Each time the Url changes the router uses the state which was already loaded into memory and does not reload from the server. When another user modifies information on the server (ie. changes site settings, add new pages, adds new modules, etc... ) the user session state needs to be refreshed. The SyncService raises Refresh or Reload events to the router to let it know that that state needs to be reloaded from the server. This is documented in this blog: https://www.oqtane.org/blog/!/53/oqtane-server-events In static render mode the application is a server-based app and is stateless (ie. there is no user session). Each time the Url changes it reloads information from the server. When another user modifies information on the server (ie. changes site settings, add new pages, adds new modules, etc... ) the existing user will get the updated information immediately upon the next Url change. There is no need for a SyncService in this scenario. You indicated "in static render mode the Sync Events are not firing" which seems to suggest you are experiencing a problem... can you please explain further. |
Thanks for the explanation, even after removing the conditional logic it doesn't work because PageState.Site.Settings doesn't get updated. It holds the old value works fine for the dropdowns but not when there is a setting with empty strings The SyncEvents are working fine it was just my misunderstanding on how they work |
Now my UpdateSetting method looks like this
These are the settings in my DB So the update is working fine, but when you load the settings by changing the scope to Site I still have Site Setting populated with HTML, which is not in the DB because @sbwalker, you state that when RenderMode is set to |
@vnetonline I cannot reproduce your issue. I modified the ThemeSettings to allow entry of a text field... and logic for loading/saving the text field. And I added logic to the Default theme component to display the information: Private.-.Default.Site.Firefox.Developer.Edition.2024-04-05.15-02-31.mp4(ignore the black highlighting of the Footer field in Theme Settings - it is because of other CSS testing I am doing). Perhaps you are having problems because the setting was declared as Private initially and then you changed it to be Public? Try changing the name of the setting so that it is treated like a brand new setting that has never been referenced before. In regards to your questions about PageState, when you navigate to any link in Static render mode it sends a request to App.razor on the Server which executes/renders all components which are required for that route. If you put a breakpoint on the Refresh() method in SiteRouter it will be hit on every navigation (note that the LocationChanged will NOT be invoked because this is only applicable in Interactive render mode). |
@sbwalker My use case is a bit different I have a scoped setting say if you want to set up a hero image as a site setting so it appears on every page and then some pages have a different image and text so that would be set in the Page scope. If the page scope is empty it would default to the site image This works great for dropdown which always have a value true or false but it doesn't work for empty string. |
@vnetonline you did not explain any of your specific business rules - you just indicated that site settings were not saving properly… so it’s very difficult to diagnose a problem when the details are not fully explained. |
@sbwalker yes you are right I should have explained better ... but if you look at my initial issue I specifically say scoped and detail how to reproduce the issue. The issue may be with MergeSettings method possibly. |
Because I can't resolve or find why the PageSate.Site.Settings doesn't get updated, I have had to work around the issue. So in my Default.razor In my theme, I retrieve settings from DB that which are scoped for
NOTE: When Loading and Updating settings, I don't use
|
since you found a way to resolve your problem, I am going to close this issue |
Issue
Is there an existing issue for this?
Describe the bug
When you have a scoped theme setting of type string and the value is an empty string for a
Site
scope thePageState.Site.Settings
is not updated.Expected Behavior
The
PageState.Site.Settings
retains the old value, even if the setting value is updated to empty string.Steps To Reproduce
LoadDefaultHero
Method with Get property to code part of ThemeSettings.razorAdd a string property to the Default Oqtane Theme ThemeSettings.razor called "_hero" and initialize the property as follows
private string _hero = "";
Modify the
LoadSettings
to the following code to loadHero
settingHero
setting based on scopeSite
,Site
PageState.Site.Settings
retains the Hero HTML previously enteredScreen Shots
UpdateSettings
Method you can see hero is emptyLoadSettings
method you can see that the Hero settings scoped to site retains its old valueOqtane Info
Version - 5.1
Render Mode - Static
Anything else?
I think this bug is in the
UpdateSiteSettingsAsync
Also i have noticed that when in static render mode the Sync Events are not firing
AddSyncEvent(setting.EntityName, setting.SettingId, SyncEventActions.Update);
The text was updated successfully, but these errors were encountered: