Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@
"@types/react-virtualized": "^9.18.7",
"@types/recompose": "^0.20.4",
"@types/reselect": "^2.0.27",
"@types/seamless-immutable": "^6.1.2",
"@types/sinon": "^4.1.3",
"@types/superagent": "^2.0.36",
"autobind-decorator": "^2.1.0",
Expand Down Expand Up @@ -277,7 +276,6 @@
"sass-loader": "10.1.1",
"sass-resources-loader": "^1.3.1",
"save-svg-as-png": "^1.4.17",
"seamless-immutable": "^7.0.1",
"source-map-loader": "^0.1.6",
"style-loader": "^4.0.0",
"styled-components": "^4.2.1",
Expand Down
1 change: 0 additions & 1 deletion packages/cbioportal-frontend-commons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"react-overlays": "0.7.4",
"react-select": "^3.0.4",
"save-svg-as-png": "^1.4.17",
"seamless-immutable": "^7.0.1",
"superagent": "^3.8.3",
"svg2pdf.js": "github:cbioportal/svg2pdf.js#v1.3.3-cbio-patch-1",
"typescript": "4.0.3",
Expand Down
4 changes: 0 additions & 4 deletions packages/cbioportal-frontend-commons/src/api/remoteData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ export function addServiceErrorHandler(handler: errorHandler) {
return JSON.stringify(this.result);
};

/**
* Constructs a MobxPromise which will call seamlessImmutable.from() on the result and the default value.
*/

export const remoteData: MobxPromiseFactory = function<R>(
input: MobxPromiseInputUnion<R>,
defaultResult?: R
Expand Down
12 changes: 3 additions & 9 deletions packages/cbioportal-frontend-commons/src/lib/SimpleCache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { observable, action, makeObservable } from 'mobx';
import Immutable from 'seamless-immutable';

export interface ICacheData<T> {
status: 'pending' | 'complete' | 'error';
Expand All @@ -10,19 +9,16 @@ export interface ICache<T> {
[queryId: string]: ICacheData<T>;
}

export type ImmutableCache<T> = ICache<T> &
Immutable.ImmutableObject<ICache<T>>;

/**
* @author Selcuk Onur Sumer
*/
export default class SimpleCache<T, Query> {
@observable.ref protected _cache: ImmutableCache<T>;
@observable.ref protected _cache: ICache<T>;
protected _pendingCache: ICache<T>;

constructor() {
makeObservable<SimpleCache<T, Query>, '_cache' | 'putData'>(this);
this._cache = Immutable.from<ICache<T>>({});
this._cache = {};
this._pendingCache = {};
}

Expand Down Expand Up @@ -86,9 +82,7 @@ export default class SimpleCache<T, Query> {

// put the data into the actual cache
if (Object.keys(data).length > 0) {
this._cache = this._cache.merge(data, {
deep: true,
}) as ImmutableCache<T>;
this._cache = { ...this._cache, ...data };
}
}
}
1 change: 0 additions & 1 deletion packages/react-mutation-mapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"react-rangeslider": "^2.2.0",
"react-select": "^3.0.4",
"react-table": "^6.10.0",
"seamless-immutable": "^7.1.4",
"superagent": "^3.8.3",
"typescript": "4.0.3"
}
Expand Down
1 change: 0 additions & 1 deletion packages/react-variant-view/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"react-rangeslider": "^2.2.0",
"react-select": "^3.0.4",
"react-table": "^6.10.0",
"seamless-immutable": "^7.1.4",
"superagent": "^3.8.3",
"typescript": "4.0.3"
}
Expand Down
27 changes: 1 addition & 26 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 20 additions & 9 deletions src/pages/patientView/clinicalInformation/SampleGeneCache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { observable, action, makeObservable } from 'mobx';
import Immutable from 'seamless-immutable';
import _ from 'lodash';
import accumulatingDebounce from '../../../shared/lib/accumulatingDebounce';

Expand Down Expand Up @@ -32,8 +31,7 @@ type SampleToEntrezSet = { [sampleId: string]: { [entrez: string]: true } };
export default class SampleGeneCache<
T extends { sampleId: string; entrezGeneId: number }
> {
@observable.ref private _cache: Cache<T> &
Immutable.ImmutableObject<Cache<T>>;
@observable.ref private _cache: Cache<T>;
private _pending: PendingCache;
private dependencies: any[];

Expand Down Expand Up @@ -158,7 +156,7 @@ export default class SampleGeneCache<
geneData: {},
};
}
this._cache = Immutable.from<Cache<T>>(_cache);
this._cache = _cache;
}

private markError(sampleToEntrezList: SampleToEntrezListOrNull) {
Expand Down Expand Up @@ -288,11 +286,24 @@ export default class SampleGeneCache<
}

@action private updateCache(toMerge: CacheMerge<T>) {
if (Object.keys(toMerge).length > 0) {
this._cache = this._cache.merge(toMerge, { deep: true }) as Cache<
T
> &
Immutable.ImmutableObject<Cache<T>>;
if (Object.keys(toMerge).length === 0) {
return;
}
const merged: Cache<T> = { ...this._cache };
for (const sampleId of Object.keys(toMerge)) {
const existing = merged[sampleId] || {
fetchedWithoutGeneArgument: false as const,
geneData: {},
};
const update = toMerge[sampleId];
merged[sampleId] = {
fetchedWithoutGeneArgument:
update.fetchedWithoutGeneArgument !== undefined
? update.fetchedWithoutGeneArgument
: existing.fetchedWithoutGeneArgument,
geneData: { ...existing.geneData, ...(update.geneData || {}) },
};
}
this._cache = merged;
}
}
2 changes: 0 additions & 2 deletions src/shared/components/lazyMobXTable/LazyMobXTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ export function lazyMobXTableSort<T>(
}[] = [];

for (let i = 0; i < data.length; i++) {
// Have to do this loop instead of using data.map because we need dataAndValue to be mutable,
// and Immutable.js makes .map return another immutable structure;
const d = data[i];
dataAndValue.push({
data: d,
Expand Down
12 changes: 3 additions & 9 deletions src/shared/lib/LazyMobXCache.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Immutable from 'seamless-immutable'; // need to use immutables so mobX can observe the cache shallowly
import accumulatingDebounce from './accumulatingDebounce';
import { observable, action, reaction, makeObservable } from 'mobx';
import { AccumulatingDebouncedFunction } from './accumulatingDebounce';
Expand All @@ -23,9 +22,6 @@ type Pending = {
[key: string]: boolean;
};

type ImmutableCache<D, M> = Cache<D, M> &
Immutable.ImmutableObject<Cache<D, M>>;

type QueryKeyToQuery<Q> = { [queryKey: string]: Q };

export type AugmentedData<D, M> = {
Expand All @@ -48,7 +44,7 @@ function isAugmentedData<D, M>(
}

export default class LazyMobXCache<Data, Query, Metadata = any> {
@observable.ref private _cache: ImmutableCache<Data, Metadata>;
@observable.ref private _cache: Cache<Data, Metadata>;
private pending: Pending;

private staticDependencies: any[];
Expand Down Expand Up @@ -102,7 +98,7 @@ export default class LazyMobXCache<Data, Query, Metadata = any> {

private init() {
this.pending = {};
this._cache = Immutable.from<Cache<Data, Metadata>>({});
this._cache = {};
this.promises = [];
}
public get cache() {
Expand Down Expand Up @@ -298,9 +294,7 @@ export default class LazyMobXCache<Data, Query, Metadata = any> {

@action private updateCache(toMerge: Cache<Data, Metadata>) {
if (Object.keys(toMerge).length > 0) {
this._cache = this._cache.merge(toMerge, {
deep: true,
}) as ImmutableCache<Data, Metadata>;
this._cache = { ...this._cache, ...toMerge };
}
}
}
1 change: 0 additions & 1 deletion typings/missing.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ declare module 'object-sizeof';
declare module 'save-svg-as-png';
declare module 'react-file-download';
declare module 'reactableMSK';
declare module 'redux-seamless-immutable';
declare module 'react-if';
declare module 'webpack-raphael';
declare module 'javascript-natural-sort';
Expand Down
Loading