fix adding new hashtag with last used account

This commit is contained in:
Nicolas Constant 2019-02-18 23:57:45 -05:00
parent 95ef1e0885
commit b8a58963d9
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
1 changed files with 17 additions and 4 deletions

View File

@ -3,8 +3,9 @@ import { Subject } from 'rxjs';
import { Store } from '@ngxs/store';
import { StreamElement, StreamTypeEnum, AddStream } from '../../../states/streams.state';
import { OpenThreadEvent } from '../../../services/tools.service';
import { OpenThreadEvent, ToolsService } from '../../../services/tools.service';
import { StreamStatusesComponent } from '../stream-statuses/stream-statuses.component';
import { AccountInfo } from 'src/app/states/accounts.state';
@Component({
selector: 'app-hashtag',
@ -17,14 +18,25 @@ export class HashtagComponent implements OnInit {
@Output() browseHashtagEvent = new EventEmitter<string>();
@Output() browseThreadEvent = new EventEmitter<OpenThreadEvent>();
@Input() hashtagElement: StreamElement;
private _hashtagElement: StreamElement;
@Input()
set hashtagElement(hashtagElement: StreamElement){
this._hashtagElement = hashtagElement;
this.lastUsedAccount = this.toolsService.getSelectedAccounts()[0];
}
get hashtagElement(): StreamElement{
return this._hashtagElement;
}
@ViewChild('appStreamStatuses') appStreamStatuses: StreamStatusesComponent;
goToTopSubject: Subject<void> = new Subject<void>();
private lastUsedAccount: AccountInfo;
constructor(
private readonly store: Store) { }
private readonly store: Store,
private readonly toolsService: ToolsService) { }
ngOnInit() {
}
@ -38,13 +50,14 @@ export class HashtagComponent implements OnInit {
event.stopPropagation();
const hashtag = this.hashtagElement.tag;
const newStream = new StreamElement(StreamTypeEnum.tag, `${hashtag}`, this.hashtagElement.accountId, hashtag, null, this.hashtagElement.displayableFullName);
const newStream = new StreamElement(StreamTypeEnum.tag, `${hashtag}`, this.lastUsedAccount.id, hashtag, null, this.hashtagElement.displayableFullName);
this.store.dispatch([new AddStream(newStream)]);
return false;
}
refresh(): any {
this.lastUsedAccount = this.toolsService.getSelectedAccounts()[0];
this.appStreamStatuses.refresh();
}