1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

major caching improvements

This commit is contained in:
checktheroads
2020-04-18 07:58:46 -07:00
parent 2895d3ae46
commit caf294a36c
7 changed files with 80 additions and 10 deletions

View File

@@ -16,6 +16,7 @@ import styled from "@emotion/styled";
import LightningBolt from "~/components/icons/LightningBolt";
import useAxios from "axios-hooks";
import strReplace from "react-string-replace";
import format from "string-format";
import { startCase } from "lodash";
import useConfig from "~/components/HyperglassProvider";
import useMedia from "~/components/MediaProvider";
@@ -24,6 +25,8 @@ import RequeryButton from "~/components/RequeryButton";
import ResultHeader from "~/components/ResultHeader";
import CacheTimeout from "~/components/CacheTimeout";
format.extend(String.prototype, {});
const FormattedError = ({ keywords, message }) => {
const patternStr = keywords.map((kw) => `(${kw})`).join("|");
const pattern = new RegExp(patternStr, "gi");
@@ -125,7 +128,11 @@ const Result = React.forwardRef(
<>
<CacheTimeout timeout={config.cache.timeout} text={config.web.text.cache_prefix} />
{data?.cached && (
<Tooltip hasArrow label={config.web.text.cache_icon} placement="top">
<Tooltip
hasArrow
label={config.web.text.cache_icon.format({ time: data?.timestamp })}
placement="top"
>
<Box ml={1}>
<LightningBolt color={color[colorMode]} />
</Box>
@@ -136,7 +143,11 @@ const Result = React.forwardRef(
const cacheSm = (
<>
{data?.cached && (
<Tooltip hasArrow label={config.web.text.cache_icon} placement="top">
<Tooltip
hasArrow
label={config.web.text.cache_icon.format({ time: data?.timestamp })}
placement="top"
>
<Box mr={1}>
<LightningBolt color={color[colorMode]} />
</Box>

View File

@@ -7,7 +7,7 @@ format.extend(String.prototype, {});
const runtimeText = (runtime, text) => {
let unit;
if (runtime > 1) {
if (runtime === 1) {
unit = "seconds";
} else {
unit = "second";