...
 
Commits (7)
......@@ -3,6 +3,7 @@ import 'reflect-metadata';
import { join } from 'path';
import { readFileSync } from 'fs';
import * as _url from 'url';
import { ngExpressEngine } from '@nguniversal/express-engine';
import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
......@@ -171,6 +172,14 @@ app.get('*', cache(), (req, res) => {
provide: 'ORIGIN_URL',
useValue: `${http}://${req.headers.host}`,
},
// for initial query params before router loads
{
provide: 'QUERY_STRING',
useFactory: () => {
return _url.parse(req.url, true).search || '';
},
deps: [],
},
],
},
(err, html) => {
......
......@@ -12,6 +12,9 @@ PlotlyModule.plotlyjs = PlotlyJS;
@NgModule({
imports: [MindsModule, PlotlyModule, CookieModule],
bootstrap: [Minds],
providers: [{ provide: 'ORIGIN_URL', useValue: location.origin }],
providers: [
{ provide: 'ORIGIN_URL', useValue: location.origin },
{ provide: 'QUERY_STRING', useValue: location.search || '' },
],
})
export class AppBrowserModule {}
import { NgModule, inject } from '@angular/core';
import { NgModule, inject, Injector } from '@angular/core';
import {
CommonModule as NgCommonModule,
isPlatformServer,
......@@ -432,8 +432,9 @@ const routes: Routes = [
},
{
provide: ConfigsService,
useFactory: client => new ConfigsService(client),
deps: [Client],
useFactory: (client, injector) =>
new ConfigsService(client, injector.get('QUERY_STRING')),
deps: [Client, Injector],
},
{
provide: MetaService,
......
import { Client } from '../api/client.service';
import { Injectable } from '@angular/core';
import { Injectable, Inject, Optional } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { map, tap } from 'rxjs/operators';
......@@ -7,11 +7,16 @@ import { map, tap } from 'rxjs/operators';
export class ConfigsService {
private configs = {};
constructor(private client: Client) {}
constructor(
private client: Client,
@Inject('QUERY_STRING') private queryString: string
) {}
async loadFromRemote() {
try {
this.configs = await this.client.get('api/v1/minds/config');
this.configs = await this.client.get(
`api/v1/minds/config${this.queryString}`
);
} catch (err) {
console.error(err);
}
......
......@@ -45,7 +45,7 @@
<h2>Experiments</h2>
<ul class="m-canaryExperiments__list">
<li>
Discovery algorithm by post age - 11th December '19
Server Side Rendering - 5th Feb 2020
</li>
</ul>
</div>
......
......@@ -109,7 +109,7 @@ describe('ChannelComponent', () => {
{ provide: FeaturesService, useValue: featuresServiceMock },
{ provide: BlockListService, useValue: MockService(BlockListService) },
{ provide: ClientMetaService, useValue: clientMetaServiceMock },
ConfigsService,
{ provide: ConfigsService, useValue: MockService(ConfigsService) },
],
}).compileComponents(); // compile template and css
}));
......
......@@ -18,7 +18,7 @@
*ngIf="group && (group['is:member'] || group.membership == 2)"
>
<!-- Sidebar -->
<div class="m-groupGrid__left">
<div class="m-groupGrid__left" *mIfBrowser>
<m-videochat></m-videochat>
<header
......@@ -328,7 +328,7 @@
<div class="m-groupGrid__right" [hidden]="!showRight">
<!-- Conversation filter -->
<minds-groups-profile-conversation [group]="group">
<minds-groups-profile-conversation [group]="group" *mIfBrowser>
</minds-groups-profile-conversation>
<!-- END: Conversation filter -->
</div>
......
......@@ -183,8 +183,9 @@ export class GroupsProfile {
}
async load() {
if (isPlatformServer(this.platformId)) return;
this.resetMarkers();
if (isPlatformBrowser(this.platformId)) {
this.resetMarkers();
}
this.error = '';
this.group = null;
......@@ -199,38 +200,41 @@ export class GroupsProfile {
if (this.updateMarkersSubscription)
this.updateMarkersSubscription.unsubscribe();
this.updateMarkersSubscription = this.updateMarkers
.getByEntityGuid(this.guid)
.subscribe(
(marker => {
// this.updateMarkersSubscription = this.updateMarkers.markers.subscribe(markers => {
if (!marker) return;
this.group.hasGathering$ = interval(1000).pipe(
throttle(() => interval(2000)), //only allow once per 2 seconds
startWith(0),
map(
() =>
[marker].filter(
marker =>
marker.entity_guid == this.group.guid &&
marker.marker == 'gathering-heartbeat' &&
marker.updated_timestamp > Date.now() / 1000 - 60 //1 minute tollerance
).length > 0
)
);
let hasMarker =
marker.read_timestamp < marker.updated_timestamp &&
marker.entity_guid == this.group.guid &&
marker.marker != 'gathering-heartbeat';
if (hasMarker) this.resetMarkers();
}).bind(this)
);
// Check for comment updates
this.joinCommentsSocketRoom();
if (isPlatformBrowser(this.platformId)) {
this.updateMarkersSubscription = this.updateMarkers
.getByEntityGuid(this.guid)
.subscribe(
(marker => {
// this.updateMarkersSubscription = this.updateMarkers.markers.subscribe(markers => {
if (!marker) return;
this.group.hasGathering$ = interval(1000).pipe(
throttle(() => interval(2000)), //only allow once per 2 seconds
startWith(0),
map(
() =>
[marker].filter(
marker =>
marker.entity_guid == this.group.guid &&
marker.marker == 'gathering-heartbeat' &&
marker.updated_timestamp > Date.now() / 1000 - 60 //1 minute tollerance
).length > 0
)
);
let hasMarker =
marker.read_timestamp < marker.updated_timestamp &&
marker.entity_guid == this.group.guid &&
marker.marker != 'gathering-heartbeat';
if (hasMarker) this.resetMarkers();
}).bind(this)
);
// Check for comment updates
this.joinCommentsSocketRoom();
}
this.updateMeta();
this.context.set('activity', {
......
......@@ -67,7 +67,7 @@ export class SearchBarComponent {
}
unListen() {
this.routerSubscription.unsubscribe();
if (this.routerSubscription) this.routerSubscription.unsubscribe();
}
handleUrl(url: string) {
......
......@@ -19,6 +19,8 @@ export class FeaturesService {
has(feature: string): boolean {
const features = this.configs.get('features');
if (!features) return false;
if (!feature) {
throw new Error('Invalid feature ID');
}
......
import { NgZone, RendererFactory2, PLATFORM_ID } from '@angular/core';
import { NgZone, RendererFactory2, PLATFORM_ID, Injector } from '@angular/core';
import { Router } from '@angular/router';
import { Location } from '@angular/common';
import { TransferState } from '@angular/platform-browser';
......@@ -186,8 +186,9 @@ export const MINDS_PROVIDERS: any[] = [
},
{
provide: ConfigsService,
useFactory: client => new ConfigsService(client),
deps: [Client],
useFactory: (client, injector) =>
new ConfigsService(client, injector.get('QUERY_STRING')),
deps: [Client, Injector],
},
{
provide: FeaturesService,
......