Skip to content

Commit

Permalink
Merge pull request #141 from vezwork/fixUndefinedTimeSpentDetail
Browse files Browse the repository at this point in the history
Fix favicon loading so it does not block data storage
  • Loading branch information
sharon-wang authored Apr 25, 2021
2 parents 4a836d6 + 3edf9ab commit 26fea1a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/data/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ async function updateAkitaData(originData, data, typeOfData, isMonetizedData) {
updateTimeSpent(originData, originStats, data, isMonetizedData);
break;
case AKITA_DATA_TYPE.ORIGIN_FAVICON: // Only for a monetized origin
await updateOriginFavicon(originData, data);
updateOriginFavicon(originData, data);
break;
default:
// console.log("invalid data type provided");
Expand Down
27 changes: 16 additions & 11 deletions src/popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,25 +384,26 @@ function createTopSiteDetailEls(originData, originStats) {
textEl(`Crunching time spent numbers...`)
]);
}
} else {
setContentOfEl(timeSpentEl, [textEl(`Crunching time spent numbers...`)]);
}

// Set visit count text
let visitCountText = ``;
const visitCount = originData.originVisitData.numberOfVisits;
if (visitCount === 0) {
// Don't set the visit count text
} else if (visitCount === 1) {
visitCountText = `${visitCount} time`;
} else {
visitCountText = `${visitCount} times`;
}

// Set visit count text
let visitCountEl = paragraphEl();
if (visitCountText !== ``) {
if (visitCount > 0) {
const percentVisits = getPercentVisitsToOriginOutOfTotal(originData, originStats);
if (percentVisits > 0) {
let timeText;
if (visitCount > 1) {
timeText = `times`;
} else {
timeText = `time`;
}
setContentOfEl(visitCountEl, [
textEl(`You've visited `),
strongEl(visitCountText),
strongEl(`${visitCount} ${timeText}`),
textEl(`, which is `),
strongEl(`${percentVisits}%`),
textEl(` of your total website visits.`)
Expand All @@ -412,6 +413,10 @@ function createTopSiteDetailEls(originData, originStats) {
textEl(`Counting up visits...`)
]);
}
} else {
setContentOfEl(visitCountEl, [
textEl(`Counting up visits...`)
]);
}

// Set payment data text
Expand Down

0 comments on commit 26fea1a

Please sign in to comment.