Skip to content

Commit

Permalink
Firefox optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
wtetsu committed Oct 16, 2021
1 parent 2dbe3d1 commit 6b2cf22
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 27 deletions.
42 changes: 16 additions & 26 deletions src/options/component/organism/Tips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import React from "react";
import { res } from "../../logic";
import { ExternalLink } from "../atom/ExternalLink";
import { Links } from "../../resource/links";

type TipsProps = {
style: React.CSSProperties;
Expand All @@ -22,35 +23,24 @@ const LINK_STYLE: React.CSSProperties = {
};

export const Tips: React.VFC<TipsProps> = (props) => {
const tips = [
{ text: res.get("windowManipulation"), href: Links.windowManipulation },
{ text: res.get("downloadDictData"), href: Links.downloadDictData },
{ text: res.get("setKeyboardShortcuts"), href: Links.setKeyboardShortcuts },
];

return (
<div style={{ ...props.style }}>
<div style={STYLE_INNER}>
<ExternalLink
href="https://github.com/wtetsu/mouse-dictionary/wiki/Window-manipulation"
icon={true}
style={LINK_STYLE}
>
<img src="img/hint.png" width="16" height="16" style={{ position: "relative", top: 3, marginRight: 3 }} />
{res.get("windowManipulation")}
</ExternalLink>
<br />
<ExternalLink
href="https://github.com/wtetsu/mouse-dictionary/wiki/Download-dictionary-data"
icon={true}
style={LINK_STYLE}
>
<img src="img/hint.png" width="16" height="16" style={{ position: "relative", top: 3, marginRight: 3 }} />
{res.get("downloadDictData")}
</ExternalLink>
<br />
<ExternalLink
href="https://github.com/wtetsu/mouse-dictionary/wiki/Keyboard-shortcuts"
icon={true}
style={LINK_STYLE}
>
<img src="img/hint.png" width="16" height="16" style={{ position: "relative", top: 3, marginRight: 3 }} />
{res.get("setKeyboardShortcuts")}
</ExternalLink>
{tips.map((e, i) => (
<>
<ExternalLink key={i} href={e.href} icon={true} style={LINK_STYLE}>
<img src="img/hint.png" width="16" height="16" style={{ position: "relative", top: 3, marginRight: 3 }} />
{e.text}
</ExternalLink>
<br />
</>
))}
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/options/extern/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const optionsEnv = { ...env } as Env;
if (BROWSER === "FIREFOX") {
// Larger registerRecordsAtOnce causes memory hog
// when loading large dictionary data in Firefox.
optionsEnv.registerRecordsAtOnce = 1000;
optionsEnv.registerRecordsAtOnce = 10000;
optionsEnv.support = { localGetBytesInUse: false };
} else {
optionsEnv.registerRecordsAtOnce = 100000;
Expand Down
21 changes: 21 additions & 0 deletions src/options/resource/links.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Mouse Dictionary (https://github.com/wtetsu/mouse-dictionary/)
* Copyright 2018-present wtetsu
* Licensed under MIT
*/

import { BROWSER, ExternalLinks } from "../types";

const Links: ExternalLinks = {
windowManipulation: "https://github.com/wtetsu/mouse-dictionary/wiki/Window-manipulation",
downloadDictData: "https://github.com/wtetsu/mouse-dictionary/wiki/Download-dictionary-data",
setKeyboardShortcuts: "",
};

if (BROWSER === "FIREFOX") {
Links.setKeyboardShortcuts = "https://github.com/wtetsu/mouse-dictionary/wiki/Keyboard-shortcuts-(Firefox)";
} else {
Links.setKeyboardShortcuts = "https://github.com/wtetsu/mouse-dictionary/wiki/Keyboard-shortcuts";
}

export { Links };
6 changes: 6 additions & 0 deletions src/options/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,10 @@ export type DictionaryFile = {
format: DictionaryFileFormat;
};

export type ExternalLinks = {
windowManipulation: string;
downloadDictData: string;
setKeyboardShortcuts: string;
};

export declare const BROWSER: "CHROME" | "FIREFOX" | "SAFARI";

0 comments on commit 6b2cf22

Please sign in to comment.