Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

App load tweaks, i18n and localStorage #4367

Merged
merged 2 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/gen-i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ const walkOpts = {
const fullPath = path.join(root, fileStats.name);

let trs;
if (fileStats.name.endsWith('.js') || fileStats.name.endsWith('.tsx')) {
if (fileStats.name.endsWith('.js') || fileStats.name.endsWith('.ts') || fileStats.name.endsWith('.tsx')) {
trs = getTranslationsJs(fullPath);
} else if (fileStats.name.endsWith('.html')) {
trs = getTranslationsOther(fullPath);
Expand Down
16 changes: 9 additions & 7 deletions src/Analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ const LAST_VISIT_TS_KEY = "mx_Riot_Analytics_lvts";

function getUid() {
try {
let data = localStorage.getItem(UID_KEY);
if (!data) {
let data = localStorage && localStorage.getItem(UID_KEY);
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
if (!data && localStorage) {
localStorage.setItem(UID_KEY, data = [...Array(16)].map(() => Math.random().toString(16)[2]).join(''));
}
return data;
Expand All @@ -145,14 +145,16 @@ class Analytics {
this.firstPage = true;
this._heartbeatIntervalID = null;

this.creationTs = localStorage.getItem(CREATION_TS_KEY);
if (!this.creationTs) {
this.creationTs = localStorage && localStorage.getItem(CREATION_TS_KEY);
if (!this.creationTs && localStorage) {
localStorage.setItem(CREATION_TS_KEY, this.creationTs = new Date().getTime());
}

this.lastVisitTs = localStorage.getItem(LAST_VISIT_TS_KEY);
this.visitCount = localStorage.getItem(VISIT_COUNT_KEY) || 0;
localStorage.setItem(VISIT_COUNT_KEY, parseInt(this.visitCount, 10) + 1);
this.lastVisitTs = localStorage && localStorage.getItem(LAST_VISIT_TS_KEY);
this.visitCount = localStorage && localStorage.getItem(VISIT_COUNT_KEY) || 0;
if (localStorage) {
localStorage.setItem(VISIT_COUNT_KEY, parseInt(this.visitCount, 10) + 1);
}
}

get disabled() {
Expand Down