From fcae4d57cd5b6fdf073763b0ad0e28bd1a55ae3b Mon Sep 17 00:00:00 2001 From: HardiReady Date: Sat, 3 Feb 2018 12:13:11 +0100 Subject: [PATCH] remove empty squads from army view; replace window.scroll with window.scrollTo() --- api/routes/overview.js | 29 +++++++++++-------- .../war-detail/war-detail.component.ts | 2 +- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/api/routes/overview.js b/api/routes/overview.js index ee96873..7d91db2 100644 --- a/api/routes/overview.js +++ b/api/routes/overview.js @@ -67,19 +67,24 @@ overview.route('/') if (err) { return next(err); } - const s = squad.toObject(); - s.members = squadMembers; - s.memberCount = squadMembers.length; - if (s.fraction === 'BLUFOR') { - delete s.fraction; - armyOverview.BLUFOR.squads.push(s); - countBlufor += s.members.length; - } - if (s.fraction === 'OPFOR') { - delete s.fraction; - armyOverview.OPFOR.squads.push(s); - countOpfor += s.members.length; + + // do not return empty squads + if (squadMembers.length > 0) { + const s = squad.toObject(); + s.members = squadMembers; + s.memberCount = squadMembers.length; + if (s.fraction === 'BLUFOR') { + delete s.fraction; + armyOverview.BLUFOR.squads.push(s); + countBlufor += s.members.length; + } + if (s.fraction === 'OPFOR') { + delete s.fraction; + armyOverview.OPFOR.squads.push(s); + countOpfor += s.members.length; + } } + callback(); }); }); diff --git a/static/src/app/statistic/war-detail/war-detail.component.ts b/static/src/app/statistic/war-detail/war-detail.component.ts index 8f22cec..98e9ac8 100644 --- a/static/src/app/statistic/war-detail/war-detail.component.ts +++ b/static/src/app/statistic/war-detail/war-detail.component.ts @@ -66,7 +66,7 @@ export class WarDetailComponent { this.fractionStatsInitialized = true; }); } - window.scroll({left: 0, top: 0, behavior: 'smooth'}); + window.scrollTo({left: 0, top: 0, behavior: 'smooth'}); } /**