Skip to content

Commit

Permalink
Correct broken object assignment & script builder string construction
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivanov1ch committed Aug 12, 2024
1 parent 673b5a1 commit 9c1549c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion frontend/src/resource/ResourceTreeNode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
{#each comment_strs as comment_text}
<div class="comment">
<Comment
comment="{[comment_range, comment_text]}"
comment="{{ comment_range, comment_text }}"
rootResource="{rootResource}"
selfId="{selfId}"
/>
Expand Down
23 changes: 12 additions & 11 deletions frontend/src/views/Comment.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@
import Hoverable from "../utils/Hoverable.svelte";
import Icon from "../utils/Icon.svelte";
export let comment, rootResource, selfId;
let text = comment[1];
let addresses = text.matchAll("#[a-fA-F0-9]+[@0x[0-9a-fA-F]+]*", text);
let addresses = comment.comment_text.matchAll(
"#[a-fA-F0-9]+[@0x[0-9a-fA-F]+]*"
);
let text_elements = [];
Array.from(addresses).forEach((location) => {
let text_split = text.split(location[0]);
let text_split = comment.comment_text.split(location[0]);
text_elements.push(text_split[0]);
text_elements.push(createAddressButton(location[0]));
text = text_split.slice(1).join(location[0]);
comment.comment_text = text_split.slice(1).join(location[0]);
});
text_elements.push(text);
text_elements.push(comment.comment_text);
function createAddressButton(location) {
let resource_id;
Expand All @@ -53,22 +54,22 @@
return button;
}
async function onDeleteClick(optional_range, comment_text) {
async function onDeleteClick(comment) {
// Delete the selected comment.
// As a side effect, the corresponding resource gets selected.
$selected = selfId;
await rootResource.delete_comment(optional_range, comment_text);
await rootResource.delete_comment(
comment.comment_range,
comment.comment_text
);
$resourceNodeDataMap[$selected].commentsPromise =
rootResource.get_comments();
}
</script>

<div class="comment">
<Hoverable let:hovering>
<button
title="Delete this comment"
on:click="{onDeleteClick(comment[0], comment[1])}"
>
<button title="Delete this comment" on:click="{onDeleteClick(comment)}">
<Icon
class="comment_icon"
url="{hovering ? '/icons/trash_can.svg' : '/icons/comment.svg'}"
Expand Down
5 changes: 3 additions & 2 deletions ofrak_core/ofrak/gui/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,13 +751,14 @@ async def delete_comment(self, request: Request) -> Response:
"""
await {resource}.run"""
f"""(
DeleteCommentModifier, DeleteCommentModifierConfig({comment_range}, {comment_text})
DeleteCommentModifier, DeleteCommentModifierConfig(comment_range={comment_range}, comment_text="{comment_text}")
)"""
)
await self.script_builder.add_action(resource, script_str, ActionType.MOD)
try:
result = await resource.run(
DeleteCommentModifier, DeleteCommentModifierConfig(comment_range, comment_text)
DeleteCommentModifier,
DeleteCommentModifierConfig(comment_range=comment_range, comment_text=comment_text),
)
await self.script_builder.commit_to_script(resource)
except Exception as e:
Expand Down

0 comments on commit 9c1549c

Please sign in to comment.