From c7b256b16fa2d78cad5dd2a5401fd5ae8d2fcc99 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Wed, 12 Dec 2018 00:10:25 -0500 Subject: [PATCH 1/7] clean up --- .../stream/status/status.component.ts | 50 +------------------ 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/src/app/components/stream/status/status.component.ts b/src/app/components/stream/status/status.component.ts index 47c99fc2..d75842dc 100644 --- a/src/app/components/stream/status/status.component.ts +++ b/src/app/components/stream/status/status.component.ts @@ -1,11 +1,7 @@ -import { Component, OnInit, Input, Output, Inject, LOCALE_ID, ElementRef, EventEmitter, Pipe, PipeTransform, ViewChild, Renderer2 } from "@angular/core"; +import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core"; import { Status, Account } from "../../../services/models/mastodon.interfaces"; -import { formatDate } from '@angular/common'; -import { stateNameErrorMessage } from "@ngxs/store/src/decorators/state"; import { StatusWrapper } from "../stream.component"; -import { DomSanitizer } from '@angular/platform-browser' - @Component({ selector: "app-status", templateUrl: "./status.component.html", @@ -28,10 +24,6 @@ export class StatusComponent implements OnInit { this._statusWrapper = value; this.status = value.status; - //TEST - //this.status.content += '

TEST'; - - if (this.status.reblog) { this.reblog = true; this.displayedStatus = this.status.reblog; @@ -46,31 +38,16 @@ export class StatusComponent implements OnInit { if (this.displayedStatus.media_attachments && this.displayedStatus.media_attachments.length > 0) { this.hasAttachments = true; } - - } get statusWrapper(): StatusWrapper { return this._statusWrapper; } - - constructor(@Inject(LOCALE_ID) private locale: string) { } + constructor() { } ngOnInit() { } - // ngAfterViewInit() { - // let el = this.contentElement.nativeElement.querySelector('.test'); - // console.log(this.contentElement.nativeElement); - // console.log(el); - // if (el) - // this.renderer.listen(el, 'click', (el2) => { - // console.log(el2); - // console.warn('YOOOOO'); - // return false; - // }); - // } - openAccount(account: Account): boolean { let accountName = account.acct; if(!accountName.includes('@')) @@ -80,24 +57,6 @@ export class StatusComponent implements OnInit { return false; } - // getCompactRelativeTime(d: string): string { - // const date = (new Date(d)).getTime(); - // const now = Date.now(); - // const timeDelta = (now - date) / (1000); - - // if (timeDelta < 60) { - // return `${timeDelta | 0}s`; - // } else if (timeDelta < 60 * 60) { - // return `${timeDelta / 60 | 0}m`; - // } else if (timeDelta < 60 * 60 * 24) { - // return `${timeDelta / (60 * 60) | 0}h`; - // } else if (timeDelta < 60 * 60 * 24 * 31) { - // return `${timeDelta / (60 * 60 * 24) | 0}d`; - // } - - // return formatDate(date, 'MM/dd', this.locale); - // } - openReply(): boolean { this.replyingToStatus = !this.replyingToStatus; @@ -109,11 +68,6 @@ export class StatusComponent implements OnInit { return false; } - // test(): boolean { - // console.warn('heeeeyaaa!'); - // return false; - // } - accountSelected(accountName: string): void { console.warn(`status comp: accountSelected ${accountName}`); this.browseAccount.next(accountName); From 98d6fd696305633268bb2fee18c6801e6c6c5a8f Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Wed, 12 Dec 2018 01:08:29 -0500 Subject: [PATCH 2/7] starting integration of thread browsing --- .../floating-column.component.html | 8 +++- .../search/search.component.html | 8 ++-- .../search/search.component.ts | 20 ++++------ .../stream/hashtag/hashtag.component.html | 7 +++- .../stream/hashtag/hashtag.component.ts | 12 +++--- .../stream/status/status.component.ts | 16 ++++---- .../stream-overlay.component.html | 13 ++++--- .../stream-overlay.component.ts | 38 +++++++++++++------ .../stream-statuses.component.html | 2 +- .../stream-statuses.component.ts | 20 +++++----- .../components/stream/stream.component.html | 7 ++-- src/app/components/stream/stream.component.ts | 13 +++++-- .../user-profile/user-profile.component.html | 7 +++- .../user-profile/user-profile.component.ts | 12 +++--- 14 files changed, 106 insertions(+), 77 deletions(-) diff --git a/src/app/components/floating-column/floating-column.component.html b/src/app/components/floating-column/floating-column.component.html index bc8106b4..8ca112ed 100644 --- a/src/app/components/floating-column/floating-column.component.html +++ b/src/app/components/floating-column/floating-column.component.html @@ -1,5 +1,7 @@
- +
x @@ -8,6 +10,8 @@ - +
\ No newline at end of file diff --git a/src/app/components/floating-column/search/search.component.html b/src/app/components/floating-column/search/search.component.html index 619fbd67..1e2089e8 100644 --- a/src/app/components/floating-column/search/search.component.html +++ b/src/app/components/floating-column/search/search.component.html @@ -12,7 +12,7 @@
\ No newline at end of file diff --git a/src/app/components/floating-column/search/search.component.ts b/src/app/components/floating-column/search/search.component.ts index 1ec03ecf..dea93cbe 100644 --- a/src/app/components/floating-column/search/search.component.ts +++ b/src/app/components/floating-column/search/search.component.ts @@ -23,12 +23,11 @@ export class SearchComponent implements OnInit { isLoading: boolean; - @Output() browseAccount = new EventEmitter(); - @Output() browseHashtag = new EventEmitter(); - @Output() browseThread = new EventEmitter(); + @Output() browseAccountEvent = new EventEmitter(); + @Output() browseHashtagEvent = new EventEmitter(); + @Output() browseThreadEvent = new EventEmitter(); constructor( - private readonly store: Store, private readonly toolsService: ToolsService, private readonly mastodonService: MastodonService) { } @@ -41,9 +40,9 @@ export class SearchComponent implements OnInit { return false; } - selectHashtag(hashtag: string): boolean { + browseHashtag(hashtag: string): boolean { if (hashtag) { - this.browseHashtag.next(hashtag); + this.browseHashtagEvent.next(hashtag); } return false; } @@ -57,10 +56,10 @@ export class SearchComponent implements OnInit { // return false; // } - selectAccount(accountName: string): boolean { + browseAccount(accountName: string): boolean { console.warn(accountName); if (accountName) { - this.browseAccount.next(accountName); + this.browseAccountEvent.next(accountName); } return false; } @@ -97,9 +96,4 @@ export class SearchComponent implements OnInit { .then(() => { this.isLoading = false; }); } } - - private getRegisteredAccounts(): AccountInfo[] { - var regAccounts = this.store.snapshot().registeredaccounts.accounts; - return regAccounts; - } } diff --git a/src/app/components/stream/hashtag/hashtag.component.html b/src/app/components/stream/hashtag/hashtag.component.html index 5945cffd..6f09f0bc 100644 --- a/src/app/components/stream/hashtag/hashtag.component.html +++ b/src/app/components/stream/hashtag/hashtag.component.html @@ -6,6 +6,9 @@ - + \ No newline at end of file diff --git a/src/app/components/stream/hashtag/hashtag.component.ts b/src/app/components/stream/hashtag/hashtag.component.ts index f1f4835e..de2e0a1d 100644 --- a/src/app/components/stream/hashtag/hashtag.component.ts +++ b/src/app/components/stream/hashtag/hashtag.component.ts @@ -10,8 +10,8 @@ import { StreamElement, StreamTypeEnum, AddStream } from '../../../states/stream styleUrls: ['./hashtag.component.scss'] }) export class HashtagComponent implements OnInit { - @Output() browseAccount = new EventEmitter(); - @Output() browseHashtag = new EventEmitter(); + @Output() browseAccountEvent = new EventEmitter(); + @Output() browseHashtagEvent = new EventEmitter(); @Input() hashtagElement: StreamElement; @@ -38,11 +38,11 @@ export class HashtagComponent implements OnInit { return false; } - selectAccount(account: string) { - this.browseAccount.next(account); + browseAccount(account: string) { + this.browseAccountEvent.next(account); } - selectHashtag(hashtag: string) { - this.browseHashtag.next(hashtag); + browseHashtag(hashtag: string) { + this.browseHashtagEvent.next(hashtag); } } diff --git a/src/app/components/stream/status/status.component.ts b/src/app/components/stream/status/status.component.ts index d75842dc..a6390231 100644 --- a/src/app/components/stream/status/status.component.ts +++ b/src/app/components/stream/status/status.component.ts @@ -13,9 +13,9 @@ export class StatusComponent implements OnInit { hasAttachments: boolean; replyingToStatus: boolean; - @Output() browseAccount = new EventEmitter(); - @Output() browseHashtag = new EventEmitter(); - @Output() browseThread = new EventEmitter(); + @Output() browseAccountEvent = new EventEmitter(); + @Output() browseHashtagEvent = new EventEmitter(); + @Output() browseThreadEvent = new EventEmitter(); private _statusWrapper: StatusWrapper; status: Status; @@ -53,7 +53,7 @@ export class StatusComponent implements OnInit { if(!accountName.includes('@')) accountName += `@${account.url.replace('https://', '').split('/')[0]}`; - this.browseAccount.next(accountName); + this.browseAccountEvent.next(accountName); return false; } @@ -69,16 +69,14 @@ export class StatusComponent implements OnInit { } accountSelected(accountName: string): void { - console.warn(`status comp: accountSelected ${accountName}`); - this.browseAccount.next(accountName); + this.browseAccountEvent.next(accountName); } hashtagSelected(hashtag: string): void { - console.warn(`status comp: hashtagSelected ${hashtag}`); - this.browseHashtag.next(hashtag); + this.browseHashtagEvent.next(hashtag); } textSelected(): void { - console.warn(`status comp: textSelected`); + this.browseThreadEvent.next(this._statusWrapper.status.uri); } } diff --git a/src/app/components/stream/stream-overlay/stream-overlay.component.html b/src/app/components/stream/stream-overlay/stream-overlay.component.html index 77f68df8..6d1fd177 100644 --- a/src/app/components/stream/stream-overlay/stream-overlay.component.html +++ b/src/app/components/stream/stream-overlay/stream-overlay.component.html @@ -5,11 +5,12 @@ REFRESH NEXT - - - - + + + \ No newline at end of file diff --git a/src/app/components/stream/stream-overlay/stream-overlay.component.ts b/src/app/components/stream/stream-overlay/stream-overlay.component.ts index f43bfbbe..f7eeafcc 100644 --- a/src/app/components/stream/stream-overlay/stream-overlay.component.ts +++ b/src/app/components/stream/stream-overlay/stream-overlay.component.ts @@ -10,6 +10,7 @@ import { StreamElement, StreamTypeEnum } from '../../../states/streams.state'; styleUrls: ['./stream-overlay.component.scss'] }) export class StreamOverlayComponent implements OnInit { + private previousElements: OverlayBrowsing[] = []; private nextElements: OverlayBrowsing[] = []; private currentElement: OverlayBrowsing; @@ -24,21 +25,20 @@ export class StreamOverlayComponent implements OnInit { @Output() closeOverlay = new EventEmitter(); - @Input('browseAccount') - set browseAccount(accountName: string) { - this.accountSelected(accountName); + @Input('browseAccountData') + set browseAccountData(accountName: string) { + this.browseAccount(accountName); // this.accountName = accountName; } - @Input('browseThread') - set browseThread(thread: string) { - // this.thread = thread; + @Input('browseThreadData') + set browseThreadData(statusUri: string) { + this.browseThread(statusUri); } - @Input('browseHashtag') - set browseHashtag(hashtag: string) { - this.hashtagSelected(hashtag); - // this.hashtag = hashtag; + @Input('browseHashtagData') + set browseHashtagData(hashtag: string) { + this.browseHashtag(hashtag); } constructor(private toolsService: ToolsService) { } @@ -93,7 +93,7 @@ export class StreamOverlayComponent implements OnInit { return false; } - accountSelected(accountName: string): void { + browseAccount(accountName: string): void { if(!accountName) return; console.log('accountSelected'); @@ -106,7 +106,7 @@ export class StreamOverlayComponent implements OnInit { this.canGoForward = false; } - hashtagSelected(hashtag: string): void { + browseHashtag(hashtag: string): void { if(!hashtag) return; console.log('hashtagSelected'); @@ -122,6 +122,20 @@ export class StreamOverlayComponent implements OnInit { this.canGoForward = false; } + browseThread(statusUri: string): any { + if(!statusUri) return; + + console.log('thread selected') + this.nextElements.length = 0; + if (this.currentElement) { + this.previousElements.push(this.currentElement); + } + + const newElement = new OverlayBrowsing(null, null, statusUri); + this.loadElement(newElement); + this.canGoForward = false; + } + private loadElement(element: OverlayBrowsing) { this.currentElement = element; diff --git a/src/app/components/stream/stream-statuses/stream-statuses.component.html b/src/app/components/stream/stream-statuses/stream-statuses.component.html index 43918a72..80071ee6 100644 --- a/src/app/components/stream/stream-statuses/stream-statuses.component.html +++ b/src/app/components/stream/stream-statuses/stream-statuses.component.html @@ -1,6 +1,6 @@
- +
\ No newline at end of file diff --git a/src/app/components/stream/stream-statuses/stream-statuses.component.ts b/src/app/components/stream/stream-statuses/stream-statuses.component.ts index edb1dc5b..d6bd8bfd 100644 --- a/src/app/components/stream/stream-statuses/stream-statuses.component.ts +++ b/src/app/components/stream/stream-statuses/stream-statuses.component.ts @@ -25,9 +25,9 @@ export class StreamStatusesComponent implements OnInit, OnDestroy { private bufferStream: Status[] = []; private bufferWasCleared: boolean; - @Output() browseAccount = new EventEmitter(); - @Output() browseHashtag = new EventEmitter(); - @Output() browseThread = new EventEmitter(); + @Output() browseAccountEvent = new EventEmitter(); + @Output() browseHashtagEvent = new EventEmitter(); + @Output() browseThreadEvent = new EventEmitter(); @Input() set streamElement(streamElement: StreamElement) { @@ -125,14 +125,16 @@ export class StreamStatusesComponent implements OnInit, OnDestroy { } } - accountSelected(accountName: string): void { - console.warn(`status comp: accountSelected ${accountName}`); - this.browseAccount.next(accountName); + browseAccount(accountName: string): void { + this.browseAccountEvent.next(accountName); } - hashtagSelected(hashtag: string): void { - console.warn(`status comp: hashtagSelected ${hashtag}`); - this.browseHashtag.next(hashtag); + browseHashtag(hashtag: string): void { + this.browseHashtagEvent.next(hashtag); + } + + browseThread(statusUri: string): void { + this.browseThreadEvent.next(statusUri); } textSelected(): void { diff --git a/src/app/components/stream/stream.component.html b/src/app/components/stream/stream.component.html index cd7b94dd..c47d64f2 100644 --- a/src/app/components/stream/stream.component.html +++ b/src/app/components/stream/stream.component.html @@ -2,15 +2,16 @@ + [browseAccountData]="overlayAccountToBrowse" + [browseHashtagData]="overlayHashtagToBrowse" + [browseThreadData]="overlayThreadToBrowse"> - +
@@ -24,7 +25,9 @@
- +
diff --git a/src/app/components/stream/user-profile/user-profile.component.ts b/src/app/components/stream/user-profile/user-profile.component.ts index 47debcb4..16452660 100644 --- a/src/app/components/stream/user-profile/user-profile.component.ts +++ b/src/app/components/stream/user-profile/user-profile.component.ts @@ -21,8 +21,8 @@ export class UserProfileComponent implements OnInit { private accountName: string; - @Output() browseAccount = new EventEmitter(); - @Output() browseHashtag = new EventEmitter(); + @Output() browseAccountEvent = new EventEmitter(); + @Output() browseHashtagEvent = new EventEmitter(); @Input('currentAccount') //set currentAccount(account: Account) { @@ -51,12 +51,12 @@ export class UserProfileComponent implements OnInit { ngOnInit() { } - accountSelected(accountName: string): void { - this.browseAccount.next(accountName); + browseAccount(accountName: string): void { + this.browseAccountEvent.next(accountName); } - hashtagSelected(hashtag: string): void { - this.browseHashtag.next(hashtag); + browseHashtag(hashtag: string): void { + this.browseHashtagEvent.next(hashtag); } private loadAccount(accountName: string): Promise { From c968e656467e1524368358933f60e8577d89cebd Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Sun, 27 Jan 2019 23:08:43 -0500 Subject: [PATCH 3/7] added call to retrieve status context --- .../stream/status/status.component.ts | 14 +++-- .../stream-overlay.component.html | 2 +- .../stream/thread/thread.component.html | 2 + .../stream/thread/thread.component.ts | 58 ++++++++++++++++--- src/app/services/mastodon.service.ts | 10 +++- 5 files changed, 73 insertions(+), 13 deletions(-) diff --git a/src/app/components/stream/status/status.component.ts b/src/app/components/stream/status/status.component.ts index a6390231..15a50e53 100644 --- a/src/app/components/stream/status/status.component.ts +++ b/src/app/components/stream/status/status.component.ts @@ -49,9 +49,9 @@ export class StatusComponent implements OnInit { } openAccount(account: Account): boolean { - let accountName = account.acct; - if(!accountName.includes('@')) - accountName += `@${account.url.replace('https://', '').split('/')[0]}`; + let accountName = account.acct; + if (!accountName.includes('@')) + accountName += `@${account.url.replace('https://', '').split('/')[0]}`; this.browseAccountEvent.next(accountName); return false; @@ -77,6 +77,12 @@ export class StatusComponent implements OnInit { } textSelected(): void { - this.browseThreadEvent.next(this._statusWrapper.status.uri); + const status = this._statusWrapper.status; + + if (status.reblog) { + this.browseThreadEvent.next(status.reblog.uri); + } else { + this.browseThreadEvent.next(this._statusWrapper.status.uri); + } } } diff --git a/src/app/components/stream/stream-overlay/stream-overlay.component.html b/src/app/components/stream/stream-overlay/stream-overlay.component.html index 6d1fd177..2ad00bf5 100644 --- a/src/app/components/stream/stream-overlay/stream-overlay.component.html +++ b/src/app/components/stream/stream-overlay/stream-overlay.component.html @@ -12,5 +12,5 @@ - + \ No newline at end of file diff --git a/src/app/components/stream/thread/thread.component.html b/src/app/components/stream/thread/thread.component.html index 5d42ddbd..affd1e0b 100644 --- a/src/app/components/stream/thread/thread.component.html +++ b/src/app/components/stream/thread/thread.component.html @@ -1,3 +1,5 @@

thread works! + + {{ thread }}

diff --git a/src/app/components/stream/thread/thread.component.ts b/src/app/components/stream/thread/thread.component.ts index d72da5ec..e271af62 100644 --- a/src/app/components/stream/thread/thread.component.ts +++ b/src/app/components/stream/thread/thread.component.ts @@ -1,15 +1,59 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import { StatusWrapper } from '../stream.component'; +import { MastodonService } from '../../../services/mastodon.service'; +import { ToolsService } from '../../../services/tools.service'; +import { Status, Results, Context } from '../../../services/models/mastodon.interfaces'; @Component({ - selector: 'app-thread', - templateUrl: './thread.component.html', - styleUrls: ['./thread.component.scss'] + selector: 'app-thread', + templateUrl: '../stream-statuses/stream-statuses.component.html', + styleUrls: ['../stream-statuses/stream-statuses.component.scss'] }) export class ThreadComponent implements OnInit { + statuses: StatusWrapper[] = []; - constructor() { } + @Output() browseAccountEvent = new EventEmitter(); + @Output() browseHashtagEvent = new EventEmitter(); + @Output() browseThreadEvent = new EventEmitter(); - ngOnInit() { - } + @Input('currentThread') + set currentThread(thread: string) { + this.getThread(thread); + } + constructor( + private readonly toolsService: ToolsService, + private readonly mastodonService: MastodonService) { } + + ngOnInit() { + } + + private getThread(thread: string) { + this.statuses.length = 0; + + let currentAccount = this.toolsService.getSelectedAccounts()[0]; + + this.mastodonService.search(currentAccount, thread, true) + .then((result: Results) => { + if(result.statuses.length === 1){ + const retrievedStatus = result.statuses[0]; + this.mastodonService.getStatusContext(currentAccount, retrievedStatus.id) + .then((context: Context) => { + let contextStatuses = [ ...context.ancestors, retrievedStatus, ...context.descendants] + + for (const s of contextStatuses) { + const wrapper = new StatusWrapper(s, currentAccount); + this.statuses.push(wrapper); + } + }); + } else { + //TODO handle error + console.error('could not retrieve status'); + } + }); + } + + onScroll(){ + //Do nothing + } } diff --git a/src/app/services/mastodon.service.ts b/src/app/services/mastodon.service.ts index aa798712..ab81b988 100644 --- a/src/app/services/mastodon.service.ts +++ b/src/app/services/mastodon.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { HttpHeaders, HttpClient } from '@angular/common/http'; import { ApiRoutes } from './models/api.settings'; -import { Account, Status, Results } from "./models/mastodon.interfaces"; +import { Account, Status, Results, Context } from "./models/mastodon.interfaces"; import { AccountInfo } from '../states/accounts.state'; import { StreamTypeEnum } from '../states/streams.state'; import { stat } from 'fs'; @@ -129,6 +129,14 @@ export class MastodonService { return this.httpClient.get(route+params, { headers: headers }).toPromise(); } + getStatusContext(account: AccountInfo, targetStatusId: string): Promise{ + const params = this.apiRoutes.getStatusContext.replace('{0}', targetStatusId); + const route = `https://${account.instance}${params}`; + + const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` }); + return this.httpClient.get(route, { headers: headers }).toPromise(); + } + searchAccount(account: AccountInfo, query: string, limit: number = 40, following: boolean = false): Promise{ const route = `https://${account.instance}${this.apiRoutes.searchForAccounts}?q=${query}&limit=${limit}&following=${following}`; const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` }); From 8db930570159632cd1271d905e45e204792fb9fa Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Sun, 27 Jan 2019 23:20:49 -0500 Subject: [PATCH 4/7] added events handling for profile/hashtag to report status selection --- .../components/stream/hashtag/hashtag.component.html | 3 ++- .../components/stream/hashtag/hashtag.component.ts | 5 +++++ .../stream-overlay/stream-overlay.component.html | 11 ++++++++--- src/app/components/stream/thread/thread.component.ts | 12 ++++++++++++ .../stream/user-profile/user-profile.component.html | 3 ++- .../stream/user-profile/user-profile.component.ts | 5 +++++ 6 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/app/components/stream/hashtag/hashtag.component.html b/src/app/components/stream/hashtag/hashtag.component.html index 6f09f0bc..7f13a754 100644 --- a/src/app/components/stream/hashtag/hashtag.component.html +++ b/src/app/components/stream/hashtag/hashtag.component.html @@ -10,5 +10,6 @@ [streamElement]="hashtagElement" [goToTop]="goToTopSubject.asObservable()" (browseAccountEvent)="browseAccount($event)" - (browseHashtagEvent)="browseHashtag($event)"> + (browseHashtagEvent)="browseHashtag($event)" + (browseThreadEvent)="browseThread($event)"> \ No newline at end of file diff --git a/src/app/components/stream/hashtag/hashtag.component.ts b/src/app/components/stream/hashtag/hashtag.component.ts index de2e0a1d..d6273593 100644 --- a/src/app/components/stream/hashtag/hashtag.component.ts +++ b/src/app/components/stream/hashtag/hashtag.component.ts @@ -12,6 +12,7 @@ import { StreamElement, StreamTypeEnum, AddStream } from '../../../states/stream export class HashtagComponent implements OnInit { @Output() browseAccountEvent = new EventEmitter(); @Output() browseHashtagEvent = new EventEmitter(); + @Output() browseThreadEvent = new EventEmitter(); @Input() hashtagElement: StreamElement; @@ -45,4 +46,8 @@ export class HashtagComponent implements OnInit { browseHashtag(hashtag: string) { this.browseHashtagEvent.next(hashtag); } + + browseThread(statusUri: string): void { + this.browseThreadEvent.next(statusUri); + } } diff --git a/src/app/components/stream/stream-overlay/stream-overlay.component.html b/src/app/components/stream/stream-overlay/stream-overlay.component.html index 2ad00bf5..9d06ac34 100644 --- a/src/app/components/stream/stream-overlay/stream-overlay.component.html +++ b/src/app/components/stream/stream-overlay/stream-overlay.component.html @@ -8,9 +8,14 @@ + (browseHashtagEvent)="browseHashtag($event)" + (browseThreadEvent)="browseThread($event)"> - + (browseHashtagEvent)="browseHashtag($event)" + (browseThreadEvent)="browseThread($event)"> + \ No newline at end of file diff --git a/src/app/components/stream/thread/thread.component.ts b/src/app/components/stream/thread/thread.component.ts index e271af62..d81d6c94 100644 --- a/src/app/components/stream/thread/thread.component.ts +++ b/src/app/components/stream/thread/thread.component.ts @@ -56,4 +56,16 @@ export class ThreadComponent implements OnInit { onScroll(){ //Do nothing } + + browseAccount(accountName: string): void { + this.browseAccountEvent.next(accountName); + } + + browseHashtag(hashtag: string): void { + this.browseHashtagEvent.next(hashtag); + } + + browseThread(statusUri: string): void { + this.browseThreadEvent.next(statusUri); + } } diff --git a/src/app/components/stream/user-profile/user-profile.component.html b/src/app/components/stream/user-profile/user-profile.component.html index d3670697..a819393d 100644 --- a/src/app/components/stream/user-profile/user-profile.component.html +++ b/src/app/components/stream/user-profile/user-profile.component.html @@ -27,7 +27,8 @@
+ (browseAccountEvent)="browseAccount($event)" + (browseThreadEvent)="browseThread($event)">
diff --git a/src/app/components/stream/user-profile/user-profile.component.ts b/src/app/components/stream/user-profile/user-profile.component.ts index 16452660..ec82cee9 100644 --- a/src/app/components/stream/user-profile/user-profile.component.ts +++ b/src/app/components/stream/user-profile/user-profile.component.ts @@ -23,6 +23,7 @@ export class UserProfileComponent implements OnInit { @Output() browseAccountEvent = new EventEmitter(); @Output() browseHashtagEvent = new EventEmitter(); + @Output() browseThreadEvent = new EventEmitter(); @Input('currentAccount') //set currentAccount(account: Account) { @@ -59,6 +60,10 @@ export class UserProfileComponent implements OnInit { this.browseHashtagEvent.next(hashtag); } + browseThread(statusUri: string): void { + this.browseThreadEvent.next(statusUri); + } + private loadAccount(accountName: string): Promise { this.account = null; this.accountName = accountName; From 2970dfd8d84b10a830ed3a104b9d94c1c504d192 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Sun, 27 Jan 2019 23:22:46 -0500 Subject: [PATCH 5/7] fix: don't load thread if none provided --- .../components/stream/thread/thread.component.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/app/components/stream/thread/thread.component.ts b/src/app/components/stream/thread/thread.component.ts index d81d6c94..59cb5f65 100644 --- a/src/app/components/stream/thread/thread.component.ts +++ b/src/app/components/stream/thread/thread.component.ts @@ -18,7 +18,9 @@ export class ThreadComponent implements OnInit { @Input('currentThread') set currentThread(thread: string) { - this.getThread(thread); + if (thread) { + this.getThread(thread); + } } constructor( @@ -35,12 +37,12 @@ export class ThreadComponent implements OnInit { this.mastodonService.search(currentAccount, thread, true) .then((result: Results) => { - if(result.statuses.length === 1){ + if (result.statuses.length === 1) { const retrievedStatus = result.statuses[0]; this.mastodonService.getStatusContext(currentAccount, retrievedStatus.id) .then((context: Context) => { - let contextStatuses = [ ...context.ancestors, retrievedStatus, ...context.descendants] - + let contextStatuses = [...context.ancestors, retrievedStatus, ...context.descendants] + for (const s of contextStatuses) { const wrapper = new StatusWrapper(s, currentAccount); this.statuses.push(wrapper); @@ -50,10 +52,10 @@ export class ThreadComponent implements OnInit { //TODO handle error console.error('could not retrieve status'); } - }); + }); } - onScroll(){ + onScroll() { //Do nothing } From 8624a2f954b05c3c8b7f25c2488dc602c1c75bbf Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Sun, 27 Jan 2019 23:29:17 -0500 Subject: [PATCH 6/7] added loading animation for thread loading --- .../stream/stream-statuses/stream-statuses.component.html | 7 +++++-- .../stream/stream-statuses/stream-statuses.component.ts | 1 + src/app/components/stream/thread/thread.component.html | 5 ----- src/app/components/stream/thread/thread.component.scss | 0 src/app/components/stream/thread/thread.component.ts | 4 ++++ 5 files changed, 10 insertions(+), 7 deletions(-) delete mode 100644 src/app/components/stream/thread/thread.component.html delete mode 100644 src/app/components/stream/thread/thread.component.scss diff --git a/src/app/components/stream/stream-statuses/stream-statuses.component.html b/src/app/components/stream/stream-statuses/stream-statuses.component.html index 80071ee6..e9f6dec7 100644 --- a/src/app/components/stream/stream-statuses/stream-statuses.component.html +++ b/src/app/components/stream/stream-statuses/stream-statuses.component.html @@ -1,6 +1,9 @@
+ +
- +
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/app/components/stream/stream-statuses/stream-statuses.component.ts b/src/app/components/stream/stream-statuses/stream-statuses.component.ts index d6bd8bfd..22078d33 100644 --- a/src/app/components/stream/stream-statuses/stream-statuses.component.ts +++ b/src/app/components/stream/stream-statuses/stream-statuses.component.ts @@ -16,6 +16,7 @@ import { StatusWrapper } from '../stream.component'; styleUrls: ['./stream-statuses.component.scss'] }) export class StreamStatusesComponent implements OnInit, OnDestroy { + private isLoading = false; //TODO private _streamElement: StreamElement; private account: AccountInfo; diff --git a/src/app/components/stream/thread/thread.component.html b/src/app/components/stream/thread/thread.component.html deleted file mode 100644 index affd1e0b..00000000 --- a/src/app/components/stream/thread/thread.component.html +++ /dev/null @@ -1,5 +0,0 @@ -

- thread works! - - {{ thread }} -

diff --git a/src/app/components/stream/thread/thread.component.scss b/src/app/components/stream/thread/thread.component.scss deleted file mode 100644 index e69de29b..00000000 diff --git a/src/app/components/stream/thread/thread.component.ts b/src/app/components/stream/thread/thread.component.ts index 59cb5f65..3d3d5d43 100644 --- a/src/app/components/stream/thread/thread.component.ts +++ b/src/app/components/stream/thread/thread.component.ts @@ -11,6 +11,7 @@ import { Status, Results, Context } from '../../../services/models/mastodon.inte }) export class ThreadComponent implements OnInit { statuses: StatusWrapper[] = []; + private isLoading: boolean; @Output() browseAccountEvent = new EventEmitter(); @Output() browseHashtagEvent = new EventEmitter(); @@ -19,6 +20,7 @@ export class ThreadComponent implements OnInit { @Input('currentThread') set currentThread(thread: string) { if (thread) { + this.isLoading = true; this.getThread(thread); } } @@ -41,6 +43,7 @@ export class ThreadComponent implements OnInit { const retrievedStatus = result.statuses[0]; this.mastodonService.getStatusContext(currentAccount, retrievedStatus.id) .then((context: Context) => { + this.isLoading = false; let contextStatuses = [...context.ancestors, retrievedStatus, ...context.descendants] for (const s of contextStatuses) { @@ -50,6 +53,7 @@ export class ThreadComponent implements OnInit { }); } else { //TODO handle error + this.isLoading = false; console.error('could not retrieve status'); } }); From 7b91b1acc1a2126dca83185c2240053e294da568 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Mon, 28 Jan 2019 00:15:27 -0500 Subject: [PATCH 7/7] variables accessibility fixed --- .../stream/stream-statuses/stream-statuses.component.ts | 2 +- src/app/components/stream/thread/thread.component.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/components/stream/stream-statuses/stream-statuses.component.ts b/src/app/components/stream/stream-statuses/stream-statuses.component.ts index 22078d33..9c486025 100644 --- a/src/app/components/stream/stream-statuses/stream-statuses.component.ts +++ b/src/app/components/stream/stream-statuses/stream-statuses.component.ts @@ -16,7 +16,7 @@ import { StatusWrapper } from '../stream.component'; styleUrls: ['./stream-statuses.component.scss'] }) export class StreamStatusesComponent implements OnInit, OnDestroy { - private isLoading = false; //TODO + isLoading = false; //TODO private _streamElement: StreamElement; private account: AccountInfo; diff --git a/src/app/components/stream/thread/thread.component.ts b/src/app/components/stream/thread/thread.component.ts index 3d3d5d43..41077b18 100644 --- a/src/app/components/stream/thread/thread.component.ts +++ b/src/app/components/stream/thread/thread.component.ts @@ -11,7 +11,7 @@ import { Status, Results, Context } from '../../../services/models/mastodon.inte }) export class ThreadComponent implements OnInit { statuses: StatusWrapper[] = []; - private isLoading: boolean; + isLoading: boolean; @Output() browseAccountEvent = new EventEmitter(); @Output() browseHashtagEvent = new EventEmitter();