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 { @@ -69,7 +69,7 @@ export default class EmojiTab implements EmoticonsTab {
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') {
console.log('appended emoji', emoji, itemsDiv.children[itemsDiv.childElementCount - 1].innerHTML, emojiUnicode(emoji));
@ -122,7 +122,7 @@ export default class EmojiTab implements EmoticonsTab { @@ -122,7 +122,7 @@ export default class EmojiTab implements EmoticonsTab {
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 as string).split('-')
//.reduce((prev, curr) => prev + String.fromCodePoint(parseInt(curr, 16)), '');
@ -130,7 +130,7 @@ export default class EmojiTab implements EmoticonsTab { @@ -130,7 +130,7 @@ export default class EmojiTab implements EmoticonsTab {
const spanEmoji = document.createElement('span');
let kek: string;
if(unified) {
/* if(unified) {
kek = RichTextProcessor.wrapRichText('_', {
entities: [{
_: 'messageEntityEmoji',
@ -139,9 +139,9 @@ export default class EmojiTab implements EmoticonsTab { @@ -139,9 +139,9 @@ export default class EmojiTab implements EmoticonsTab {
unicode: emoji
}]
});
} else {
} else { */
kek = RichTextProcessor.wrapEmojiText(emoji);
}
//}
/* if(!kek.includes('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 @@ -718,35 +718,35 @@ export function wrapAlbum({groupID, attachmentDiv, middleware, uploading, lazyLo
uploading?: 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
let storage = appMessagesManager.groupedMessagesStorage[groupID];
for(let mid in storage) {
let m = appMessagesManager.getMessage(+mid);
let media = m.media.photo || m.media.document;
// !higher msgID will be the FIRST in album
const storage = Object.keys(appMessagesManager.groupedMessagesStorage[groupID]).map(id => +id).sort((a, b) => a - b);
for(const mid of storage) {
const m = appMessagesManager.getMessage(mid);
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});
}
let spacing = 2;
let 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 spacing = 2;
const layouter = new Layouter(items.map(i => ({w: i.size.w, h: i.size.h})), mediaSizes.active.album.width, 100, spacing);
const layout = layouter.layout();
//console.log('layout:', layout, items.map(i => ({w: i.size.w, h: i.size.h})));
/* let borderRadius = window.getComputedStyle(realParent).getPropertyValue('border-radius');
let brSplitted = fillPropertyValue(borderRadius); */
for(let {geometry, sides} of layout) {
let item = items.shift();
for(const {geometry, sides} of layout) {
const item = items.shift();
if(!item) {
console.error('no item for layout!');
continue;
}
let {size, media, message} = item;
let div = document.createElement('div');
const {size, media, message} = item;
const div = document.createElement('div');
div.classList.add('album-item');
div.dataset.mid = message.mid;

2
src/lib/appManagers/appImManager.ts

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

Loading…
Cancel
Save