diff --git a/package-lock.json b/package-lock.json index fd298c0d..710c98b4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sengi", - "version": "0.12.2", + "version": "0.14.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 07aa9178..0ca6de00 100644 --- a/package.json +++ b/package.json @@ -129,7 +129,9 @@ "category": "Network" }, "snap": { - "publish": ["github"] + "publish": [ + "github" + ] } } } diff --git a/src/app/components/stream/status/status.component.html b/src/app/components/stream/status/status.component.html index 1c05b6ab..87d8af14 100644 --- a/src/app/components/stream/status/status.component.html +++ b/src/app/components/stream/status/status.component.html @@ -1,4 +1,4 @@ -
+
(); @Output() browseHashtagEvent = new EventEmitter(); @@ -49,6 +50,7 @@ export class StatusComponent implements OnInit { private _statusWrapper: StatusWrapper; status: Status; + @Input('statusWrapper') set statusWrapper(value: StatusWrapper) { this._statusWrapper = value; @@ -85,6 +87,7 @@ export class StatusComponent implements OnInit { } constructor( + public elem: ElementRef, private readonly toolsService: ToolsService) { } ngOnInit() { diff --git a/src/app/components/stream/thread/thread.component.ts b/src/app/components/stream/thread/thread.component.ts index 90f6ad28..8dc271cb 100644 --- a/src/app/components/stream/thread/thread.component.ts +++ b/src/app/components/stream/thread/thread.component.ts @@ -53,24 +53,24 @@ export class ThreadComponent implements OnInit, OnDestroy { private readonly mastodonService: MastodonService) { } ngOnInit() { - if(this.refreshEventEmitter) { + if (this.refreshEventEmitter) { this.refreshSubscription = this.refreshEventEmitter.subscribe(() => { this.refresh(); }) } - if(this.goToTopEventEmitter) { + if (this.goToTopEventEmitter) { this.goToTopSubscription = this.goToTopEventEmitter.subscribe(() => { this.goToTop(); }) } this.newPostSub = this.notificationService.newRespondPostedStream.subscribe((replyData: NewReplyData) => { - if(replyData){ + if (replyData) { const repondingStatus = this.statuses.find(x => x.status.id === replyData.uiStatusId); const responseStatus = replyData.response; - if(repondingStatus && this.statuses[0]){ - this.statuses.push(responseStatus); + if (repondingStatus && this.statuses[0]) { + this.statuses.push(responseStatus); } } }); @@ -78,7 +78,7 @@ export class ThreadComponent implements OnInit, OnDestroy { this.hideAccountSubscription = this.notificationService.hideAccountUrlStream.subscribe((accountUrl: string) => { if (accountUrl) { this.statuses = this.statuses.filter(x => { - if(x.status.reblog){ + if (x.status.reblog) { return x.status.reblog.account.url != accountUrl; } else { return x.status.account.url != accountUrl; @@ -88,9 +88,9 @@ export class ThreadComponent implements OnInit, OnDestroy { }); this.deleteStatusSubscription = this.notificationService.deletedStatusStream.subscribe((status: StatusWrapper) => { - if(status){ + if (status) { this.statuses = this.statuses.filter(x => { - return !(x.status.url.replace('https://','').split('/')[0] === status.provider.instance && x.status.id === status.status.id); + return !(x.status.url.replace('https://', '').split('/')[0] === status.provider.instance && x.status.id === status.status.id); }); } }); @@ -155,6 +155,7 @@ export class ThreadComponent implements OnInit, OnDestroy { return this.mastodonService.getStatusContext(currentAccount, status.id) .then((context: Context) => { let contextStatuses = [...context.ancestors, status, ...context.descendants] + const position = context.ancestors.length; for (const s of contextStatuses) { const wrapper = new StatusWrapper(s, currentAccount); @@ -162,9 +163,19 @@ export class ThreadComponent implements OnInit, OnDestroy { } this.hasContentWarnings = this.statuses.filter(x => x.status.sensitive || x.status.spoiler_text).length > 1; + + return position; }); }) + .then((position: number) => { + setTimeout(() => { + const el = this.statusChildren.toArray()[position]; + el.isSelected = true; + // el.elem.nativeElement.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'start' }); + el.elem.nativeElement.scrollIntoView({ behavior: 'auto', block: 'nearest', inline: 'start' }); + }, 0); + }) .catch((err: HttpErrorResponse) => { this.notificationService.notifyHttpError(err); })