From a8b5c8cd64d456d30aab09dc56da7e4e20100e67 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 26 Feb 2024 14:00:53 +0800 Subject: [PATCH] Experimental "cloud" shortcuts settings import/export --- src/app.css | 2 +- src/components/account-info.jsx | 21 +++++ src/components/shortcuts-settings.css | 20 +++++ src/components/shortcuts-settings.jsx | 120 +++++++++++++++++++++++++- src/pages/settings.jsx | 33 +++++++ src/utils/states.js | 6 ++ 6 files changed, 199 insertions(+), 3 deletions(-) diff --git a/src/app.css b/src/app.css index f33cfd43..6aa65765 100644 --- a/src/app.css +++ b/src/app.css @@ -2108,7 +2108,7 @@ meter.donut[hidden] { :root .toastify { user-select: none; padding: 8px 16px; - border-radius: 999px; + border-radius: 44px; pointer-events: none; color: var(--button-text-color); text-shadow: 0 calc(var(--hairline-width) * -1) var(--drop-shadow-color); diff --git a/src/components/account-info.jsx b/src/components/account-info.jsx index 0f5fd5b0..d7e8e99f 100644 --- a/src/components/account-info.jsx +++ b/src/components/account-info.jsx @@ -1251,6 +1251,27 @@ function RelatedActions({ )} + {import.meta.env.DEV && currentAuthenticated && isSelf && ( + <> + + { + const relationships = + await currentMasto.v1.accounts.relationships.fetch({ + id: [accountID.current], + }); + const { note } = relationships[0] || {}; + if (note) { + alert(note); + console.log(note); + } + }} + > + + See note + + + )} {!relationship && relationshipUIState === 'loading' && ( diff --git a/src/components/shortcuts-settings.css b/src/components/shortcuts-settings.css index f2b2aba6..86cc6f70 100644 --- a/src/components/shortcuts-settings.css +++ b/src/components/shortcuts-settings.css @@ -153,6 +153,15 @@ } #import-export-container section p { margin: 8px 0; + + &.field-button { + display: flex; + gap: 8px; + + button { + flex-shrink: 0; + } + } } #import-export-container section details > summary { cursor: pointer; @@ -182,3 +191,14 @@ font-size: 90%; flex-shrink: 0; } + +#import-export-container { + footer { + font-size: 90%; + color: var(--text-insignificant-color); + + .icon { + vertical-align: text-bottom; + } + } +} diff --git a/src/components/shortcuts-settings.jsx b/src/components/shortcuts-settings.jsx index 1044ad73..d2e82a88 100644 --- a/src/components/shortcuts-settings.jsx +++ b/src/components/shortcuts-settings.jsx @@ -17,6 +17,7 @@ import { fetchFollowedTags } from '../utils/followed-tags'; import pmem from '../utils/pmem'; import showToast from '../utils/show-toast'; import states from '../utils/states'; +import store from '../utils/store'; import AsyncText from './AsyncText'; import Icon from './icon'; @@ -716,6 +717,7 @@ function ShortcutForm({ } function ImportExport({ shortcuts, onClose }) { + const { masto } = api(); const shortcutsStr = useMemo(() => { if (!shortcuts) return ''; if (!shortcuts.filter(Boolean).length) return ''; @@ -754,6 +756,8 @@ function ImportExport({ shortcuts, onClose }) { }, [importShortcutStr]); const hasCurrentSettings = states.shortcuts.length > 0; + const shortcutsImportFieldRef = useRef(); + return (
{!!onClose && ( @@ -772,8 +776,9 @@ function ImportExport({ shortcuts, onClose }) { {' '} Import -

+

+ {states.settings.shortcutSettingsCloudImportExport && ( + + )}

{!!parsedImportShortcutStr && Array.isArray(parsedImportShortcutStr) && ( @@ -991,8 +1043,64 @@ function ImportExport({ shortcuts, onClose }) { Share )}{' '} + {states.settings.shortcutSettingsCloudImportExport && ( + + )}{' '} {shortcutsStr.length > 0 && ( - + {shortcutsStr.length} characters )} @@ -1008,6 +1116,14 @@ function ImportExport({ shortcuts, onClose }) { )} + {states.settings.shortcutSettingsCloudImportExport && ( +
+

+ Import/export settings from/to instance + server (Very experimental) +

+
+ )}
); diff --git a/src/pages/settings.jsx b/src/pages/settings.jsx index 99a6c01b..b3f9af4b 100644 --- a/src/pages/settings.jsx +++ b/src/pages/settings.jsx @@ -464,6 +464,39 @@ function Settings({ onClose }) { )} + {authenticated && ( +
  • + +
    + + ⚠️⚠️⚠️ Very experimental. +
    + Stored in your own profile’s notes. Profile (private) notes + are mainly used for other profiles, and hidden for own + profile. +
    +
    +
    + + Note: This feature uses currently-logged-in instance server + API. + +
    +
  • + )}