kattrali / webkitten

A command-driven web browser toolkit inspired by luakit and Vim.

Home Page:https://webkitten.delisa.me

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

on-load-uri not called for refreshes

keith opened this issue · comments

Currently when calling reload_webview from a script, on-load-uri is not called afterwards.

The problem here seems to be that while webview_did_load is called via the WKNavigationDelegate, the WKNavigation that is passed, has a nil request, meaning the callback isn't fired.

One possible way around this would be knowing that this is a case where navigationDidFinishDocumentLoad: is called, but with a nil request, we could implement an else case on that conditional, something like:

} else {
    let uri = webview::uri(webview);
    info!("did refresh {}", uri);
    UI.engine.on_uri_event::<CocoaUI>(&UI, window_index, webview_index, &uri, URIEvent::Load);
}

Which seems to work correctly, but also feels like a bit of a hack.

Also it seems like if we instead were getting a WKNavigationAction from this API, we would be able to use the navigationType to figure this out, but for some reason it passes only a WKNavigation

I also tried the public didFinishNavigation: delegate method but got the same results.

¯_(ツ)_/¯