Skip to content

Commit

Permalink
Read mod names from Cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Ito committed Dec 25, 2016
1 parent 8da8573 commit bff76b6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
20 changes: 10 additions & 10 deletions Cursed.Base/MainForm.fs
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,6 @@ type MainForm(app: Application) =
layout

do
job {
let! isLatest = Startup.IsLatest

app.Invoke (fun () ->
if isLatest then
app.MainForm.Title <- sprintf "Cursed - Update Available"
)
}
|> start

DataAccess.LoadCache ()

let dynamicLayout =
Expand Down Expand Up @@ -167,3 +157,13 @@ type MainForm(app: Application) =
base.ClientSize <- new Size(900, 600)
base.Content <- dynamicLayout
base.DataContext <- modpack

job {
let! isLatest = Startup.IsLatest

if not isLatest then
app.Invoke (fun () ->
app.MainForm.Title <- sprintf "Cursed - Update Available"
)
}
|> start
2 changes: 1 addition & 1 deletion Cursed.Base/MainFormController.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module MainFormController =
let manifest = ModpackManifest.Parse(manifestFile)
let forge = CreateMultiMc location manifestFile

manifest.Files.[..3]
manifest.Files
|> List.ofSeq
|> List.map (modpack.DownloadMod location)
|> Job.conCollect
Expand Down
16 changes: 13 additions & 3 deletions Cursed.Base/Modpack.fs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ type Modpack(app: Application) as this =
Save cache

job {
let cachedModName =
let cache = CacheActor.FileLoop.PostAndReply GetCache
cache
|> List.tryFind (fun p ->
p.Id = file.ProjectId
)

let projectResponse =
Request.create Get (Uri <| sprintf "http://minecraft.curseforge.com/projects/%i" file.ProjectId)
|> getResponse
Expand All @@ -107,13 +114,16 @@ type Modpack(app: Application) as this =
let html = HtmlDocument.Load(link)

let modName =
let modNameHtml = (html.CssSelect("h1.project-title > a > span")).[0].InnerText
modNameHtml ()
match cachedModName with
| Some project -> project.Name
| None ->
let modNameHtml = (html.CssSelect("h1.project-title > a > span")).[0].InnerText
modNameHtml ()

this.AddMod (modName, file.ProjectId)

let fileUrl = sprintf "%A/files/%i/download" projectResponse.responseUri file.FileId

using(Request.create Get (Uri fileUrl) |> getResponse |> run) (fun r ->
let fileName = Uri.UnescapeDataString(r.responseUri.Segments |> Array.last)

Expand Down

0 comments on commit bff76b6

Please sign in to comment.