Merge pull request #272 from NicolasConstant/topic_firefox-autofocus
Topic firefox autofocus
This commit is contained in:
commit
fde017ccf6
|
@ -735,7 +735,11 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
try{
|
||||||
this.footerElement.nativeElement.scrollIntoViewIfNeeded({ behavior: 'instant', block: 'end', inline: 'start' });
|
this.footerElement.nativeElement.scrollIntoViewIfNeeded({ behavior: 'instant', block: 'end', inline: 'start' });
|
||||||
|
}catch(err) {
|
||||||
|
this.footerElement.nativeElement.scrollIntoView({ behavior: 'instant', block: 'end', inline: 'start' });
|
||||||
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,9 @@ export class UserNotificationService {
|
||||||
private soundJustPlayed = false;
|
private soundJustPlayed = false;
|
||||||
private soundFileId: string;
|
private soundFileId: string;
|
||||||
|
|
||||||
|
private accountSub: Subscription;
|
||||||
|
private loadedAccounts: AccountInfo[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly streamingService: StreamingService,
|
private readonly streamingService: StreamingService,
|
||||||
private readonly toolsService: ToolsService,
|
private readonly toolsService: ToolsService,
|
||||||
|
@ -37,14 +40,24 @@ export class UserNotificationService {
|
||||||
|
|
||||||
private fetchNotifications() {
|
private fetchNotifications() {
|
||||||
let accounts = this.store.snapshot().registeredaccounts.accounts;
|
let accounts = this.store.snapshot().registeredaccounts.accounts;
|
||||||
// let promises: Promise<any>[] = [];
|
|
||||||
|
|
||||||
accounts.forEach((account: AccountInfo) => {
|
accounts.forEach((account: AccountInfo) => {
|
||||||
// let sinceId = null;
|
this.loadedAccounts.push(account);
|
||||||
// if (this.sinceIds[account.id]) {
|
this.startFetchingNotifications(account);
|
||||||
// sinceId = this.sinceIds[account.id];
|
});
|
||||||
// }
|
|
||||||
|
|
||||||
|
this.accountSub = this.store.select(state => state.registeredaccounts.accounts)
|
||||||
|
.subscribe((accounts: AccountInfo[]) => {
|
||||||
|
accounts.forEach(a => {
|
||||||
|
if(!this.loadedAccounts.find(x => x.id === a.id)){
|
||||||
|
this.loadedAccounts.push(a);
|
||||||
|
this.startFetchingNotifications(a);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private startFetchingNotifications(account: AccountInfo) {
|
||||||
let getMentionsPromise = this.mastodonService.getNotifications(account, ['favourite', 'follow', 'reblog', 'poll'], null, null, 10)
|
let getMentionsPromise = this.mastodonService.getNotifications(account, ['favourite', 'follow', 'reblog', 'poll'], null, null, 10)
|
||||||
.then((notifications: Notification[]) => {
|
.then((notifications: Notification[]) => {
|
||||||
this.processMentionsAndNotifications(account, notifications, NotificationTypeEnum.UserMention);
|
this.processMentionsAndNotifications(account, notifications, NotificationTypeEnum.UserMention);
|
||||||
|
@ -73,13 +86,12 @@ export class UserNotificationService {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(err => { });
|
.catch(err => { });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private playSoundNotification() {
|
private playSoundNotification() {
|
||||||
const settings = this.toolsService.getSettings();
|
const settings = this.toolsService.getSettings();
|
||||||
if(settings.disableSounds) return;
|
if (settings.disableSounds) return;
|
||||||
if(this.soundJustPlayed) return;
|
if (this.soundJustPlayed) return;
|
||||||
this.soundJustPlayed = true;
|
this.soundJustPlayed = true;
|
||||||
|
|
||||||
this.setNotificationSound();
|
this.setNotificationSound();
|
||||||
|
@ -94,13 +106,13 @@ export class UserNotificationService {
|
||||||
let settings = this.toolsService.getSettings();
|
let settings = this.toolsService.getSettings();
|
||||||
let soundId = settings.notificationSoundFileId;
|
let soundId = settings.notificationSoundFileId;
|
||||||
|
|
||||||
if(!soundId){
|
if (!soundId) {
|
||||||
soundId = '0';
|
soundId = '0';
|
||||||
settings.notificationSoundFileId = '0';
|
settings.notificationSoundFileId = '0';
|
||||||
this.toolsService.saveSettings(settings);
|
this.toolsService.saveSettings(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.soundFileId === soundId) return;
|
if (this.soundFileId === soundId) return;
|
||||||
|
|
||||||
var sound = this.getAllNotificationSounds().find(x => x.id === soundId);
|
var sound = this.getAllNotificationSounds().find(x => x.id === soundId);
|
||||||
this.sound = new Howl({
|
this.sound = new Howl({
|
||||||
|
@ -110,9 +122,9 @@ export class UserNotificationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private processNewUpdate(account: AccountInfo, notification: StatusUpdate) {
|
private processNewUpdate(account: AccountInfo, notification: StatusUpdate) {
|
||||||
if(!notification && !notification.notification) return;
|
if (!notification && !notification.notification) return;
|
||||||
|
|
||||||
if(!notification.muteSound){
|
if (!notification.muteSound) {
|
||||||
this.playSoundNotification();
|
this.playSoundNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,5 +273,5 @@ export class NotificationSoundDefinition {
|
||||||
constructor(
|
constructor(
|
||||||
public readonly id: string,
|
public readonly id: string,
|
||||||
public readonly path: string,
|
public readonly path: string,
|
||||||
public readonly name: string) {}
|
public readonly name: string) { }
|
||||||
}
|
}
|
Loading…
Reference in New Issue