Browse Source

Fix album order

master
morethanwords 4 years ago
parent
commit
febcb7cb35
  1. 10
      src/components/emoticonsDropdown/tabs/emoji.ts
  2. 28
      src/components/wrappers.ts
  3. 2
      src/lib/appManagers/appImManager.ts

10
src/components/emoticonsDropdown/tabs/emoji.ts

@ -69,7 +69,7 @@ export default class EmojiTab implements EmoticonsTab {
emoji = emoji.split('-').reduce((prev, curr) => prev + String.fromCodePoint(parseInt(curr, 16)), ''); emoji = emoji.split('-').reduce((prev, curr) => prev + String.fromCodePoint(parseInt(curr, 16)), '');
this.appendEmoji(emoji/* .replace(/[\ufe0f\u2640\u2642\u2695]/g, '') */, itemsDiv, false, false); this.appendEmoji(emoji/* .replace(/[\ufe0f\u2640\u2642\u2695]/g, '') */, itemsDiv, false/* , false */);
/* if(category == 'Smileys & Emotion') { /* if(category == 'Smileys & Emotion') {
console.log('appended emoji', emoji, itemsDiv.children[itemsDiv.childElementCount - 1].innerHTML, emojiUnicode(emoji)); console.log('appended emoji', emoji, itemsDiv.children[itemsDiv.childElementCount - 1].innerHTML, emojiUnicode(emoji));
@ -122,7 +122,7 @@ export default class EmojiTab implements EmoticonsTab {
this.init = null; this.init = null;
} }
private appendEmoji(emoji: string, container: HTMLElement, prepend = false, unified = false) { private appendEmoji(emoji: string, container: HTMLElement, prepend = false/* , unified = false */) {
//const emoji = details.unified; //const emoji = details.unified;
//const emoji = (details.unified as string).split('-') //const emoji = (details.unified as string).split('-')
//.reduce((prev, curr) => prev + String.fromCodePoint(parseInt(curr, 16)), ''); //.reduce((prev, curr) => prev + String.fromCodePoint(parseInt(curr, 16)), '');
@ -130,7 +130,7 @@ export default class EmojiTab implements EmoticonsTab {
const spanEmoji = document.createElement('span'); const spanEmoji = document.createElement('span');
let kek: string; let kek: string;
if(unified) { /* if(unified) {
kek = RichTextProcessor.wrapRichText('_', { kek = RichTextProcessor.wrapRichText('_', {
entities: [{ entities: [{
_: 'messageEntityEmoji', _: 'messageEntityEmoji',
@ -139,9 +139,9 @@ export default class EmojiTab implements EmoticonsTab {
unicode: emoji unicode: emoji
}] }]
}); });
} else { } else { */
kek = RichTextProcessor.wrapEmojiText(emoji); kek = RichTextProcessor.wrapEmojiText(emoji);
} //}
/* if(!kek.includes('emoji')) { /* if(!kek.includes('emoji')) {
console.log(emoji, kek, spanEmoji, emoji.length, new TextEncoder().encode(emoji), emojiUnicode(emoji)); console.log(emoji, kek, spanEmoji, emoji.length, new TextEncoder().encode(emoji), emojiUnicode(emoji));

28
src/components/wrappers.ts

@ -718,35 +718,35 @@ export function wrapAlbum({groupID, attachmentDiv, middleware, uploading, lazyLo
uploading?: boolean, uploading?: boolean,
isOut: boolean isOut: boolean
}) { }) {
let items: {size: MTPhotoSize, media: any, message: any}[] = []; const items: {size: MTPhotoSize, media: any, message: any}[] = [];
// higher msgID will be the last in album // !higher msgID will be the FIRST in album
let storage = appMessagesManager.groupedMessagesStorage[groupID]; const storage = Object.keys(appMessagesManager.groupedMessagesStorage[groupID]).map(id => +id).sort((a, b) => a - b);
for(let mid in storage) { for(const mid of storage) {
let m = appMessagesManager.getMessage(+mid); const m = appMessagesManager.getMessage(mid);
let media = m.media.photo || m.media.document; const media = m.media.photo || m.media.document;
let size: any = media._ == 'photo' ? appPhotosManager.choosePhotoSize(media, 480, 480) : {w: media.w, h: media.h}; const size: any = media._ == 'photo' ? appPhotosManager.choosePhotoSize(media, 480, 480) : {w: media.w, h: media.h};
items.push({size, media, message: m}); items.push({size, media, message: m});
} }
let spacing = 2; const spacing = 2;
let layouter = new Layouter(items.map(i => ({w: i.size.w, h: i.size.h})), mediaSizes.active.album.width, 100, spacing); const layouter = new Layouter(items.map(i => ({w: i.size.w, h: i.size.h})), mediaSizes.active.album.width, 100, spacing);
let layout = layouter.layout(); const layout = layouter.layout();
//console.log('layout:', layout, items.map(i => ({w: i.size.w, h: i.size.h}))); //console.log('layout:', layout, items.map(i => ({w: i.size.w, h: i.size.h})));
/* let borderRadius = window.getComputedStyle(realParent).getPropertyValue('border-radius'); /* let borderRadius = window.getComputedStyle(realParent).getPropertyValue('border-radius');
let brSplitted = fillPropertyValue(borderRadius); */ let brSplitted = fillPropertyValue(borderRadius); */
for(let {geometry, sides} of layout) { for(const {geometry, sides} of layout) {
let item = items.shift(); const item = items.shift();
if(!item) { if(!item) {
console.error('no item for layout!'); console.error('no item for layout!');
continue; continue;
} }
let {size, media, message} = item; const {size, media, message} = item;
let div = document.createElement('div'); const div = document.createElement('div');
div.classList.add('album-item'); div.classList.add('album-item');
div.dataset.mid = message.mid; div.dataset.mid = message.mid;

2
src/lib/appManagers/appImManager.ts

@ -893,6 +893,8 @@ export class AppImManager {
}); });
}); });
targets.sort((a, b) => a.mid - b.mid);
let idx = targets.findIndex(t => t.mid == messageID); let idx = targets.findIndex(t => t.mid == messageID);
this.log('open mediaViewer single with ids:', ids, idx, targets); this.log('open mediaViewer single with ids:', ids, idx, targets);

Loading…
Cancel
Save