Browse Source

Make changelogs available only for new versions

master
morethanwords 3 years ago
parent
commit
0ac6675e28
  1. 2
      src/lib/appManagers/apiUpdatesManager.ts
  2. 10
      src/lib/appManagers/appStateManager.ts
  3. 3
      src/scripts/generate_changelog.js

2
src/lib/appManagers/apiUpdatesManager.ts

@ -689,7 +689,7 @@ export class ApiUpdatesManager {
if(newVersion) { if(newVersion) {
this.updatesState.syncLoading.then(() => { this.updatesState.syncLoading.then(() => {
fetch('changelogs/' + newVersion + '.md') fetch('changelogs/' + newVersion.split(' ')[0] + '.md')
.then(res => (res.status === 200 && res.ok && res.text()) || Promise.reject()) .then(res => (res.status === 200 && res.ok && res.text()) || Promise.reject())
.then(text => { .then(text => {
const pre = `**Telegram Web${App.suffix} was updated to version alpha ${newVersion}**\n\n`; const pre = `**Telegram Web${App.suffix} was updated to version alpha ${newVersion}**\n\n`;

10
src/lib/appManagers/appStateManager.ts

@ -28,7 +28,7 @@ import compareVersion from '../../helpers/compareVersion';
const REFRESH_EVERY = 24 * 60 * 60 * 1000; // 1 day const REFRESH_EVERY = 24 * 60 * 60 * 1000; // 1 day
// const REFRESH_EVERY = 1e3; // const REFRESH_EVERY = 1e3;
//const REFRESH_EVERY_WEEK = 24 * 60 * 60 * 1000 * 7; // 7 days //const REFRESH_EVERY_WEEK = 24 * 60 * 60 * 1000 * 7; // 7 days
const STATE_VERSION = App.versionFull; const STATE_VERSION = App.version;
const BUILD = App.build; const BUILD = App.build;
export type Background = { export type Background = {
@ -421,7 +421,7 @@ export class AppStateManager extends EventListenerBase<{
this.pushToState(missingKey, state[missingKey]); this.pushToState(missingKey, state[missingKey]);
}); });
if(state.version !== STATE_VERSION/* || true */) { if(state.version !== STATE_VERSION || state.build !== BUILD/* || true */) {
// reset filters and dialogs if version is older // reset filters and dialogs if version is older
if(compareVersion(state.version, '0.8.7') === -1) { if(compareVersion(state.version, '0.8.7') === -1) {
this.state.allDialogsLoaded = copy(STATE_INIT.allDialogsLoaded); this.state.allDialogsLoaded = copy(STATE_INIT.allDialogsLoaded);
@ -431,8 +431,12 @@ export class AppStateManager extends EventListenerBase<{
result.length = 0; result.length = 0;
} }
} }
if(compareVersion(state.version, STATE_VERSION) !== 0) {
this.newVersion = STATE_VERSION;
}
this.pushToState('version', this.newVersion = STATE_VERSION); this.pushToState('version', STATE_VERSION);
this.pushToState('build', BUILD); this.pushToState('build', BUILD);
} }

3
src/scripts/generate_changelog.js

@ -29,5 +29,6 @@ splitted.forEach(text => {
} }
const firstLine = splitted.shift(); const firstLine = splitted.shift();
fs.writeFileSync(writeTo.replace('{VERSION}', firstLine.substr(4)), splitted.join('\n') + '\n'); const version = firstLine.split(' ')[1];
fs.writeFileSync(writeTo.replace('{VERSION}', version), splitted.join('\n') + '\n');
}); });

Loading…
Cancel
Save