Skip to content

Commit 5db8bfe

Browse files
committed
Merge branch 'feat/media-quotes-5645' into 'master'
Media quotes #5645 See merge request minds/front!2006
2 parents 5b5e90d + 6a89361 commit 5db8bfe

File tree

8 files changed

+65
-5
lines changed

8 files changed

+65
-5
lines changed

src/app/modules/composer/components/toolbar/toolbar.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
(onSelect)="onAttachmentSelect($event)"
2323
accept="image/*,video/*,video/mp4,video/x-m4v"
2424
data-cy="upload-button"
25-
*ngIf="!(remind$ | async)"
25+
*ngIf="fileUploadVisible$ | async"
2626
#fileUploadComponent
2727
>
2828
<m-icon

src/app/modules/composer/components/toolbar/toolbar.component.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import { ScheduleComponent } from '../popup/schedule/schedule.component';
1010
import { ToasterService } from '../../../../common/services/toaster.service';
1111
import { ButtonComponent } from '../../../../common/components/button/button.component';
1212
import { BehaviorSubject } from 'rxjs';
13+
import { MediaQuotesExperimentService } from '../../../experiments/sub-services/media-quotes-experiment.service';
14+
15+
export let mediaQuotesExperimentServiceMock = new (function() {
16+
this.isActive = jasmine.createSpy('isActive').and.returnValue(true);
17+
})();
1318

1419
describe('Composer Toolbar', () => {
1520
let comp: ToolbarComponent;
@@ -36,20 +41,24 @@ describe('Composer Toolbar', () => {
3641

3742
const size$ = new BehaviorSubject<ComposerSize>('full');
3843

44+
const remind$ = new BehaviorSubject(null);
45+
3946
const composerServiceMock: any = MockService(ComposerService, {
4047
has: [
4148
'attachment$',
4249
'isEditing$',
4350
'monetization$',
4451
'size$',
4552
'attachmentError$',
53+
'remind$',
4654
],
4755
props: {
4856
attachment$: { get: () => attachment$ },
4957
isEditing$: { get: () => isEditing$ },
5058
monetization$: { get: () => monetization$ },
5159
size$: { get: () => size$ },
5260
attachmentError$: { get: () => attachmentError$ },
61+
remind$: { get: () => remind$ },
5362
},
5463
});
5564

@@ -92,6 +101,10 @@ describe('Composer Toolbar', () => {
92101
provide: ToasterService,
93102
useValue: MockService(ToasterService),
94103
},
104+
{
105+
provide: MediaQuotesExperimentService,
106+
useValue: mediaQuotesExperimentServiceMock,
107+
},
95108
],
96109
}).compileComponents();
97110
})

src/app/modules/composer/components/toolbar/toolbar.component.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { isPlatformBrowser } from '@angular/common';
3838
import { ToasterService } from '../../../../common/services/toaster.service';
3939
import { AttachmentErrorComponent } from '../popup/attachment-error/attachment-error.component';
4040
import isMobile from '../../../../helpers/is-mobile';
41+
import { MediaQuotesExperimentService } from '../../../experiments/sub-services/media-quotes-experiment.service';
4142

4243
/**
4344
* Composer toolbar. Displays important actions
@@ -110,7 +111,8 @@ export class ToolbarComponent implements OnInit, AfterViewInit, OnDestroy {
110111
protected popup: PopupService,
111112
protected cd: ChangeDetectorRef,
112113
protected toaster: ToasterService,
113-
@Inject(PLATFORM_ID) protected platformId: Object
114+
@Inject(PLATFORM_ID) protected platformId: Object,
115+
protected mediaQuotesExperiment: MediaQuotesExperimentService
114116
) {}
115117

116118
/**
@@ -408,6 +410,16 @@ export class ToolbarComponent implements OnInit, AfterViewInit, OnDestroy {
408410
return isMobile();
409411
}
410412

413+
fileUploadVisible$ = this.remind$.pipe(
414+
map(remind => {
415+
if (this.mediaQuotesExperiment.isActive()) {
416+
return true;
417+
}
418+
419+
return !remind;
420+
})
421+
);
422+
411423
/**
412424
* Triggers change detection
413425
*/
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Injectable } from '@angular/core';
2+
import { ExperimentsService } from '../experiments.service';
3+
4+
/**
5+
* https://growthbook.minds.com/features/front-5645-media-quotes
6+
*/
7+
@Injectable({ providedIn: 'root' })
8+
export class MediaQuotesExperimentService {
9+
constructor(private experiments: ExperimentsService) {}
10+
11+
/**
12+
* Returns true if the media quotes experiment is active.
13+
* @returns { boolean } whether media quotes experiment is active.
14+
*/
15+
public isActive(): boolean {
16+
return this.experiments.hasVariation('front-5645-media-quotes', true);
17+
}
18+
}

src/app/modules/newsfeed/activity-v2/content/content.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<m-videoPlayer--scrollaware
7070
#videoEl
7171
[guid]="videoGuid"
72-
[shouldPlayInModal]="!isModal"
72+
[shouldPlayInModal]="entity.remind_object ? false : !isModal"
7373
(mediaModalRequested)="onModalRequested($event)"
7474
[autoplay]="
7575
service.displayOptions.autoplayVideo &&

src/app/modules/newsfeed/activity-v2/content/content.component.ng.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@
257257
// ** QUOTE **
258258
// *********************************
259259

260+
.m-activityContent__media + .m-activityContent__quote {
261+
margin-top: $spacing4;
262+
}
263+
260264
.m-activityContent--quote {
261265
overflow: hidden;
262266

src/app/modules/newsfeed/activity-v2/content/content.component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,12 @@ export class ActivityV2ContentComponent
621621
return;
622622
}
623623

624+
// We don't support showing media quotes in modal yet
625+
if (this.entity.remind_object) {
626+
this.redirectToSinglePage();
627+
return;
628+
}
629+
624630
if (
625631
this.service.displayOptions.bypassMediaModal &&
626632
this.entity.content_type !== 'image' &&
@@ -669,7 +675,10 @@ export class ActivityV2ContentComponent
669675
}
670676

671677
redirectToSinglePage(): void {
672-
this.router.navigateByUrl(this.canonicalUrl);
678+
// don't navigate if we're already there
679+
if (this.router.url !== this.canonicalUrl) {
680+
this.router.navigateByUrl(this.canonicalUrl);
681+
}
673682
}
674683

675684
onImageError(e: Event): void {}

src/app/modules/newsfeed/activity/activity.service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,11 @@ export class ActivityService implements OnDestroy {
396396
}
397397

398398
buildCanonicalUrl(entity: ActivityEntity, full: boolean): string {
399-
const guid = entity.entity_guid || entity.guid;
399+
let guid = entity.entity_guid || entity.guid;
400+
// use the entity guid for media quotes
401+
if (entity.remind_object && entity.entity_guid) {
402+
guid = entity.guid;
403+
}
400404
const prefix = full ? this.siteUrl : '/';
401405
return `${prefix}newsfeed/${guid}`;
402406
}

0 commit comments

Comments
 (0)