Skip to content

Commit

Permalink
Revert "Add (broken) update notification row"
Browse files Browse the repository at this point in the history
This reverts commit 5fbc889.
  • Loading branch information
Kai Ito committed Jan 5, 2017
1 parent 22d0ad4 commit c6eb31a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 69 deletions.
25 changes: 10 additions & 15 deletions Cursed.Base/Actors/ViewActor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
module ViewActor =
open System

let initialState =
{ ModpackLink = String.Empty
ExtractLocation = String.Empty
Mods = []
ModCount = 0
ProgressBarState = Disabled
Versions = new Version("1.0.0"), new Version("1.0.0") }

let UpdateLoop =
let inboxHandler (inbox: MailboxProcessor<StateReplyMessage>) =
let rec messageLoop oldState =
Expand Down Expand Up @@ -64,15 +56,18 @@ module ViewActor =

reply.Reply newState.ProgressBarState
return! messageLoop newState
| SetVersions (current, latest, reply) ->
let newState = { oldState with Versions = current, latest }

reply.Reply newState.Versions
return! messageLoop newState
| StateReplyMessage.Restart ->
return! messageLoop initialState
return! messageLoop { ModpackLink = String.Empty
ExtractLocation = String.Empty
Mods = []
ModCount = 0
ProgressBarState = Disabled }
}

messageLoop initialState
messageLoop { ModpackLink = String.Empty
ExtractLocation = String.Empty
Mods = []
ModCount = 0
ProgressBarState = Disabled }

MailboxProcessor.Start(inboxHandler)
4 changes: 2 additions & 2 deletions Cursed.Base/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
namespace System
open System.Reflection

[<assembly: AssemblyVersionAttribute("1.2.0")>]
[<assembly: AssemblyVersionAttribute("1.2.1")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyVersion = "1.2.0"
let [<Literal>] AssemblyVersion = "1.2.1"
37 changes: 4 additions & 33 deletions Cursed.Base/MainForm.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,6 @@ type MainForm(app: Application) =
inherit Form()
let modpack = new Modpack(app)

let updateNotificationRow =
let updateCellLayout =
let updateAvailableLabel =
let label = new Label(Text="Update available")
label.Font <- new Font("Seguo UI", 12.0f, FontStyle.Bold)
label

let versionsLabel =
let label = new Label()
label.Text <- sprintf "Current: %A Latest: %A" "" ""
label.TextAlignment <- TextAlignment.Center
label

let downloadButton = new Button(Text="Get")
let row = new TableRow([new TableCell(updateAvailableLabel); new TableCell(versionsLabel, true); new TableCell(downloadButton)])

let tableLayout =
let layout = new TableLayout(row)
let visibleBinding = Binding.Property(fun (l: TableLayout) -> l.Visible)
let updateNotificationLayoutVisibleBinding = Binding.Property(fun (m: Modpack) -> m.Versions).Convert(fun (current, latest) ->
latest.CompareTo(current) <= 0
)
layout.BindDataContext(visibleBinding, updateNotificationLayoutVisibleBinding) |> ignore
layout
tableLayout

let updateCell = new TableCell(updateCellLayout)
new TableRow([new TableCell(); updateCell; new TableCell()])

let extractLocationRow =
let extractLocationHelpText = new Label(Text="Choose extract location")
let extractLocationLabel =
Expand Down Expand Up @@ -174,7 +145,6 @@ type MainForm(app: Application) =

layout.Padding <- new Padding(10)
layout.Spacing <- new Size(5, 5)
layout.Rows.Add(updateNotificationRow)
layout.Rows.Add(extractLocationRow)
layout.Rows.Add(urlInputRow)
layout
Expand All @@ -189,10 +159,11 @@ type MainForm(app: Application) =
base.DataContext <- modpack

async {
let! current, latest = Startup.GetVersions
let isLatest = latest.CompareTo(current) <= 0
let! isLatest = Startup.IsLatest

if not isLatest then
modpack.SetUpdateAvailable (current, latest)
app.Invoke (fun () ->
app.MainForm.Title <- sprintf "Cursed - Update Available"
)
}
|> Async.Start
10 changes: 0 additions & 10 deletions Cursed.Base/Modpack.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type Modpack(app: Application) as this =
let mutable mods = [{ Link = String.Empty; Name = String.Empty; Completed = false; ProjectId = 0 }]
let mutable modCount = 0
let mutable progressBarState = Disabled
let mutable versions = new Version("1.0.0"), new Version("1.0.0")

member this.UpdateModpackLink link =
this.ModpackLink <- ViewActor.UpdateLoop.PostAndReply (fun reply -> UpdateModpackLink (link, reply))
Expand All @@ -62,9 +61,6 @@ type Modpack(app: Application) as this =
member this.FinishDownload =
this.ProgressBarState <- ViewActor.UpdateLoop.PostAndReply FinishDownload

member this.SetUpdateAvailable (current, latest) =
this.Versions <- ViewActor.UpdateLoop.PostAndReply (fun reply -> SetVersions (current, latest, reply))

member this.ModpackLink
with get() = modpackLink
and private set(value) =
Expand Down Expand Up @@ -94,12 +90,6 @@ type Modpack(app: Application) as this =
progressBarState <- value
app.Invoke (fun () -> this.OnPropertyChanged <@ this.ProgressBarState @>)

member this.Versions
with get() = versions
and private set(value) =
versions <- value
app.Invoke (fun () -> this.OnPropertyChanged <@ this.Versions @>)

member this.DownloadMod location (file: ModpackManifest.File) =
let saveToCache projectId modName fileId fileName =
CacheActor.FileLoop.Post <| SaveProject { Id = projectId; Name = modName; Files = [] }
Expand Down
6 changes: 3 additions & 3 deletions Cursed.Base/Startup.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ module Startup =
return version
}

let private currentVersion =
let private getCurrentVersion =
Assembly.GetExecutingAssembly().GetName().Version

let GetVersions =
let IsLatest =
async {
let! latest = getLatestVersion
let latestVersion = new Version(latest)

return currentVersion, latestVersion
return latestVersion.CompareTo(getCurrentVersion) <= 0
}

5 changes: 1 addition & 4 deletions Cursed.Base/State.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Cursed.Base
open FSharp.Data
open System

type ModpackManifest = JsonProvider<"./SampleManifest.json">

Expand All @@ -20,8 +19,7 @@ type AppState =
ExtractLocation: string
Mods: Mod list
ModCount: int
ProgressBarState: ProgressBarState
Versions: Version * Version}
ProgressBarState: ProgressBarState }

type ModFile =
{ Id: int
Expand All @@ -39,7 +37,6 @@ type StateReplyMessage =
| AddMod of string * int * AsyncReplyChannel<Mod list>
| UpdateModpackInformation of int * AsyncReplyChannel<int * ProgressBarState>
| FinishDownload of AsyncReplyChannel<ProgressBarState>
| SetVersions of Version * Version * AsyncReplyChannel<Version * Version>
| Restart

type FileReplyMessage =
Expand Down
4 changes: 2 additions & 2 deletions Cursed/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
namespace System
open System.Reflection

[<assembly: AssemblyVersionAttribute("1.2.0")>]
[<assembly: AssemblyVersionAttribute("1.2.1")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyVersion = "1.2.0"
let [<Literal>] AssemblyVersion = "1.2.1"

0 comments on commit c6eb31a

Please sign in to comment.