Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

Commit

Permalink
fix: чистка сохранённых данных старых версий
Browse files Browse the repository at this point in the history
closes #42
  • Loading branch information
anmostovoy committed Mar 20, 2017
1 parent 1d8e44c commit c3e422d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
7 changes: 4 additions & 3 deletions source/js/tabs/settings/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import {setsAuto} from './sets-auto';
import {setsGame} from './sets-game';
import {sendNotify} from '../../notifications/sendNotify';

clientStorage.remove('settings');

export default class Settings {
tab = createTab(`настройки`);
$root = this.tab.$content;
settingsValues: SettingsValues = clientStorage.get('settings') || {};
settingsValues: SettingsValues = clientStorage.get('ext_settings') || {};
deps: PlainObject<string[]> = {};

private _onNamedSettingChange = EventEmitter<SettingsData>();
Expand Down Expand Up @@ -119,7 +120,7 @@ export default class Settings {
this.checkDependencies(data);
this.settingsValues[data.name as keyof SettingsValues] = data.value;
this._onNamedSettingChange.emit(data);
clientStorage.set('settings', this.settingsValues);
clientStorage.set('ext_settings', this.settingsValues);
console.log('settings: ', this.settingsValues);
});
}
Expand Down Expand Up @@ -197,7 +198,7 @@ export default class Settings {
${st.subs ? this.drawSetsGroup(st.subs) : ''}
</div>`;
}
clientStorage.set('settings', this.settingsValues);
clientStorage.set('ext_settings', this.settingsValues);

return html;
}
Expand Down
8 changes: 5 additions & 3 deletions source/js/tracking/Tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ const COMPANION_PHRASE_ID = [
580004,
];

clientStorage.remove('messagesLog');

/**
* Позволяет подписаться на обновление данных
*/
export default class Tracking {
messagesLog: MessageRaw[] = clientStorage.get('messagesLog') || [];
messagesLog: MessageRaw[] = clientStorage.get('ext_log') || [];
maxLogLength: number;
onNewTurn = EventEmitter<any>();
onNewMessages = EventEmitter<Message[]>();
Expand Down Expand Up @@ -105,7 +107,7 @@ export default class Tracking {
}

this.messagesLog = messagesLog.slice(this.maxLogLength ? messagesLog.length - this.maxLogLength : 0);
clientStorage.set('messagesLog', this.messagesLog);
clientStorage.set('ext_log', this.messagesLog);

this.onNewTurn.emit(hero);
if (messagesNew.length) {
Expand Down Expand Up @@ -144,7 +146,7 @@ export default class Tracking {
}

clear() {
clientStorage.set('messagesLog', '');
clientStorage.remove('ext_log');
this.messagesLog = [];
}
}
5 changes: 5 additions & 0 deletions source/js/utils/clientStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ function get(name: string) {
const g = pgf.base.settings.get(name);
return g ? JSON.parse(g) : null;
}
function remove(name: string) {
if (!window.localStorage) return;
localStorage.removeItem(pgf.base.settings._prefix + '_' + name);
}

function size(): number {
let t = 0;
Expand All @@ -26,6 +30,7 @@ function size(): number {


export default {
remove,
set,
get,
size,
Expand Down

0 comments on commit c3e422d

Please sign in to comment.