mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-28 08:13:17 +03:00
GH-383 Reload only when a new file gets selected
This commit is contained in:
parent
55cddec9ad
commit
8902aafedd
@ -39,6 +39,16 @@ class HtmlPreviewTool: NSView, UiComponent {
|
||||
source
|
||||
.observeOn(MainScheduler.instance)
|
||||
.subscribe(onNext: { [unowned self] state in
|
||||
guard let serverUrl = state.htmlPreview.server else {
|
||||
return
|
||||
}
|
||||
|
||||
if serverUrl.mark == self.mark {
|
||||
return
|
||||
}
|
||||
|
||||
self.mark = serverUrl.mark
|
||||
self.webview.load(URLRequest(url: serverUrl.payload))
|
||||
})
|
||||
.addDisposableTo(self.disposeBag)
|
||||
}
|
||||
@ -53,6 +63,8 @@ class HtmlPreviewTool: NSView, UiComponent {
|
||||
fileprivate let emitter: ActionEmitter
|
||||
fileprivate let uuid: String
|
||||
|
||||
fileprivate var mark = Token()
|
||||
|
||||
fileprivate let webview: WKWebView
|
||||
|
||||
fileprivate let disposeBag = DisposeBag()
|
||||
|
@ -25,8 +25,9 @@ class HtmlPreviewToolReducer: Reducer {
|
||||
|
||||
case let .selectHtmlFile(url):
|
||||
state.htmlPreview.htmlFile = url
|
||||
state.htmlPreview.server = self.baseServerUrl
|
||||
.appendingPathComponent("\(uuid)/\(HtmlPreviewToolReducer.basePath)/index.html")
|
||||
state.htmlPreview.server = Marked(
|
||||
self.baseServerUrl .appendingPathComponent("\(uuid)/\(HtmlPreviewToolReducer.basePath)/index.html")
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
@ -44,9 +44,9 @@ extension HttpServerService {
|
||||
return
|
||||
}
|
||||
|
||||
let basePath = serverUrl.deletingLastPathComponent().path
|
||||
let basePath = serverUrl.payload.deletingLastPathComponent().path
|
||||
|
||||
self.server.GET[serverUrl.path] = shareFile(htmlFileUrl.path)
|
||||
self.server.GET[serverUrl.payload.path] = shareFile(htmlFileUrl.path)
|
||||
self.server["\(basePath)/:path"] = shareFilesFromDirectory(htmlFileUrl.parent.path)
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ struct HtmlPreviewState {
|
||||
static let `default` = HtmlPreviewState()
|
||||
|
||||
var htmlFile: URL?
|
||||
var server: URL?
|
||||
var server: Marked<URL>?
|
||||
}
|
||||
|
||||
struct AppearanceState: SerializableState {
|
||||
|
Loading…
Reference in New Issue
Block a user