mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-13 17:38:57 +01:00
Check for no shortcuts cases
This commit is contained in:
parent
932e66f330
commit
f7343fd4fd
1 changed files with 20 additions and 13 deletions
|
@ -680,11 +680,13 @@ function ShortcutForm({
|
||||||
}
|
}
|
||||||
|
|
||||||
function ImportExport({ shortcuts, onClose }) {
|
function ImportExport({ shortcuts, onClose }) {
|
||||||
const shortcutsStr = useMemo(
|
const shortcutsStr = useMemo(() => {
|
||||||
() =>
|
if (!shortcuts) return '';
|
||||||
compressToEncodedURIComponent(JSON.stringify(shortcuts.filter(Boolean))),
|
if (!shortcuts.filter(Boolean).length) return '';
|
||||||
[shortcuts],
|
return compressToEncodedURIComponent(
|
||||||
);
|
JSON.stringify(shortcuts.filter(Boolean)),
|
||||||
|
);
|
||||||
|
}, [shortcuts]);
|
||||||
const [importShortcutStr, setImportShortcutStr] = useState('');
|
const [importShortcutStr, setImportShortcutStr] = useState('');
|
||||||
const [importUIState, setImportUIState] = useState('default');
|
const [importUIState, setImportUIState] = useState('default');
|
||||||
const parsedImportShortcutStr = useMemo(() => {
|
const parsedImportShortcutStr = useMemo(() => {
|
||||||
|
@ -901,6 +903,7 @@ function ImportExport({ shortcuts, onClose }) {
|
||||||
value={shortcutsStr}
|
value={shortcutsStr}
|
||||||
readOnly
|
readOnly
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
if (!e.target.value) return;
|
||||||
e.target.select();
|
e.target.select();
|
||||||
// Copy url to clipboard
|
// Copy url to clipboard
|
||||||
try {
|
try {
|
||||||
|
@ -917,6 +920,7 @@ function ImportExport({ shortcuts, onClose }) {
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="plain2"
|
class="plain2"
|
||||||
|
disabled={!shortcutsStr}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
try {
|
try {
|
||||||
navigator.clipboard.writeText(shortcutsStr);
|
navigator.clipboard.writeText(shortcutsStr);
|
||||||
|
@ -936,6 +940,7 @@ function ImportExport({ shortcuts, onClose }) {
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="plain2"
|
class="plain2"
|
||||||
|
disabled={!shortcutsStr}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
try {
|
try {
|
||||||
navigator.share({
|
navigator.share({
|
||||||
|
@ -956,14 +961,16 @@ function ImportExport({ shortcuts, onClose }) {
|
||||||
</small>
|
</small>
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
<details>
|
{!!shortcutsStr && (
|
||||||
<summary class="insignificant">
|
<details>
|
||||||
<small>Raw Shortcuts JSON</small>
|
<summary class="insignificant">
|
||||||
</summary>
|
<small>Raw Shortcuts JSON</small>
|
||||||
<textarea style={{ width: '100%' }} rows={10} readOnly>
|
</summary>
|
||||||
{JSON.stringify(shortcuts.filter(Boolean), null, 2)}
|
<textarea style={{ width: '100%' }} rows={10} readOnly>
|
||||||
</textarea>
|
{JSON.stringify(shortcuts.filter(Boolean), null, 2)}
|
||||||
</details>
|
</textarea>
|
||||||
|
</details>
|
||||||
|
)}
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue