added emoji cache
This commit is contained in:
parent
761a910d31
commit
f11d82c072
|
@ -24,19 +24,19 @@ export class ToolsService {
|
|||
getAccountSettings(account: AccountInfo): AccountSettings {
|
||||
var accountsSettings = <AccountSettings[]>this.store.snapshot().globalsettings.settings.accountSettings;
|
||||
let accountSettings = accountsSettings.find(x => x.accountId === account.id);
|
||||
if(!accountSettings){
|
||||
if (!accountSettings) {
|
||||
accountSettings = new AccountSettings();
|
||||
accountSettings.accountId = account.id;
|
||||
this.saveAccountSettings(accountSettings);
|
||||
}
|
||||
if(!accountSettings.customStatusCharLength){
|
||||
if (!accountSettings.customStatusCharLength) {
|
||||
accountSettings.customStatusCharLength = 500;
|
||||
this.saveAccountSettings(accountSettings);
|
||||
}
|
||||
return accountSettings;
|
||||
}
|
||||
|
||||
saveAccountSettings(accountSettings: AccountSettings){
|
||||
saveAccountSettings(accountSettings: AccountSettings) {
|
||||
this.store.dispatch([
|
||||
new SaveAccountSettings(accountSettings)
|
||||
])
|
||||
|
@ -45,19 +45,19 @@ export class ToolsService {
|
|||
findAccount(account: AccountInfo, accountName: string): Promise<Account> {
|
||||
return this.mastodonService.search(account, accountName, true)
|
||||
.then((result: Results) => {
|
||||
if(accountName[0] === '@') accountName = accountName.substr(1);
|
||||
if (accountName[0] === '@') accountName = accountName.substr(1);
|
||||
|
||||
const foundAccount = result.accounts.find(
|
||||
x => (x.acct.toLowerCase() === accountName.toLowerCase()
|
||||
||
|
||||
(x.acct.toLowerCase().split('@')[0] === accountName.toLowerCase().split('@')[0])
|
||||
&& x.url.replace('https://', '').split('/')[0] === accountName.toLowerCase().split('@')[1])
|
||||
);
|
||||
||
|
||||
(x.acct.toLowerCase().split('@')[0] === accountName.toLowerCase().split('@')[0])
|
||||
&& x.url.replace('https://', '').split('/')[0] === accountName.toLowerCase().split('@')[1])
|
||||
);
|
||||
return foundAccount;
|
||||
});
|
||||
}
|
||||
|
||||
getStatusUsableByAccount(account: AccountInfo, originalStatus: StatusWrapper): Promise<Status>{
|
||||
getStatusUsableByAccount(account: AccountInfo, originalStatus: StatusWrapper): Promise<Status> {
|
||||
const isProvider = originalStatus.provider.id === account.id;
|
||||
|
||||
let statusPromise: Promise<Status> = Promise.resolve(originalStatus.status);
|
||||
|
@ -83,13 +83,17 @@ export class ToolsService {
|
|||
return `@${fullHandle}`;
|
||||
}
|
||||
|
||||
private emojiCache: { [id: string]: Emoji[] } = {};
|
||||
getCustomEmojis(account: AccountInfo): Promise<Emoji[]> {
|
||||
//TODO: add cache
|
||||
|
||||
return this.mastodonService.getCustomEmojis(account)
|
||||
.then(emojis => {
|
||||
return emojis.filter(x => x.visible_in_picker);
|
||||
});
|
||||
if (this.emojiCache[account.id]) {
|
||||
return Promise.resolve(this.emojiCache[account.id]);
|
||||
} else {
|
||||
return this.mastodonService.getCustomEmojis(account)
|
||||
.then(emojis => {
|
||||
this.emojiCache[account.id] = emojis.filter(x => x.visible_in_picker);
|
||||
return this.emojiCache[account.id];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue