Skip to content
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

[CSM-458] Query postponeUpdate endpoint when postponing the update #485

Merged
merged 3 commits into from Sep 21, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,8 @@ Changelog

### Features

- Postpone Update Api call integration ([PR 485](https://github.com/input-output-hk/daedalus/pull/485))

### Fixes

- Fix all features eslint warnings ([PR 468](https://github.com/input-output-hk/daedalus/pull/468))
Expand Down
11 changes: 11 additions & 0 deletions app/api/CardanoClientApi.js
Expand Up @@ -518,6 +518,17 @@ export default class CardanoClientApi {
// return null;
}

async postponeUpdate() {
Logger.debug('CardanoClientApi::postponeUpdate called');
try {
const response = await ClientApi.postponeUpdate(tlsConfig);
Logger.debug('CardanoClientApi::postponeUpdate success: ' + stringifyData(response));
} catch (error) {
Logger.error('CardanoClientApi::postponeUpdate error: ' + stringifyError(error));
throw new GenericApiError();
}
}

async applyUpdate() {
Logger.debug('CardanoClientApi::applyUpdate called');
try {
Expand Down
3 changes: 3 additions & 0 deletions app/api/index.js
Expand Up @@ -122,6 +122,8 @@ export type NextUpdateResponse = {
version: string,
};

export type PostponeUpdateResponse = void;

export type ApplyUpdateResponse = void;

export type UpdateWalletPasswordRequest = {
Expand Down Expand Up @@ -173,6 +175,7 @@ export type Api = {
redeemPaperVendedAda(request: RedeemPaperVendedAdaRequest): Promise<RedeemPaperVendedAdaResponse>,
generateMnemonic(): string,
nextUpdate(): Promise<NextUpdateResponse>,
postponeUpdate(): PostponeUpdateResponse,
applyUpdate(): ApplyUpdateResponse,
getSyncProgress(): Promise<GetSyncProgressResponse>,
setUserLocale(locale: string): Promise<string>,
Expand Down
12 changes: 11 additions & 1 deletion app/stores/NodeUpdateStore.js
Expand Up @@ -3,7 +3,11 @@ import { observable, action } from 'mobx';
import Store from './lib/Store';
import Request from './lib/LocalizedRequest';
import environment from '../environment';
import type { NextUpdateResponse, ApplyUpdateResponse } from '../api';
import type {
NextUpdateResponse,
PostponeUpdateResponse,
ApplyUpdateResponse,
} from '../api';

export default class NodeUpdateStore extends Store {

Expand All @@ -14,8 +18,13 @@ export default class NodeUpdateStore extends Store {
@observable isNotificationExpanded = false;
@observable isUpdateInstalled = false;
@observable updateVersion = null;

// REQUESTS
/* eslint-disable max-len */
@observable nextUpdateRequest: Request<NextUpdateResponse> = new Request(this.api.nextUpdate);
@observable postponeUpdateRequest: Request<PostponeUpdateResponse> = new Request(this.api.postponeUpdate);
@observable applyUpdateRequest: Request<ApplyUpdateResponse> = new Request(this.api.applyUpdate);
/* eslint-disable max-len */

setup() {
const actions = this.actions.nodeUpdate;
Expand All @@ -40,6 +49,7 @@ export default class NodeUpdateStore extends Store {
};

@action _postponeNodeUpdate = () => {
this.postponeUpdateRequest.execute();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add some basic error handling here! E.g

@action _postponeNodeUpdate = async () => {
  try {
    await this.postponeUpdateRequest.execute();
    this.isUpdatePostponed = true;
  } catch(error) {
    this.isUpdatePostponed = false;
  }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed @DominikGuzei - the only part that worries me is the fact that we should add "submitting" state on postpone button AND handle error state in the UI as if this call fails we will not hide the update notification so the user should be noticed that the error happened...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah definitely, the whole error handling logic needs to be fleshed out for the UI

this.isUpdatePostponed = true;
};

Expand Down
1 change: 1 addition & 0 deletions flow/declarations/DaedalusClientApi.js
Expand Up @@ -75,6 +75,7 @@ declare module 'daedalus-client-api' {
// Status
declare function notify(tls: TlsConfig, onSuccess: Function, onError?: Function): void;
declare function nextUpdate(tls: TlsConfig): any;
declare function postponeUpdate(tls: TlsConfig): any;
declare function applyUpdate(tls: TlsConfig): any;
declare function syncProgress(tls: TlsConfig): any;

Expand Down