Browse Source

Fix loading top history because of hidden message

Support different languages of changelogs
master
Eduard Kuzmenko 3 years ago
parent
commit
0b3574ff9d
  1. 2
      src/components/chat/topbar.ts
  2. 24
      src/lib/appManagers/apiUpdatesManager.ts
  3. 4
      src/lib/appManagers/appImManager.ts
  4. 19
      src/scripts/generate_changelog.js

2
src/components/chat/topbar.ts

@ -386,7 +386,7 @@ export default class ChatTopbar { @@ -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',
text: 'Chat.Menu.ClearSelection',

24
src/lib/appManagers/apiUpdatesManager.ts

@ -22,9 +22,9 @@ import appPeersManager from "./appPeersManager"; @@ -22,9 +22,9 @@ import appPeersManager from "./appPeersManager";
import appStateManager from './appStateManager';
import serverTimeManager from '../mtproto/serverTimeManager';
import assumeType from '../../helpers/assumeType';
import noop from '../../helpers/noop';
import RichTextProcessor from '../richtextprocessor';
import App from '../../config/app';
import filterUnique from '../../helpers/array/filterUnique';
type UpdatesState = {
pendingPtsUpdates: (Update & {pts: number, pts_count: number})[],
@ -624,7 +624,7 @@ export class ApiUpdatesManager { @@ -624,7 +624,7 @@ export class ApiUpdatesManager {
rootScope.dispatchEvent(update._, update as any);
}
public attach() {
public attach(langCode?: string) {
if(this.attached) return;
//return;
@ -688,8 +688,9 @@ export class ApiUpdatesManager { @@ -688,8 +688,9 @@ export class ApiUpdatesManager {
// });
if(newVersion) {
this.updatesState.syncLoading.then(() => {
fetch('changelogs/' + newVersion.split(' ')[0] + '.md')
this.updatesState.syncLoading.then(async() => {
const getChangelog = (lang: string) => {
fetch(`changelogs/${newVersion.split(' ')[0]}_${lang}.md`)
.then(res => (res.status === 200 && res.ok && res.text()) || Promise.reject())
.then(text => {
const pre = `**Telegram Web${App.suffix} was updated to version ${newVersion}**\n\n`;
@ -708,9 +709,20 @@ export class ApiUpdatesManager { @@ -708,9 +709,20 @@ export class ApiUpdatesManager {
inbox_date: Date.now() / 1000 | 0,
media: undefined
};
this.processLocalUpdate(update);
})
.catch(noop);
});
};
const languages = filterUnique([langCode, 'en']);
for(const language of languages) {
try {
await getChangelog(language);
break;
} catch(err) {
}
}
});
}
});

4
src/lib/appManagers/appImManager.ts

@ -150,7 +150,7 @@ export class AppImManager { @@ -150,7 +150,7 @@ export class AppImManager {
}
constructor() {
apiUpdatesManager.attach();
apiUpdatesManager.attach(I18n.lastRequestedLangCode);
appNotificationsManager.start();
this.log = logger('IM', LogTypes.Log | LogTypes.Warn | LogTypes.Debug | LogTypes.Error);
@ -1164,7 +1164,7 @@ export class AppImManager { @@ -1164,7 +1164,7 @@ export class AppImManager {
const top = chatBubbles.scrollable.scrollTop;
const position = {
mids: getObjectKeysAndSort(chatBubbles.bubbles, 'desc'),
mids: getObjectKeysAndSort(chatBubbles.bubbles, 'desc').filter(mid => !chatBubbles.skippedMids.has(mid)),
top
};

19
src/scripts/generate_changelog.js

@ -7,9 +7,17 @@ @@ -7,9 +7,17 @@
// @ts-check
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 processChangelog = (fileName) => {
const text = fs.readFileSync('./' + fileName).toString('utf-8');
const lang = (fileName.split('_')[1] || 'en').split('.')[0];
const writeTo = `${logsPath}${lang}_{VERSION}.md`;
const separator = '### ';
const splitted = text.split(separator);
@ -32,3 +40,10 @@ splitted.forEach(text => { @@ -32,3 +40,10 @@ splitted.forEach(text => {
const version = firstLine.split(' ')[1];
fs.writeFileSync(writeTo.replace('{VERSION}', version), splitted.join('\n') + '\n');
});
};
fileNames.forEach(fileName => {
if(fileName.endsWith('.md') && fileName.startsWith('CHANGELOG')) {
processChangelog(fileName);
}
});

Loading…
Cancel
Save