Browse Source

Emoji settings

master
morethanwords 4 years ago
parent
commit
6c3956444c
  1. 2
      src/components/chat/bubbles.ts
  2. 15
      src/components/chat/input.ts
  3. 19
      src/components/sidebarLeft/tabs/generalSettings.ts
  4. 3
      src/lang.ts
  5. 8
      src/lib/appManagers/appStateManager.ts

2
src/components/chat/bubbles.ts

@ -2043,7 +2043,7 @@ export default class ChatBubbles {
let canHaveTail = true; let canHaveTail = true;
if(totalEntities && !messageMedia) { if(totalEntities && !messageMedia && rootScope.settings.emoji.big) {
let emojiEntities = totalEntities.filter((e) => e._ === 'messageEntityEmoji'); let emojiEntities = totalEntities.filter((e) => e._ === 'messageEntityEmoji');
let strLength = messageMessage.length; let strLength = messageMessage.length;
let emojiStrLength = emojiEntities.reduce((acc: number, curr: any) => acc + curr.length, 0); let emojiStrLength = emojiEntities.reduce((acc: number, curr: any) => acc + curr.length, 0);

15
src/components/chat/input.ts

@ -72,10 +72,8 @@ const POSTING_MEDIA_NOT_ALLOWED = 'Posting media content isn\'t allowed in this
type ChatInputHelperType = 'edit' | 'webpage' | 'forward' | 'reply'; type ChatInputHelperType = 'edit' | 'webpage' | 'forward' | 'reply';
let selId = 0;
export default class ChatInput { export default class ChatInput {
public static AUTO_COMPLETE_REG_EXP = /(\s|^)((?::|.)(?!.*:).*|(?:(?:@|\/)(?:[\S]*)))$/; private static AUTO_COMPLETE_REG_EXP = /(\s|^)((?::|.)(?!.*:).*|(?:(?:@|\/)(?:[\S]*)))$/;
public messageInput: HTMLElement; public messageInput: HTMLElement;
public messageInputField: InputField; public messageInputField: InputField;
private fileInput: HTMLInputElement; private fileInput: HTMLInputElement;
@ -132,8 +130,8 @@ export default class ChatInput {
private lockRedo = false; private lockRedo = false;
private canRedoFromHTML = ''; private canRedoFromHTML = '';
readonly undoHistory: string[] = []; private readonly undoHistory: string[] = [];
readonly executedHistory: string[] = []; private readonly executedHistory: string[] = [];
private canUndoFromHTML = ''; private canUndoFromHTML = '';
private autocompleteHelperController: AutocompleteHelperController; private autocompleteHelperController: AutocompleteHelperController;
@ -435,7 +433,8 @@ export default class ChatInput {
}, {passive: false, capture: true}); */ }, {passive: false, capture: true}); */
this.listenerSetter.add(rootScope, 'settings_updated', () => { this.listenerSetter.add(rootScope, 'settings_updated', () => {
if(this.stickersHelper) { if(this.stickersHelper || this.emojiHelper) {
this.previousQuery = undefined;
this.checkAutocomplete(); this.checkAutocomplete();
/* if(!rootScope.settings.stickers.suggest) { /* if(!rootScope.settings.stickers.suggest) {
this.stickersHelper.checkEmoticon(''); this.stickersHelper.checkEmoticon('');
@ -1221,7 +1220,7 @@ export default class ChatInput {
const matches = value.match(ChatInput.AUTO_COMPLETE_REG_EXP); const matches = value.match(ChatInput.AUTO_COMPLETE_REG_EXP);
if(!matches) { if(!matches) {
delete this.previousQuery; this.previousQuery = undefined;
this.autocompleteHelperController.hideOtherHelpers(); this.autocompleteHelperController.hideOtherHelpers();
return; return;
} }
@ -1289,7 +1288,7 @@ export default class ChatInput {
// console.log('found commands', found, filtered); // console.log('found commands', found, filtered);
}); });
} }
} else { // emoji } else if(rootScope.settings.emoji.suggest) { // emoji
if(!value.match(/^\s*:(.+):\s*$/)) { if(!value.match(/^\s*:(.+):\s*$/)) {
foundHelper = this.emojiHelper; foundHelper = this.emojiHelper;
this.appEmojiManager.getBothEmojiKeywords().then(() => { this.appEmojiManager.getBothEmojiKeywords().then(() => {

19
src/components/sidebarLeft/tabs/generalSettings.ts

@ -170,6 +170,25 @@ export default class AppGeneralSettingsTab extends SliderSuperTab {
container.append(gifsCheckboxField.label, videosCheckboxField.label); container.append(gifsCheckboxField.label, videosCheckboxField.label);
} }
{
const container = section('Emoji');
const suggestCheckboxField = new CheckboxField({
text: 'GeneralSettings.EmojiPrediction',
name: 'suggest-emoji',
stateKey: 'settings.emoji.suggest',
withRipple: true
});
const bigCheckboxField = new CheckboxField({
text: 'GeneralSettings.BigEmoji',
name: 'emoji-big',
stateKey: 'settings.emoji.big',
withRipple: true
});
container.append(suggestCheckboxField.label, bigCheckboxField.label);
}
{ {
const container = section('Telegram.InstalledStickerPacksController'); const container = section('Telegram.InstalledStickerPacksController');

3
src/lang.ts

@ -436,6 +436,7 @@ const lang = {
"Of": "%1$d of %2$d", "Of": "%1$d of %2$d",
"NoResult": "No results", "NoResult": "No results",
"Updating": "Updating...", "Updating": "Updating...",
"Emoji": "Emoji",
// * macos // * macos
"AccountSettings.Filters": "Chat Folders", "AccountSettings.Filters": "Chat Folders",
@ -668,6 +669,8 @@ const lang = {
"NewPoll.OptionsAddOption": "Add an Option", "NewPoll.OptionsAddOption": "Add an Option",
"NewPoll.MultipleChoice": "Multiple Answers", "NewPoll.MultipleChoice": "Multiple Answers",
"NewPoll.Quiz": "Quiz Mode", "NewPoll.Quiz": "Quiz Mode",
"GeneralSettings.BigEmoji": "Large Emoji",
"GeneralSettings.EmojiPrediction": "Suggest Emoji",
"GroupPermission.Delete": "Delete Exception", "GroupPermission.Delete": "Delete Exception",
"Schedule.SendToday": "Send today at %@", "Schedule.SendToday": "Send today at %@",
"Schedule.SendDate": "Send on %@ at %@", "Schedule.SendDate": "Send on %@ at %@",

8
src/lib/appManagers/appStateManager.ts

@ -74,6 +74,10 @@ export type State = {
suggest: boolean, suggest: boolean,
loop: boolean loop: boolean
}, },
emoji: {
suggest: boolean,
big: boolean
},
background?: Background, // ! DEPRECATED background?: Background, // ! DEPRECATED
themes: Theme[], themes: Theme[],
theme: Theme['name'], theme: Theme['name'],
@ -119,6 +123,10 @@ export const STATE_INIT: State = {
suggest: true, suggest: true,
loop: true loop: true
}, },
emoji: {
suggest: true,
big: true
},
themes: [{ themes: [{
name: 'day', name: 'day',
background: { background: {

Loading…
Cancel
Save