A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: only show loading indicator on button that was pressed
Abdullah Attaeb2b92d85cc6
diff --git a/apps/web/src/dialogs/settings/index.tsx b/apps/web/src/dialogs/settings/index.tsxindex 322346e65..c3d62e6ff 100644--- a/apps/web/src/dialogs/settings/index.tsx+++ b/apps/web/src/dialogs/settings/index.tsx@@ -379,7 +379,7 @@ function SettingsGroupComponent(props: { item: SettingsGroup }) {function SettingItem(props: { item: Setting }) {const { item } = props;const [state, setState] = useState<unknown>();- const [isWorking, setIsWorking] = useState(false);+ const [workIndex, setWorkIndex] = useState<number>();const isUserPremium = useIsUserPremium();useEffect(() => {@@ -388,16 +388,16 @@ function SettingItem(props: { item: Setting }) {}, [item]);const workWithLoading = useCallback(- async (action) => {- if (isWorking) return;+ async (index: number, action: () => Promise<unknown> | void) => {+ if (workIndex) return;try {- setIsWorking(true);+ setWorkIndex(index);await action();} finally {- setIsWorking(false);+ setWorkIndex(undefined);}},- [isWorking]+ [workIndex]);if (item.isHidden && item.isHidden(state)) return null;@@ -447,17 +447,17 @@ function SettingItem(props: { item: Setting }) {"& > label": { width: "auto" }}}>- {components.map((component) => {+ {components.map((component, index) => {switch (component.type) {case "button":return (<Button- disabled={isWorking}+ disabled={workIndex === index}title={component.title}variant={component.variant}- onClick={() => workWithLoading(component.action)}+ onClick={() => workWithLoading(index, component.action)}>- {isWorking ? (+ {workIndex ? (<Loading size={18} sx={{ mr: 2 }} />) : (component.title@@ -473,8 +473,8 @@ function SettingItem(props: { item: Setting }) {? "accent": "icon-secondary"}}- disabled={isWorking}- onChange={() => workWithLoading(component.toggle)}+ disabled={workIndex === index}+ onChange={() => workWithLoading(index, component.toggle)}checked={component.isToggled()}data-checked={component.isToggled()}/>