From ce177ba4ca1bc7c39eeaf90bb09d9cb2ee906454 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Fri, 1 Mar 2019 19:42:59 -0800 Subject: [PATCH] Use optional parameters when possible Signed-off-by: Mcat12 --- src/components/common/EnableDisable.tsx | 2 +- src/components/common/WithAPIData.tsx | 4 ++-- src/util/api.tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/common/EnableDisable.tsx b/src/components/common/EnableDisable.tsx index 90754fa..8c3db59 100644 --- a/src/components/common/EnableDisable.tsx +++ b/src/components/common/EnableDisable.tsx @@ -72,7 +72,7 @@ class EnableDisable extends Component { * @param action The action to perform ("enable" or "disable") * @param time The amount of time to disable for. This setting is optional. */ - setStatus = (action: StatusAction, time: number | null = null) => { + setStatus = (action: StatusAction, time?: number) => { if (this.state.processing) { // Wait for the first status change to go through return; diff --git a/src/components/common/WithAPIData.tsx b/src/components/common/WithAPIData.tsx index 52853d7..3ca175c 100644 --- a/src/components/common/WithAPIData.tsx +++ b/src/components/common/WithAPIData.tsx @@ -70,7 +70,7 @@ export class WithAPIData extends Component< private dataHandle: CancelablePromise | undefined; - loadData = (data: T | null = null) => { + loadData = (data?: T) => { // Only repeat if there is a non-zero repeat interval const cancelOptions = this.props.repeatOptions.interval !== 0 @@ -85,7 +85,7 @@ export class WithAPIData extends Component< this.dataHandle.cancel(); } - if (data !== null) { + if (data) { // Some data was given, it should be used as the API response this.setState({ apiResult: new Ok(data) }); diff --git a/src/util/api.tsx b/src/util/api.tsx index dcc3add..93e46e9 100644 --- a/src/util/api.tsx +++ b/src/util/api.tsx @@ -84,7 +84,7 @@ export default { getStatus(): Promise { return http.get("dns/status"); }, - setStatus(action: StatusAction, time: number | null = null) { + setStatus(action: StatusAction, time?: number) { return http.post("dns/status", { action, time }); }, getNetworkInfo(): Promise {