Skip to content
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

Implement manual autosave control #624

Merged
merged 4 commits into from
Feb 12, 2025

Conversation

Etschbeijer
Copy link
Collaborator

Enable manual control of the autosave

grafik

@Etschbeijer Etschbeijer self-assigned this Feb 11, 2025
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't change stuff you are not touching ... !! 😄

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

especially if it is a code style flavor based on personal preference. After the next release i will add fantomas support to avoid this issue for now and forever

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sry!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont touch stuff you are not working on

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sry!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont touch stuff you are not working on

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sry!

SwateDefaultSearch : bool
TIBSearchCatalogues : Set<string>
[<AutoOpen>]
module PersistentStorageState =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no! do not abbreviate from existing patterns

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sry!

}
open Browser

let [<Literal>] AutosaveConfig_Key = "AutosaveConfig"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to "LocalStorage" folder with its own file

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont do code style changes on files you are not working on

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont do code style changes on files you are not working on

@@ -81,13 +82,13 @@ type Settings =
]
)

static member ActivityLog(model) =
static member ActivityLog (model, dispatch) =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as mentioned above, move this out of activity log

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont do code style changes on files you are not working on

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont do code style changes on files you are not working on

@Etschbeijer
Copy link
Collaborator Author

grafik

open Messages

[<AutoOpen>]
module rec PersistentStorage =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you added "module rec PersistenStorage"?

As far as i can see it it is not required and should not exists in ActivityLogView.

What you could do: Move ActivityLog as a file to Pages/Settings. Since the rework some months ago, activity log is no longer their own page, but was added to settings

prop.children [
Html.p [
prop.className "select-none text-xl py-2"
prop.text "Autsave"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo "Autsave"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -0,0 +1,20 @@

module AutosaveConfig
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module LocalStorage.AutosaveConfig ! (Reuse existing patterns)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

prop.text "Autsave"
]
Daisy.toggle [
let autosaveConfig = getAutosaveConfiguration()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is bad practise. imo better use a react state and fill it with React.useEffectOnce

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no wait. this is simply wrong. "autosaveConfig" refers to value stored in LocalStorage. But value in LocalStorage should be read into PersistentStorage model on init. So you do not need it here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


prop.onChange (fun (b: bool) ->
PersistentStorage.UpdateAutosave (model.PersistentStorageState.Autosave) |> PersistentStorageMsg |> dispatch
setAutosaveConfiguration(b)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This setAutosaveConfiguration should be done inside of update function for "UpdateAutosave" PLUS you are not using b to update model but the value already in model. So this should never change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Components.Forms.Generic.BoxedField("Appearance",
static member ToggleAutosaveConfig(model, dispatch) =
Html.label [
prop.className "grid lg:col-span-2 grid-cols-subgrid cursor-pointer not-prose"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

alignment

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

prop.onChange (fun (b: bool) ->
PersistentStorage.UpdateAutosave (model.PersistentStorageState.Autosave) |> PersistentStorageMsg |> dispatch
setAutosaveConfiguration(b)
if not b then LocalHistory.Model.ResetHistoryWebStorage()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also move into update for PersistentStorage.UpdateAutosave

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@Freymaurer Freymaurer merged commit 530343b into main Feb 12, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants