Fix loading top history because of hidden message
Support different languages of changelogs
This commit is contained in:
parent
3b8390afde
commit
0b3574ff9d
@ -386,7 +386,7 @@ export default class ChatTopbar {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
verify: () => !this.chat.selection.isSelecting && !!Object.keys(this.chat.bubbles.bubbles).length
|
verify: () => !this.chat.selection.isSelecting && !!this.chat.bubbles.getRenderedLength()
|
||||||
}, {
|
}, {
|
||||||
icon: 'select',
|
icon: 'select',
|
||||||
text: 'Chat.Menu.ClearSelection',
|
text: 'Chat.Menu.ClearSelection',
|
||||||
|
@ -22,9 +22,9 @@ import appPeersManager from "./appPeersManager";
|
|||||||
import appStateManager from './appStateManager';
|
import appStateManager from './appStateManager';
|
||||||
import serverTimeManager from '../mtproto/serverTimeManager';
|
import serverTimeManager from '../mtproto/serverTimeManager';
|
||||||
import assumeType from '../../helpers/assumeType';
|
import assumeType from '../../helpers/assumeType';
|
||||||
import noop from '../../helpers/noop';
|
|
||||||
import RichTextProcessor from '../richtextprocessor';
|
import RichTextProcessor from '../richtextprocessor';
|
||||||
import App from '../../config/app';
|
import App from '../../config/app';
|
||||||
|
import filterUnique from '../../helpers/array/filterUnique';
|
||||||
|
|
||||||
type UpdatesState = {
|
type UpdatesState = {
|
||||||
pendingPtsUpdates: (Update & {pts: number, pts_count: number})[],
|
pendingPtsUpdates: (Update & {pts: number, pts_count: number})[],
|
||||||
@ -624,7 +624,7 @@ export class ApiUpdatesManager {
|
|||||||
rootScope.dispatchEvent(update._, update as any);
|
rootScope.dispatchEvent(update._, update as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
public attach() {
|
public attach(langCode?: string) {
|
||||||
if(this.attached) return;
|
if(this.attached) return;
|
||||||
|
|
||||||
//return;
|
//return;
|
||||||
@ -688,29 +688,41 @@ export class ApiUpdatesManager {
|
|||||||
// });
|
// });
|
||||||
|
|
||||||
if(newVersion) {
|
if(newVersion) {
|
||||||
this.updatesState.syncLoading.then(() => {
|
this.updatesState.syncLoading.then(async() => {
|
||||||
fetch('changelogs/' + newVersion.split(' ')[0] + '.md')
|
const getChangelog = (lang: string) => {
|
||||||
.then(res => (res.status === 200 && res.ok && res.text()) || Promise.reject())
|
fetch(`changelogs/${newVersion.split(' ')[0]}_${lang}.md`)
|
||||||
.then(text => {
|
.then(res => (res.status === 200 && res.ok && res.text()) || Promise.reject())
|
||||||
const pre = `**Telegram Web${App.suffix} was updated to version ${newVersion}**\n\n`;
|
.then(text => {
|
||||||
|
const pre = `**Telegram Web${App.suffix} was updated to version ${newVersion}**\n\n`;
|
||||||
|
|
||||||
|
text = pre + text;
|
||||||
|
|
||||||
|
const entities: MessageEntity[] = [];
|
||||||
|
const message = RichTextProcessor.parseMarkdown(text, entities);
|
||||||
|
|
||||||
|
const update: Update.updateServiceNotification = {
|
||||||
|
_: 'updateServiceNotification',
|
||||||
|
entities,
|
||||||
|
message,
|
||||||
|
type: 'local',
|
||||||
|
pFlags: {},
|
||||||
|
inbox_date: Date.now() / 1000 | 0,
|
||||||
|
media: undefined
|
||||||
|
};
|
||||||
|
|
||||||
text = pre + text;
|
this.processLocalUpdate(update);
|
||||||
|
});
|
||||||
const entities: MessageEntity[] = [];
|
};
|
||||||
const message = RichTextProcessor.parseMarkdown(text, entities);
|
|
||||||
|
const languages = filterUnique([langCode, 'en']);
|
||||||
const update: Update.updateServiceNotification = {
|
for(const language of languages) {
|
||||||
_: 'updateServiceNotification',
|
try {
|
||||||
entities,
|
await getChangelog(language);
|
||||||
message,
|
break;
|
||||||
type: 'local',
|
} catch(err) {
|
||||||
pFlags: {},
|
|
||||||
inbox_date: Date.now() / 1000 | 0,
|
}
|
||||||
media: undefined
|
}
|
||||||
};
|
|
||||||
this.processLocalUpdate(update);
|
|
||||||
})
|
|
||||||
.catch(noop);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -150,7 +150,7 @@ export class AppImManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
apiUpdatesManager.attach();
|
apiUpdatesManager.attach(I18n.lastRequestedLangCode);
|
||||||
appNotificationsManager.start();
|
appNotificationsManager.start();
|
||||||
|
|
||||||
this.log = logger('IM', LogTypes.Log | LogTypes.Warn | LogTypes.Debug | LogTypes.Error);
|
this.log = logger('IM', LogTypes.Log | LogTypes.Warn | LogTypes.Debug | LogTypes.Error);
|
||||||
@ -1164,7 +1164,7 @@ export class AppImManager {
|
|||||||
const top = chatBubbles.scrollable.scrollTop;
|
const top = chatBubbles.scrollable.scrollTop;
|
||||||
|
|
||||||
const position = {
|
const position = {
|
||||||
mids: getObjectKeysAndSort(chatBubbles.bubbles, 'desc'),
|
mids: getObjectKeysAndSort(chatBubbles.bubbles, 'desc').filter(mid => !chatBubbles.skippedMids.has(mid)),
|
||||||
top
|
top
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,28 +7,43 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const text = fs.readFileSync('./CHANGELOG.md').toString('utf-8');
|
const fileNames = fs.readdirSync('./');
|
||||||
|
|
||||||
const writeTo = `./public/changelogs/{VERSION}.md`;
|
const logsPath = './public/changelogs/';
|
||||||
|
fs.rmSync(logsPath, {force: true, recursive: true});
|
||||||
|
fs.mkdirSync(logsPath);
|
||||||
|
|
||||||
const separator = '### ';
|
const processChangelog = (fileName) => {
|
||||||
const splitted = text.split(separator);
|
const text = fs.readFileSync('./' + fileName).toString('utf-8');
|
||||||
splitted.forEach(text => {
|
|
||||||
if(!text.trim()) return;
|
|
||||||
text = separator + text;
|
|
||||||
text = text.replace(/^\*/gm, '•');
|
|
||||||
const splitted = text.split('\n');
|
|
||||||
|
|
||||||
for(let i = splitted.length - 1; i >= 0; --i) {
|
const lang = (fileName.split('_')[1] || 'en').split('.')[0];
|
||||||
const line = splitted[i];
|
const writeTo = `${logsPath}${lang}_{VERSION}.md`;
|
||||||
if(!line.trim()) {
|
|
||||||
splitted.splice(i, 1);
|
const separator = '### ';
|
||||||
} else {
|
const splitted = text.split(separator);
|
||||||
break;
|
splitted.forEach(text => {
|
||||||
|
if(!text.trim()) return;
|
||||||
|
text = separator + text;
|
||||||
|
text = text.replace(/^\*/gm, '•');
|
||||||
|
const splitted = text.split('\n');
|
||||||
|
|
||||||
|
for(let i = splitted.length - 1; i >= 0; --i) {
|
||||||
|
const line = splitted[i];
|
||||||
|
if(!line.trim()) {
|
||||||
|
splitted.splice(i, 1);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
const firstLine = splitted.shift();
|
||||||
|
const version = firstLine.split(' ')[1];
|
||||||
|
fs.writeFileSync(writeTo.replace('{VERSION}', version), splitted.join('\n') + '\n');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const firstLine = splitted.shift();
|
fileNames.forEach(fileName => {
|
||||||
const version = firstLine.split(' ')[1];
|
if(fileName.endsWith('.md') && fileName.startsWith('CHANGELOG')) {
|
||||||
fs.writeFileSync(writeTo.replace('{VERSION}', version), splitted.join('\n') + '\n');
|
processChangelog(fileName);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user