mirror of
https://github.com/gosticks/web.git
synced 2026-10-07 07:07:07 +00:00
Use optional parameters when possible
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
This commit is contained in:
@@ -72,7 +72,7 @@ class EnableDisable extends Component<EnableDisableProps, EnableDisableState> {
|
||||
* @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;
|
||||
|
||||
@@ -70,7 +70,7 @@ export class WithAPIData<T> extends Component<
|
||||
|
||||
private dataHandle: CancelablePromise<T> | 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<T> 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) });
|
||||
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ export default {
|
||||
getStatus(): Promise<ApiStatus> {
|
||||
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<ApiNetworkSettings> {
|
||||
|
||||
Reference in New Issue
Block a user