Skip to content

Commit a3ff3ad

Browse files
author
Daniel Herzog
committed
DFL-3621: Resources UI is affected by clearing the network log; Cleaned up get_entries vs get_entries_filtered
1 parent 936c951 commit a3ff3ad

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

src/network/network_service.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cls.NetworkLogger = function()
1111
{
1212
// ids is an optional array of entry ids.
1313
var ctx = this.get_logger_context();
14-
var entries = ctx && ctx.get_entries(true) || [];
14+
var entries = ctx && ctx.get_entries() || [];
1515
if (ids)
1616
{
1717
var filter_bound = this._filter_entries_by_list.bind(this, ids);
@@ -59,11 +59,6 @@ cls.NetworkLogger = function()
5959
this.post("context-removed", {"context_type": type});
6060
};
6161

62-
this.remove_logger_request_context = function()
63-
{
64-
return this._remove_request_context(cls.NetworkLogger.CONTEXT_TYPE_LOGGER);
65-
};
66-
6762
this.remove_crafter_request_context = function()
6863
{
6964
return this._remove_request_context(cls.NetworkLogger.CONTEXT_TYPE_CRAFTER);
@@ -430,6 +425,7 @@ cls.RequestContext = function(logger, is_main_context)
430425
is_blacklist: true
431426
};
432427
this.allocated_res_ids = [];
428+
this._cleared_ids = [];
433429
this.is_paused = false;
434430
this.is_waiting_for_create_request = false;
435431
this._logger_entries = [];
@@ -456,6 +452,9 @@ cls.RequestContextPrototype = function()
456452

457453
this._filter_function = function(item)
458454
{
455+
if (this._cleared_ids.contains(item.id))
456+
return false;
457+
459458
var success = false;
460459
for (var i = 0, filter; filter = this._filters[i]; i++)
461460
{
@@ -478,16 +477,13 @@ cls.RequestContextPrototype = function()
478477

479478
this.get_entries_filtered = function()
480479
{
481-
return this.get_entries().filter(this._filter_function_bound);
480+
var entries = this.is_paused ? this._paused_entries : this._logger_entries;
481+
return entries.filter(this._filter_function_bound);
482482
};
483483

484-
this.get_entries = function(dismiss_paused)
484+
this.get_entries = function()
485485
{
486-
var entries = this._logger_entries;
487-
if (!dismiss_paused && this.is_paused)
488-
entries = this._paused_entries;
489-
490-
return entries;
486+
return this._logger_entries;
491487
};
492488

493489
this.get_entries_with_res_id = function(res_id)
@@ -574,6 +570,8 @@ cls.RequestContextPrototype = function()
574570
event.windowID,
575571
this.get_starttime());
576572
this._logger_entries.push(logger_entry);
573+
if (this.after_clear)
574+
this.after_clear = false;
577575
// Store the id in the list of entries in the window_context
578576
var window_context = event.windowID && this.get_window_context(event.windowID, true);
579577
if (window_context)
@@ -583,6 +581,13 @@ cls.RequestContextPrototype = function()
583581
this.post_on_context_or_logger("resource-update", {id: logger_entry.id, is_paused: this.is_paused});
584582
};
585583

584+
this.clear = function()
585+
{
586+
var helpers = window.helpers;
587+
this._cleared_ids.extend(this.get_entries().map(helpers.prop("id")));
588+
this.after_clear = true;
589+
};
590+
586591
this.post_on_context_or_logger = function(name, body)
587592
{
588593
// Find out where to post the update message.

src/network/network_view.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ cls.NetworkLogView = function(id, name, container_class, html, default_handler,
5151
this._container = container;
5252

5353
var ctx = this.network_logger.get_logger_context();
54-
if (ctx)
54+
if (ctx && !ctx.after_clear)
5555
{
5656
if (this._type_filters)
5757
ctx.set_filters(this._type_filters);
@@ -433,8 +433,14 @@ cls.NetworkLogView = function(id, name, container_class, html, default_handler,
433433

434434
this._on_clear_log_bound = function(evt, target)
435435
{
436-
this.network_logger.remove_logger_request_context();
437-
this.needs_instant_update = true;
436+
// this.network_logger.remove_logger_request_context();
437+
var ctx = this.network_logger.get_logger_context();
438+
if (ctx)
439+
{
440+
ctx.clear();
441+
this.needs_instant_update = true;
442+
this.update();
443+
}
438444
}.bind(this);
439445

440446
this._on_close_incomplete_warning_bound = function(evt, target)

0 commit comments

Comments
 (0)