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 && (
+ {
+ setImportUIState('cloud-downloading');
+ const currentAccount = store.session.get('currentAccount');
+ showToast(
+ 'Downloading saved shortcuts from instance server…',
+ );
+ try {
+ const relationships =
+ await masto.v1.accounts.relationships.fetch({
+ id: [currentAccount],
+ });
+ const relationship = relationships[0];
+ if (relationship) {
+ const { note = '' } = relationship;
+ if (
+ /(.*)<\/phanpy-shortcuts-settings>/.test(
+ note,
+ )
+ ) {
+ const settings = note.match(
+ /(.*)<\/phanpy-shortcuts-settings>/,
+ )[1];
+ const { v, dt, data } = JSON.parse(settings);
+ shortcutsImportFieldRef.current.value = data;
+ shortcutsImportFieldRef.current.dispatchEvent(
+ new Event('input'),
+ );
+ }
+ }
+ setImportUIState('default');
+ } catch (e) {
+ console.error(e);
+ setImportUIState('error');
+ showToast('Unable to download shortcuts');
+ }
+ }}
+ title="Download shortcuts from instance server"
+ >
+
+
+
+ )}
{!!parsedImportShortcutStr &&
Array.isArray(parsedImportShortcutStr) && (
@@ -991,8 +1043,64 @@ function ImportExport({ shortcuts, onClose }) {
Share
)}{' '}
+ {states.settings.shortcutSettingsCloudImportExport && (
+
{
+ setImportUIState('cloud-uploading');
+ const currentAccount = store.session.get('currentAccount');
+ try {
+ const relationships =
+ await masto.v1.accounts.relationships.fetch({
+ id: [currentAccount],
+ });
+ const relationship = relationships[0];
+ if (relationship) {
+ const { note = '' } = relationship;
+ // const newNote = `${note}\n\n\n${shortcutsStr} `;
+ let newNote = '';
+ if (
+ /(.*)<\/phanpy-shortcuts-settings>/.test(
+ note,
+ )
+ ) {
+ const settingsJSON = JSON.stringify({
+ v: '1', // version
+ dt: Date.now(), // datetime stamp
+ data: shortcutsStr, // shortcuts settings string
+ });
+ newNote = note.replace(
+ /(.*)<\/phanpy-shortcuts-settings>/,
+ `${settingsJSON} `,
+ );
+ } else {
+ newNote = `${note}\n\n\n${settingsJSON} `;
+ }
+ showToast('Saving shortcuts to instance server…');
+ await masto.v1.accounts
+ .$select(currentAccount)
+ .note.create({
+ comment: newNote,
+ });
+ setImportUIState('default');
+ showToast('Shortcuts saved');
+ }
+ } catch (e) {
+ console.error(e);
+ setImportUIState('error');
+ showToast('Unable to save shortcuts');
+ }
+ }}
+ title="Sync to instance server"
+ >
+
+
+
+ )}{' '}
{shortcutsStr.length > 0 && (
-
+
{shortcutsStr.length} characters
)}
@@ -1008,6 +1116,14 @@ function ImportExport({ shortcuts, onClose }) {
)}
+ {states.settings.shortcutSettingsCloudImportExport && (
+
+ )}
);
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 && (
+
+
+ {
+ states.settings.shortcutSettingsCloudImportExport =
+ e.target.checked;
+ }}
+ />{' '}
+ "Cloud" import/export for shortcuts settings{' '}
+
+
+
+
+ ⚠️⚠️⚠️ 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.
+
+
+
+ )}
{
if (path.join('.') === 'settings.contentTranslationAutoInline') {
store.account.set('settings-contentTranslationAutoInline', !!value);
}
+ if (path.join('.') === 'settings.shortcutSettingsCloudImportExport') {
+ store.account.set('settings-shortcutSettingsCloudImportExport', !!value);
+ }
if (path.join('.') === 'settings.contentTranslationTargetLanguage') {
console.log('SET', value);
store.account.set('settings-contentTranslationTargetLanguage', value);