diff --git a/src/components/JournalEntries.tsx b/src/components/JournalEntries.tsx index 6a3cdec..ced40ee 100644 --- a/src/components/JournalEntries.tsx +++ b/src/components/JournalEntries.tsx @@ -121,166 +121,141 @@ function RollbackToHereDialog(props: RollbackToHereDialogPropsType) { ); } -class JournalEntries extends React.PureComponent { - public static defaultProps = { - prevUid: null, - }; - - public state: { - dialog?: EteSync.SyncEntry; - rollbackDialogId?: string; - }; +interface PropsType { + journal: EteSync.Journal; + entries: Immutable.List; + uid?: string; +} - public props: { - journal: EteSync.Journal; - entries: Immutable.List; - uid?: string; - }; +export default function JournalEntries(props: PropsType) { + const [dialog, setDialog] = React.useState(); + const [rollbackDialogId, setRollbackDialogId] = React.useState(); - constructor(props: any) { - super(props); - this.state = {}; + if (props.journal === undefined) { + return (
Loading
); } - public render() { - if (this.props.journal === undefined) { - return (
Loading
); - } - - const rowRenderer = (params: { index: number, key: string, style: React.CSSProperties }) => { - const { key, index, style } = params; - const syncEntry = this.props.entries.get(this.props.entries.size - index - 1)!; - let comp; - try { - comp = parseString(syncEntry.content); - } catch (e) { - const icon = (); - return ( - { - this.setState({ - dialog: syncEntry, - }); - }} - /> - ); - } - - let icon; - if (syncEntry.action === EteSync.SyncEntryAction.Add) { - icon = (); - } else if (syncEntry.action === EteSync.SyncEntryAction.Change) { - icon = (); - } else if (syncEntry.action === EteSync.SyncEntryAction.Delete) { - icon = (); - } - - let name; - let uid; - if (comp.name === "vcalendar") { - if (EventType.isEvent(comp)) { - const vevent = EventType.fromVCalendar(comp); - name = vevent.summary; - uid = vevent.uid; - } else { - const vtodo = TaskType.fromVCalendar(comp); - name = vtodo.summary; - uid = vtodo.uid; - } - } else if (comp.name === "vcard") { - const vcard = new ContactType(comp); - name = vcard.fn; - uid = vcard.uid; - } else { - name = "Error processing entry"; - uid = ""; - } - - if (this.props.uid && (this.props.uid !== uid)) { - return undefined; - } - + const rowRenderer = (params: { index: number, key: string, style: React.CSSProperties }) => { + const { key, index, style } = params; + // eslint-disable-next-line react/prop-types + const syncEntry = props.entries.get(props.entries.size - index - 1)!; + let comp; + try { + comp = parseString(syncEntry.content); + } catch (e) { + const icon = (); return ( { - this.setState({ - dialog: syncEntry, - }); - }} + primaryText="Failed parsing item" + secondaryText="Unknown" + onClick={() => setDialog(syncEntry)} /> ); - }; + } + + let icon; + if (syncEntry.action === EteSync.SyncEntryAction.Add) { + icon = (); + } else if (syncEntry.action === EteSync.SyncEntryAction.Change) { + icon = (); + } else if (syncEntry.action === EteSync.SyncEntryAction.Delete) { + icon = (); + } + + let name; + let uid; + if (comp.name === "vcalendar") { + if (EventType.isEvent(comp)) { + const vevent = EventType.fromVCalendar(comp); + name = vevent.summary; + uid = vevent.uid; + } else { + const vtodo = TaskType.fromVCalendar(comp); + name = vtodo.summary; + uid = vtodo.uid; + } + } else if (comp.name === "vcard") { + const vcard = new ContactType(comp); + name = vcard.fn; + uid = vcard.uid; + } else { + name = "Error processing entry"; + uid = ""; + } + + // eslint-disable-next-line react/prop-types + if (props.uid && (props.uid !== uid)) { + return undefined; + } return ( -
- this.setState({ rollbackDialogId: undefined })} - /> - { - this.setState({ dialog: undefined }); - }} - > - - Raw Content - - -
Entry UID:
{this.state.dialog?.uid}
-
Content: -
{this.state.dialog?.content}
-
-
- - - - -
- - - {({ height, width }) => ( - - )} - - -
+ setDialog(syncEntry)} + /> ); - } -} + }; -export default JournalEntries; + return ( +
+ setRollbackDialogId(undefined)} + /> + setDialog(undefined)} + > + + Raw Content + + +
Entry UID:
{dialog?.uid}
+
Content: +
{dialog?.content}
+
+
+ + + + +
+ + + {({ height, width }) => ( + + )} + + +
+ ); +}