mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2025-12-16 18:02:15 +01:00
Implement persisted page visits counter
This commit is contained in:
@@ -19,6 +19,8 @@ ReactDOM.render(root, document.getElementById('root'));
|
|||||||
|
|
||||||
executeStartupCommands();
|
executeStartupCommands();
|
||||||
|
|
||||||
|
appData.appState.registerVisit();
|
||||||
|
|
||||||
log.debug("started");
|
log.debug("started");
|
||||||
|
|
||||||
function executeStartupCommands() {
|
function executeStartupCommands() {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export type PersistedAppData = {
|
|||||||
uiTheme: string;
|
uiTheme: string;
|
||||||
version: number;
|
version: number;
|
||||||
debugMode: boolean | null;
|
debugMode: boolean | null;
|
||||||
|
pageVisistsCount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CommandResultView = {
|
export type CommandResultView = {
|
||||||
@@ -28,6 +29,7 @@ export default class AppState {
|
|||||||
persistedVersion: number;
|
persistedVersion: number;
|
||||||
wasOldVersion: boolean;
|
wasOldVersion: boolean;
|
||||||
env: string;
|
env: string;
|
||||||
|
pageVisitsCount: number;
|
||||||
|
|
||||||
constructor(persistData : PersistedAppData, env: string) {
|
constructor(persistData : PersistedAppData, env: string) {
|
||||||
this.commandResults = [];
|
this.commandResults = [];
|
||||||
@@ -39,6 +41,7 @@ export default class AppState {
|
|||||||
this.persistedVersion = persistData.version || 0.1;
|
this.persistedVersion = persistData.version || 0.1;
|
||||||
this.wasOldVersion = persistData.version != null && this.version > this.persistedVersion;
|
this.wasOldVersion = persistData.version != null && this.version > this.persistedVersion;
|
||||||
this.debugMode = env !== 'prod' || persistData.debugMode === true;
|
this.debugMode = env !== 'prod' || persistData.debugMode === true;
|
||||||
|
this.pageVisitsCount = persistData.pageVisistsCount || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
addCommandResult(input : string, view : JSX.Element) {
|
addCommandResult(input : string, view : JSX.Element) {
|
||||||
@@ -76,12 +79,18 @@ export default class AppState {
|
|||||||
this.triggerChanged();
|
this.triggerChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerVisit() {
|
||||||
|
this.pageVisitsCount++;
|
||||||
|
this.triggerChanged();
|
||||||
|
}
|
||||||
|
|
||||||
getPersistData() : PersistedAppData {
|
getPersistData() : PersistedAppData {
|
||||||
return {
|
return {
|
||||||
emphasizeBytes: this.emphasizeBytes,
|
emphasizeBytes: this.emphasizeBytes,
|
||||||
uiTheme: this.uiTheme,
|
uiTheme: this.uiTheme,
|
||||||
version: this.version,
|
version: this.version,
|
||||||
debugMode: this.debugMode
|
debugMode: this.debugMode,
|
||||||
|
pageVisistsCount: this.pageVisitsCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user