Skip to content

Commit 17808cb

Browse files
author
p01
committed
Cleaner get_resource(id) and get_resource_for_url(url)
1 parent e41567e commit 17808cb

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/resource-manager/resource_service.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -245,27 +245,24 @@ cls.ResourceManagerService = function(view, network_logger)
245245
return this._context;
246246
};
247247

248-
249248
this.get_resource = function(id)
250249
{
251250
var ctx = this._context;
252-
if (!ctx || ctx._resourceHash[id]==null)
253-
return null;
251+
if (!ctx)
252+
return null;
254253

255-
return ctx.resourceList[ctx._resourceHash[id]];
254+
var resource = ctx.resourceList.filter(function(v){return v.id==id;});
255+
return resource && resource.last;
256256
};
257257

258-
259258
this.get_resource_for_url = function(url)
260259
{
261-
if (!this._context)
262-
return null;
263-
264-
var id = this._context.resourcesUrlDict[url];
265-
if (id===undefined)
260+
var ctx = this._context;
261+
if (!ctx)
266262
return null;
267263

268-
return this.get_resource(id);
264+
var resource = ctx.resourceList.filter(function(v){return v.url==url;});
265+
return resource && resource.last;
269266
};
270267

271268
this._fetch_resource_data = function(callback, id, type)
@@ -295,8 +292,6 @@ cls.ResourceManagerService = function(view, network_logger)
295292
this._view.update();
296293
}.bind(this);
297294

298-
299-
300295
this.request_resource_for_url = function(url,callback)
301296
{
302297
cls.ResourceRequest(url, callback, data);

0 commit comments

Comments
 (0)