Skip to content
Merged
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: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"sfw": "^2.0.4",
"shell-env": "^4.0.3",
"tmp": "0.2.5",
"tslib": "^2.6.0",
"update-electron-app": "^3.0.0"
},
"devDependencies": {
Expand Down
113 changes: 57 additions & 56 deletions src/renderer/components/history-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,64 +16,65 @@ interface HistoryWrapperProps {
* A component that observes the appState and manages the history dialog.
* Can be rendered as just a button or as a button with a dialog.
*/
@observer
export class HistoryWrapper extends React.Component<HistoryWrapperProps> {
private toggleHistory = () => {
const { appState } = this.props;
appState.toggleHistory();
};
export const HistoryWrapper = observer(
class HistoryWrapper extends React.Component<HistoryWrapperProps> {
private toggleHistory = () => {
const { appState } = this.props;
appState.toggleHistory();
};

private handleRevisionSelect = async (revisionId: string) => {
const { remoteLoader } = window.app;
try {
await remoteLoader.fetchGistAndLoad(
this.props.appState.gistId!,
revisionId,
);
} catch (error: any) {
console.error('Failed to load revision', error);
this.props.appState.showErrorDialog(
`Failed to load revision: ${error.message || 'Unknown error'}`,
);
}
};
private handleRevisionSelect = async (revisionId: string) => {
const { remoteLoader } = window.app;
try {
await remoteLoader.fetchGistAndLoad(
this.props.appState.gistId!,
revisionId,
);
} catch (error: any) {
console.error('Failed to load revision', error);
this.props.appState.showErrorDialog(
`Failed to load revision: ${error.message || 'Unknown error'}`,
);
}
};

public renderHistoryButton() {
const { className } = this.props;
public renderHistoryButton() {
const { className } = this.props;

return (
<Button
icon="history"
onClick={this.toggleHistory}
className={className}
aria-label="View revision history"
data-testid="history-button"
/>
);
}
return (
<Button
icon="history"
onClick={this.toggleHistory}
className={className}
aria-label="View revision history"
data-testid="history-button"
/>
);
}

public render() {
const { appState, buttonOnly } = this.props;
const dialogKey = 'history-dialog';
public render() {
const { appState, buttonOnly } = this.props;
const dialogKey = 'history-dialog';

return (
<>
{buttonOnly ? (
this.renderHistoryButton()
) : (
<>
{this.renderHistoryButton()}
<GistHistoryDialog
key={dialogKey}
appState={appState}
isOpen={appState.isHistoryShowing}
onClose={this.toggleHistory}
onRevisionSelect={this.handleRevisionSelect}
activeRevision={appState.activeGistRevision}
/>
</>
)}
</>
);
}
}
return (
<>
{buttonOnly ? (
this.renderHistoryButton()
) : (
<>
{this.renderHistoryButton()}
<GistHistoryDialog
key={dialogKey}
appState={appState}
isOpen={appState.isHistoryShowing}
onClose={this.toggleHistory}
onRevisionSelect={this.handleRevisionSelect}
activeRevision={appState.activeGistRevision}
/>
</>
)}
</>
);
}
},
);
Loading