From f976ff9c056ad118a7ebd98ea5936ba9cee2bd8c Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Mon, 27 Mar 2017 13:49:28 -0700 Subject: [PATCH 1/2] readme working --- Readme.md | 14 +++++------ app/services/core/query-cache.ts | 11 +++++++++ app/services/core/rx-list-proxy.ts | 37 ++++++++++++++++++++++-------- 3 files changed, 45 insertions(+), 17 deletions(-) diff --git a/Readme.md b/Readme.md index 479f493ad4..7a59053873 100644 --- a/Readme.md +++ b/Readme.md @@ -13,13 +13,13 @@ - Or for the latest changes `git clone https://github.com/Azure/BatchLabs` #### 3. Install the dependencies -``` +```bash yarn install npm install -g gulp (Optional) ``` #### 4. Build and run the application -``` +```bash npm run build:prod npm run electron:prod @@ -32,19 +32,19 @@ npm run electron [Dev docs](docs/readme.md) For developers, you can set up a development environment as follows: -** Use `yarn install` instead of `npm install` this will makes sure everybody has the same exact set of depenencies [Migrating from npm to yarn](https://yarnpkg.com/lang/en/docs/migrating-from-npm/)** +**Use `yarn install` instead of `npm install` this will makes sure everybody has the same exact set of depenencies [Migrating from npm to yarn](https://yarnpkg.com/lang/en/docs/migrating-from-npm/)** Start the dev server -``` +```bash npm run dev-server ``` Start electron -``` -// In the command line +```bash +# In the command line npm run dev-electron -// In VSCode just press F5 +# In VSCode just press F5 ``` The dev-server and dev-electron support hot reload for a better development experience. Simply saving a file will cause the UI to refresh to your updated changes. diff --git a/app/services/core/query-cache.ts b/app/services/core/query-cache.ts index 3d3e8b7d94..7204929737 100644 --- a/app/services/core/query-cache.ts +++ b/app/services/core/query-cache.ts @@ -26,6 +26,17 @@ export class QueryCache { this.cleanCache(); } + public addKeyToQuery(filter: string, key: string) { + if (!filter) { + filter = noQueryKey; + } + const query = this._cache[filter]; + if (!query) { + return; + } + query.keys = query.keys.add(key); + } + public getKeys(filter: string): CachedKeyList { if (!filter) { filter = noQueryKey; diff --git a/app/services/core/rx-list-proxy.ts b/app/services/core/rx-list-proxy.ts index 75f3cfa57d..80ec2d3af3 100644 --- a/app/services/core/rx-list-proxy.ts +++ b/app/services/core/rx-list-proxy.ts @@ -6,6 +6,7 @@ import { LoadingStatus } from "app/components/base/loading"; import { CachedKeyList } from "./query-cache"; import { RxEntityProxy } from "./rx-entity-proxy"; import { RxProxyBase, RxProxyBaseConfig } from "./rx-proxy-base"; +import { log } from "app/utils"; export interface RxListProxyConfig extends RxProxyBaseConfig { initialOptions?: any; @@ -117,16 +118,15 @@ export abstract class RxListProxy extends RxProxyBase): Observable { const obs = entityProxy.fetch(); - obs.subscribe(() => { - entityProxy.item.first().subscribe((newItem) => { - if (!newItem) { return; } - const key = this.cache.getItemKey(newItem); - const itemKeys = this._itemKeys; - if (itemKeys.value.has(key)) { - return; - } - this._itemKeys.next(OrderedSet(OrderedSet([key]).concat(this._itemKeys.value))); - }); + obs.subscribe({ + next: () => { + entityProxy.item.first().subscribe((newItem) => { + this._addItemToList(newItem); + }); + }, error: (error) => { + log.error("Error loading new item into RxListProxy", + { error, params: this._params, options: this._options }); + }, }); return obs; } @@ -174,4 +174,21 @@ export abstract class RxListProxy extends RxProxyBase Date: Mon, 27 Mar 2017 13:52:48 -0700 Subject: [PATCH 2/2] fix --- app/services/core/rx-list-proxy.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/services/core/rx-list-proxy.ts b/app/services/core/rx-list-proxy.ts index 80ec2d3af3..c44fd3d7de 100644 --- a/app/services/core/rx-list-proxy.ts +++ b/app/services/core/rx-list-proxy.ts @@ -3,10 +3,10 @@ import { List, OrderedSet } from "immutable"; import { AsyncSubject, BehaviorSubject, Observable } from "rxjs"; import { LoadingStatus } from "app/components/base/loading"; +import { log } from "app/utils"; import { CachedKeyList } from "./query-cache"; import { RxEntityProxy } from "./rx-entity-proxy"; import { RxProxyBase, RxProxyBaseConfig } from "./rx-proxy-base"; -import { log } from "app/utils"; export interface RxListProxyConfig extends RxProxyBaseConfig { initialOptions?: any; @@ -34,7 +34,7 @@ export abstract class RxListProxy extends RxProxyBase { - this._itemKeys.next(OrderedSet(this._itemKeys.getValue().filter((key) => key !== deletedKey))); + this._itemKeys.next(OrderedSet(this._itemKeys.value.filter((key) => key !== deletedKey))); }); } @@ -73,7 +73,7 @@ export abstract class RxListProxy extends RxProxyBase { const keys = OrderedSet(this.newItems(this.processResponse(response))); this._hasMore.next(this.hasMoreItems()); - const currentKeys = this._itemKeys.getValue(); + const currentKeys = this._itemKeys.value; if (currentKeys.size === 0) { this.cache.queryCache.cacheQuery(this._options.filter, keys, this.putQueryCacheData()); } @@ -117,12 +117,10 @@ export abstract class RxListProxy extends RxProxyBase): Observable { - const obs = entityProxy.fetch(); + const obs = entityProxy.fetch().flatMap(() => entityProxy.item.first()); obs.subscribe({ - next: () => { - entityProxy.item.first().subscribe((newItem) => { - this._addItemToList(newItem); - }); + next: (newItem) => { + this._addItemToList(newItem); }, error: (error) => { log.error("Error loading new item into RxListProxy", { error, params: this._params, options: this._options });