Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern Match Cleanup #9

Merged
merged 3 commits into from
Jun 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions src/chrobot.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ pub fn as_value(
decoder,
) {
case result {
Ok(runtime.RemoteObject(_, _, _, Some(value), _, _, _)) -> {
Ok(runtime.RemoteObject(value: Some(value), ..)) -> {
decoder(value)
|> result.replace_error(chrome.ProtocolError)
}
Expand Down Expand Up @@ -661,7 +661,7 @@ pub fn select_all(on page: Page, matching selector: String) {
let selector_code = "window.document.querySelectorAll(\"" <> selector <> "\")"
let result = eval(page, selector_code)
case result {
Ok(runtime.RemoteObject(_, _, _, _, _, _, Some(remote_object_id))) -> {
Ok(runtime.RemoteObject(object_id: Some(remote_object_id), ..)) -> {
use result_properties <- result.try(runtime.get_properties(
page_caller(page),
remote_object_id,
Expand Down Expand Up @@ -689,16 +689,11 @@ pub fn select_all(on page: Page, matching selector: String) {
list.filter_map(property_descriptors, fn(prop_descriptor) {
case prop_descriptor {
runtime.PropertyDescriptor(
_,
Some(runtime.RemoteObject(_, _, _, _, _, _, Some(object_id))),
_,
_,
_,
_,
_,
_,
_,
_,
value: Some(runtime.RemoteObject(
object_id: Some(object_id),
..,
)),
..,
) -> {
Ok(object_id)
}
Expand Down Expand Up @@ -896,7 +891,7 @@ fn handle_eval_response(eval_response) {

fn handle_object_id_response(response) {
case response {
Ok(runtime.RemoteObject(_, _, _, _, _, _, Some(remote_object_id))) -> {
Ok(runtime.RemoteObject(object_id: Some(remote_object_id), ..)) -> {
Ok(remote_object_id)
}
Ok(_) -> {
Expand Down Expand Up @@ -985,7 +980,10 @@ pub fn call_custom_function_on(
))
}
runtime.CallFunctionOnResponse(
runtime.RemoteObject(_, _, _, Some(value), _, _, _),
runtime.RemoteObject(
value: Some(value),
..,
),
None,
) -> {
value_decoder(value)
Expand Down