Loading src/app/common/components/sort-selector/sort-selector.component.ts +3 −3 Original line number Original line Diff line number Diff line Loading @@ -56,10 +56,10 @@ export class SortSelectorComponent implements OnInit, OnDestroy, AfterViewInit { id: '30d', id: '30d', label: '30d', label: '30d', }, }, /*{ { id: '1y', id: '1y', label: '1y' label: '1y', },*/ }, ]; ]; customTypes: Array<{ id; label; icon? }> = [ customTypes: Array<{ id; label; icon? }> = [ Loading src/app/common/services/feeds.service.ts +22 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,8 @@ import { switchMap, map, tap, first } from 'rxjs/operators'; export class FeedsService { export class FeedsService { limit: BehaviorSubject<number> = new BehaviorSubject(12); limit: BehaviorSubject<number> = new BehaviorSubject(12); offset: BehaviorSubject<number> = new BehaviorSubject(0); offset: BehaviorSubject<number> = new BehaviorSubject(0); fallbackAt: number | null = null; fallbackAtIndex: BehaviorSubject<number | null> = new BehaviorSubject(null); pageSize: Observable<number>; pageSize: Observable<number>; pagingToken: string = ''; pagingToken: string = ''; canFetchMore: boolean = true; canFetchMore: boolean = true; Loading Loading @@ -50,6 +52,22 @@ export class FeedsService { .setCastToActivities(this.castToActivities) .setCastToActivities(this.castToActivities) .getFromFeed(feed) .getFromFeed(feed) ), ), tap(feed => { if (feed.length && this.fallbackAt) { for (let i = 0; i < feed.length; i++) { const entity: any = feed[i].getValue(); if ( entity && entity.time_created && entity.time_created < this.fallbackAt ) { this.fallbackAtIndex.next(i); break; } } } }), tap(feed => { tap(feed => { if (feed.length) if (feed.length) // We should have skipped but.. // We should have skipped but.. Loading Loading @@ -143,6 +161,8 @@ export class FeedsService { response.entities = response.activity; response.entities = response.activity; } } if (response.entities.length) { if (response.entities.length) { this.fallbackAt = response['fallback_at']; this.fallbackAtIndex.next(null); this.rawFeed.next(this.rawFeed.getValue().concat(response.entities)); this.rawFeed.next(this.rawFeed.getValue().concat(response.entities)); this.pagingToken = response['load-next']; this.pagingToken = response['load-next']; } else { } else { Loading @@ -168,6 +188,8 @@ export class FeedsService { * To clear data. * To clear data. */ */ clear(): FeedsService { clear(): FeedsService { this.fallbackAt = null; this.fallbackAtIndex.next(null); this.offset.next(0); this.offset.next(0); this.pagingToken = ''; this.pagingToken = ''; this.rawFeed.next([]); this.rawFeed.next([]); Loading src/app/modules/newsfeed/feeds/sorted.component.html +16 −5 Original line number Original line Diff line number Diff line Loading @@ -30,7 +30,7 @@ [class.m-feeds-sortedList__flex]="!isActivityFeed()" [class.m-feeds-sortedList__flex]="!isActivityFeed()" > > <ng-container <ng-container *ngFor="let entity of feedsService.feed | async; let i = index" *ngFor="let entity$ of feedsService.feed | async; let i = index" > > <ng-container *ngIf="isActivityFeed()"> <ng-container *ngIf="isActivityFeed()"> <m-featured-content <m-featured-content Loading @@ -39,11 +39,22 @@ ></m-featured-content> ></m-featured-content> </ng-container> </ng-container> <ng-container *mIfFeature="'top-feeds-by-age'"> <div *ngIf="i === (feedsService.fallbackAtIndex | async)" class="m-feeds-sorted__fallbackLegend" > <span i18n>Posts older than {{ period | uppercase }}</span> </div> </ng-container> <ng-container *ngIf="entity$ | async as entity"> <m-newsfeed__entity <m-newsfeed__entity [entity]="entity | async" [entity]="entity" [slot]="i + 1" [slot]="i + 1" ></m-newsfeed__entity> ></m-newsfeed__entity> </ng-container> </ng-container> </ng-container> <infinite-scroll <infinite-scroll distance="25%" distance="25%" Loading src/app/modules/newsfeed/feeds/sorted.component.scss +30 −0 Original line number Original line Diff line number Diff line Loading @@ -42,6 +42,36 @@ m-newsfeed--sorted { } } } } .m-feeds-sorted__fallbackLegend { text-align: center; margin: 32px auto 28px; height: 0; position: relative; border-top: 1px solid; @include m-theme() { border-top-color: themed($m-grey-200); } > span { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: inline-block; padding: 0 12px; font-size: 11px; line-height: 1; letter-spacing: 0.5px; text-transform: uppercase; @include m-theme() { color: themed($m-grey-400); background: themed($m-body-bg); } } } .m-feeds-sorted__query { .m-feeds-sorted__query { font-size: 16px; font-size: 16px; letter-spacing: 1px; letter-spacing: 1px; Loading src/app/modules/newsfeed/feeds/sorted.component.ts +1 −0 Original line number Original line Diff line number Diff line Loading @@ -230,6 +230,7 @@ export class NewsfeedSortedComponent implements OnInit, OnDestroy { all, all, query, query, nsfw, nsfw, period_fallback: 1, }) }) .setLimit(12) .setLimit(12) .setCastToActivities(true) .setCastToActivities(true) Loading Loading
src/app/common/components/sort-selector/sort-selector.component.ts +3 −3 Original line number Original line Diff line number Diff line Loading @@ -56,10 +56,10 @@ export class SortSelectorComponent implements OnInit, OnDestroy, AfterViewInit { id: '30d', id: '30d', label: '30d', label: '30d', }, }, /*{ { id: '1y', id: '1y', label: '1y' label: '1y', },*/ }, ]; ]; customTypes: Array<{ id; label; icon? }> = [ customTypes: Array<{ id; label; icon? }> = [ Loading
src/app/common/services/feeds.service.ts +22 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,8 @@ import { switchMap, map, tap, first } from 'rxjs/operators'; export class FeedsService { export class FeedsService { limit: BehaviorSubject<number> = new BehaviorSubject(12); limit: BehaviorSubject<number> = new BehaviorSubject(12); offset: BehaviorSubject<number> = new BehaviorSubject(0); offset: BehaviorSubject<number> = new BehaviorSubject(0); fallbackAt: number | null = null; fallbackAtIndex: BehaviorSubject<number | null> = new BehaviorSubject(null); pageSize: Observable<number>; pageSize: Observable<number>; pagingToken: string = ''; pagingToken: string = ''; canFetchMore: boolean = true; canFetchMore: boolean = true; Loading Loading @@ -50,6 +52,22 @@ export class FeedsService { .setCastToActivities(this.castToActivities) .setCastToActivities(this.castToActivities) .getFromFeed(feed) .getFromFeed(feed) ), ), tap(feed => { if (feed.length && this.fallbackAt) { for (let i = 0; i < feed.length; i++) { const entity: any = feed[i].getValue(); if ( entity && entity.time_created && entity.time_created < this.fallbackAt ) { this.fallbackAtIndex.next(i); break; } } } }), tap(feed => { tap(feed => { if (feed.length) if (feed.length) // We should have skipped but.. // We should have skipped but.. Loading Loading @@ -143,6 +161,8 @@ export class FeedsService { response.entities = response.activity; response.entities = response.activity; } } if (response.entities.length) { if (response.entities.length) { this.fallbackAt = response['fallback_at']; this.fallbackAtIndex.next(null); this.rawFeed.next(this.rawFeed.getValue().concat(response.entities)); this.rawFeed.next(this.rawFeed.getValue().concat(response.entities)); this.pagingToken = response['load-next']; this.pagingToken = response['load-next']; } else { } else { Loading @@ -168,6 +188,8 @@ export class FeedsService { * To clear data. * To clear data. */ */ clear(): FeedsService { clear(): FeedsService { this.fallbackAt = null; this.fallbackAtIndex.next(null); this.offset.next(0); this.offset.next(0); this.pagingToken = ''; this.pagingToken = ''; this.rawFeed.next([]); this.rawFeed.next([]); Loading
src/app/modules/newsfeed/feeds/sorted.component.html +16 −5 Original line number Original line Diff line number Diff line Loading @@ -30,7 +30,7 @@ [class.m-feeds-sortedList__flex]="!isActivityFeed()" [class.m-feeds-sortedList__flex]="!isActivityFeed()" > > <ng-container <ng-container *ngFor="let entity of feedsService.feed | async; let i = index" *ngFor="let entity$ of feedsService.feed | async; let i = index" > > <ng-container *ngIf="isActivityFeed()"> <ng-container *ngIf="isActivityFeed()"> <m-featured-content <m-featured-content Loading @@ -39,11 +39,22 @@ ></m-featured-content> ></m-featured-content> </ng-container> </ng-container> <ng-container *mIfFeature="'top-feeds-by-age'"> <div *ngIf="i === (feedsService.fallbackAtIndex | async)" class="m-feeds-sorted__fallbackLegend" > <span i18n>Posts older than {{ period | uppercase }}</span> </div> </ng-container> <ng-container *ngIf="entity$ | async as entity"> <m-newsfeed__entity <m-newsfeed__entity [entity]="entity | async" [entity]="entity" [slot]="i + 1" [slot]="i + 1" ></m-newsfeed__entity> ></m-newsfeed__entity> </ng-container> </ng-container> </ng-container> <infinite-scroll <infinite-scroll distance="25%" distance="25%" Loading
src/app/modules/newsfeed/feeds/sorted.component.scss +30 −0 Original line number Original line Diff line number Diff line Loading @@ -42,6 +42,36 @@ m-newsfeed--sorted { } } } } .m-feeds-sorted__fallbackLegend { text-align: center; margin: 32px auto 28px; height: 0; position: relative; border-top: 1px solid; @include m-theme() { border-top-color: themed($m-grey-200); } > span { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: inline-block; padding: 0 12px; font-size: 11px; line-height: 1; letter-spacing: 0.5px; text-transform: uppercase; @include m-theme() { color: themed($m-grey-400); background: themed($m-body-bg); } } } .m-feeds-sorted__query { .m-feeds-sorted__query { font-size: 16px; font-size: 16px; letter-spacing: 1px; letter-spacing: 1px; Loading
src/app/modules/newsfeed/feeds/sorted.component.ts +1 −0 Original line number Original line Diff line number Diff line Loading @@ -230,6 +230,7 @@ export class NewsfeedSortedComponent implements OnInit, OnDestroy { all, all, query, query, nsfw, nsfw, period_fallback: 1, }) }) .setLimit(12) .setLimit(12) .setCastToActivities(true) .setCastToActivities(true) Loading