Skip to content

Commit

Permalink
fix "issie ate my sheets" problem
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcl committed Feb 28, 2021
1 parent 3f3796b commit ab1e2b0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
23 changes: 16 additions & 7 deletions src/Renderer/UI/FileMenuView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ let releaseFileActivity (a:string) (dispatch)=
dispatch <| ModelType.ReleaseFileActivity a

let releaseFileActivityImplementation a =
printfn "Releasing %s" a
match fileProcessingBusy with
| a' :: rest when a' = a ->
fileProcessingBusy <- rest
Expand Down Expand Up @@ -380,6 +381,7 @@ let setupProjectFromComponents (sheetName: string) (ldComps: LoadedComponent lis
/// Closes waveadder if it is open
let private openFileInProject' saveCurrent name project (model:Model) dispatch =
let newModel = {model with CurrentProj = Some project}
printfn "Opening %s" name
match getFileInProject name project with
| None ->
log <| sprintf "Warning: openFileInProject could not find the component %s in the project" name
Expand Down Expand Up @@ -408,10 +410,17 @@ let private openFileInProject' saveCurrent name project (model:Model) dispatch =
project.LoadedComponents
setupProjectFromComponents name ldcs newModel dispatch

let openFileInProject name project (model:Model) dispatch =
if requestFileActivity "openFileInProject" dispatch then
openFileInProject' true name project (model:Model) dispatch
dispatch <| ReleaseFileActivity "openFileInProject"
let openFileInProject name (model:Model) dispatch =
match model.CurrentProj with
| Some proj ->
printfn "opening %s... " name
if requestFileActivity "openFileInProject" dispatch then
printfn "Starting..."
openFileInProject' true name proj (model:Model) dispatch
dispatch <| ReleaseFileActivity "openFileInProject"
else
printfn "cancelled"
| None -> ()


/// return a react warning message if name if not valid for a sheet Add or Rename, or else None
Expand Down Expand Up @@ -494,7 +503,7 @@ let renameSheet oldName newName (model:Model) dispatch =


/// rename file
let renameFileInProject name project model dispatch =
let renameFileInProject name model dispatch =
match model.CurrentProj, getCurrentWSMod model with
| None,_ -> log "Warning: renameFileInProject called when no project is currently open"
| Some project, Some ws when ws.WSViewState<>WSClosed ->
Expand Down Expand Up @@ -781,7 +790,7 @@ let viewTopMenu model messagesFunc simulateButtonFunc dispatch =
Button.Color IsPrimary
Button.Disabled(name = project.OpenFileName)
Button.OnClick(fun _ ->
openFileInProject name project model dispatch) ] [ str "open" ]
dispatch <| ExecuteWithCurrentModel (openFileInProject name,dispatch)) ] [ str "open" ]
]
// Add option to rename?
Level.item [] [
Expand All @@ -790,7 +799,7 @@ let viewTopMenu model messagesFunc simulateButtonFunc dispatch =
Button.IsOutlined
Button.Color IsInfo
Button.OnClick(fun _ ->
renameFileInProject name project model dispatch) ] [ str "rename" ]
dispatch <| ExecuteWithCurrentModel (renameFileInProject name, dispatch)) ] [ str "rename" ]
]
Level.item []
[ Button.button
Expand Down
1 change: 1 addition & 0 deletions src/Renderer/UI/ModelType.fs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ type Project = {


type Msg =
| ExecuteWithCurrentModel of (Model -> (Msg->Unit)-> Unit)* (Msg -> Unit)
| JSDiagramMsg of JSDiagramMsg<JSCanvas,JSComponent>
| KeyboardShortcutMsg of KeyboardShortcutMsg
| StartSimulation of Result<SimulationData, SimulationError>
Expand Down
5 changes: 4 additions & 1 deletion src/Renderer/UI/Update.fs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,10 @@ let update msg model =
let msgS = (sprintf "%A..." msg) |> Seq.truncate 60 |> Seq.map (fun c -> string c) |> String.concat ""
printfn "%d %s" sdlen msgS
match msg with

// special synchronisation message
| ExecuteWithCurrentModel (func, dispatch)->
func model dispatch
model, Cmd.none
// special mesages for mouse control of screen vertical dividing bar, active when Wavesim is selected as rightTab
| SetDragMode mode -> {model with DividerDragMode= mode}, Cmd.none
| SetViewerWidth w -> {model with WaveSimViewerWidth = w}, Cmd.none
Expand Down

0 comments on commit ab1e2b0

Please sign in to comment.