Skip to content

add cleanup websocket messages button #159

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/components/view/http/http-details-pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ export class HttpDetailsPane extends React.Component<{
isPaidUser={this.props.accountStore!.isPaidUser}
filenamePrefix={filenamePrefix}
messages={exchange.messages}
onClearMessages={() => exchange.downstream.cleanupMessages()}
/>;
}

Expand Down
8 changes: 8 additions & 0 deletions src/components/view/stream-message-list-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class StreamMessageListCard extends React.Component<ExpandableCardProps &
streamLabel?: string,
messages: Array<StreamMessage>,
editorNode: portals.HtmlPortalNode<typeof SelfSizedEditor>
onClearMessages?: () => void,
}> {

@observable
Expand All @@ -67,6 +68,7 @@ export class StreamMessageListCard extends React.Component<ExpandableCardProps &
expanded,
onCollapseToggled,
onExpandToggled,
onClearMessages,
ariaLabel
} = this.props;

Expand All @@ -92,6 +94,12 @@ export class StreamMessageListCard extends React.Component<ExpandableCardProps &
disabled={!isPaidUser}
onClick={this.exportMessages}
/>
{ onClearMessages &&
<IconButton
icon={['fas', 'ban']}
title="Clear all messages"
onClick={onClearMessages}
/> }
</CollapsingButtons>
{ streamLabel && <Pill
color={getSummaryColor('data')}
Expand Down
10 changes: 7 additions & 3 deletions src/model/websockets/websocket-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,15 @@ export class WebSocketStream extends HttpExchange implements WebSocketView {
this.upstream.updateWithRequestHead(params);
}

cleanup() {
super.cleanup();

@action
cleanupMessages() {
// Clear all websocket message data too
this.messages.forEach(msg => msg.cleanup());
this.messages.length = 0;
}

cleanup() {
super.cleanup();
this.cleanupMessages();
}
}