fix delay in status selection

This commit is contained in:
Nicolas Constant 2020-02-14 19:59:45 -05:00
parent 0702063f69
commit f925f08d00
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
3 changed files with 12 additions and 6 deletions

View File

@ -56,6 +56,7 @@ export class StatusComponent implements OnInit {
this._statusWrapper = value;
// console.warn(value.status);
this.status = value.status;
this.isSelected = value.isSelected;
if (this.status.reblog) {
this.reblog = true;

View File

@ -159,12 +159,16 @@ export class ThreadComponent implements OnInit, OnDestroy {
pipeline
.then((status: Status) => {
return this.mastodonService.getStatusContext(currentAccount, status.id)
.then((context: Context) => {
.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);
for (let i = 0; i < contextStatuses.length; i++) {
let s = contextStatuses[i];
const wrapper = new StatusWrapper(s, currentAccount);
if(i == position) wrapper.isSelected = true;
this.statuses.push(wrapper);
}
@ -177,10 +181,9 @@ export class ThreadComponent implements OnInit, OnDestroy {
.then((position: number) => {
setTimeout(() => {
const el = this.statusChildren.toArray()[position];
el.isSelected = true;
//el.elem.nativeElement.scrollIntoViewIfNeeded({ behavior: 'auto', block: 'start', inline: 'nearest' });
//el.elem.nativeElement.scrollIntoViewIfNeeded({ behavior: 'auto', block: 'start', inline: 'nearest' });
scrollIntoView(el.elem.nativeElement, { behavior: 'smooth', block: 'nearest'});
}, 250);
})

View File

@ -17,4 +17,6 @@ export class StatusWrapper {
public status: Status,
public provider: AccountInfo
) { }
public isSelected: boolean;
}