You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-26 22:41:17 +02:00
Desktop: Fix keyboard can't add text after certain error/info dialogs are shown (#11603)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import ElectronAppWrapper from './ElectronAppWrapper';
|
||||
import shim from '@joplin/lib/shim';
|
||||
import shim, { MessageBoxType } from '@joplin/lib/shim';
|
||||
import { _, setLocale } from '@joplin/lib/locale';
|
||||
import { BrowserWindow, nativeTheme, nativeImage, shell, dialog, MessageBoxSyncOptions, safeStorage } from 'electron';
|
||||
import { dirname, toSystemSlashes } from '@joplin/lib/path-utils';
|
||||
@@ -384,9 +384,14 @@ export class Bridge {
|
||||
|
||||
/* returns the index of the clicked button */
|
||||
public showMessageBox(message: string, options: MessageDialogOptions = {}) {
|
||||
const defaultButtons = [_('OK')];
|
||||
if (options.type !== MessageBoxType.Error && options.type !== MessageBoxType.Info) {
|
||||
defaultButtons.push(_('Cancel'));
|
||||
}
|
||||
|
||||
const result = this.showMessageBox_(this.activeWindow(), { type: 'question',
|
||||
message: message,
|
||||
buttons: [_('OK'), _('Cancel')], ...options });
|
||||
buttons: defaultButtons, ...options });
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { CommandRuntime, CommandDeclaration } from '@joplin/lib/services/CommandService';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import shim, { MessageBoxType } from '@joplin/lib/shim';
|
||||
const app = require('@electron/remote').app;
|
||||
const { clipboard } = require('electron');
|
||||
|
||||
@@ -14,7 +15,7 @@ export const runtime = (): CommandRuntime => {
|
||||
const appPath = app.getPath('exe');
|
||||
const cmd = `${appPath} --env dev`;
|
||||
clipboard.writeText(cmd);
|
||||
alert(`The dev mode command has been copied to clipboard:\n\n${cmd}`);
|
||||
await shim.showMessageBox(`The dev mode command has been copied to clipboard:\n\n${cmd}`, { type: MessageBoxType.Info });
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { CommandRuntime, CommandDeclaration, CommandContext } from '@joplin/lib/services/CommandService';
|
||||
import RevisionService from '@joplin/lib/services/RevisionService';
|
||||
import shim, { MessageBoxType } from '@joplin/lib/shim';
|
||||
|
||||
export const declaration: CommandDeclaration = {
|
||||
name: 'restoreNoteRevision',
|
||||
@@ -11,9 +12,9 @@ export const runtime = (): CommandRuntime => {
|
||||
execute: async (_context: CommandContext, noteId: string, reverseRevIndex = 0) => {
|
||||
try {
|
||||
const note = await RevisionService.instance().restoreNoteById(noteId, reverseRevIndex);
|
||||
alert(RevisionService.instance().restoreSuccessMessage(note));
|
||||
await shim.showMessageBox(RevisionService.instance().restoreSuccessMessage(note), { type: MessageBoxType.Info });
|
||||
} catch (error) {
|
||||
alert(error.message);
|
||||
await shim.showErrorDialog(error.message);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@ import ClipperServer from '@joplin/lib/ClipperServer';
|
||||
import Setting from '@joplin/lib/models/Setting';
|
||||
import EncryptionService from '@joplin/lib/services/e2ee/EncryptionService';
|
||||
import { AppState } from '../app.reducer';
|
||||
import shim, { MessageBoxType } from '@joplin/lib/shim';
|
||||
|
||||
class ClipperConfigScreenComponent extends React.Component {
|
||||
public constructor() {
|
||||
@@ -30,7 +31,7 @@ class ClipperConfigScreenComponent extends React.Component {
|
||||
private copyToken_click() {
|
||||
clipboard.writeText(this.props.apiToken);
|
||||
|
||||
alert(_('Token has been copied to the clipboard!'));
|
||||
void shim.showMessageBox(_('Token has been copied to the clipboard!'), { type: MessageBoxType.Info });
|
||||
}
|
||||
|
||||
private renewToken_click() {
|
||||
|
||||
@@ -19,6 +19,7 @@ import shouldShowMissingPasswordWarning from '@joplin/lib/components/shared/conf
|
||||
import MacOSMissingPasswordHelpLink from './controls/MissingPasswordHelpLink';
|
||||
const { KeymapConfigScreen } = require('../KeymapConfig/KeymapConfigScreen');
|
||||
import SettingComponent, { UpdateSettingValueEvent } from './controls/SettingComponent';
|
||||
import shim from '@joplin/lib/shim';
|
||||
|
||||
|
||||
interface Font {
|
||||
@@ -144,7 +145,7 @@ class ConfigScreenComponent extends React.Component<any, any> {
|
||||
screenName = section.name;
|
||||
|
||||
if (this.hasChanges()) {
|
||||
const ok = confirm(_('This will open a new screen. Save your current changes?'));
|
||||
const ok = await shim.showConfirmationDialog(_('This will open a new screen. Save your current changes?'));
|
||||
if (ok) {
|
||||
await shared.saveSettings(this);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import EncryptionService from '@joplin/lib/services/e2ee/EncryptionService';
|
||||
import { themeStyle } from '@joplin/lib/theme';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import time from '@joplin/lib/time';
|
||||
import shim from '@joplin/lib/shim';
|
||||
import shim, { MessageBoxType } from '@joplin/lib/shim';
|
||||
import dialogs from '../dialogs';
|
||||
import { decryptedStatText, determineKeyPassword, dontReencryptData, enableEncryptionConfirmationMessages, onSavePasswordClick, onToggleEnabledClick, reencryptData, upgradeMasterKey, useInputPasswords, useNeedMasterPassword, usePasswordChecker, useStats, useToggleShowDisabledMasterKeys } from '@joplin/lib/components/EncryptionConfigScreen/utils';
|
||||
import { MasterKeyEntity } from '@joplin/lib/services/e2ee/types';
|
||||
@@ -47,7 +47,7 @@ const EncryptionConfigScreen = (props: Props) => {
|
||||
const onUpgradeMasterKey = useCallback(async (mk: MasterKeyEntity) => {
|
||||
const password = determineKeyPassword(mk.id, masterPasswordKeys, props.masterPassword, props.passwords);
|
||||
const result = await upgradeMasterKey(mk, password);
|
||||
alert(result);
|
||||
await shim.showMessageBox(result, { type: MessageBoxType.Info });
|
||||
}, [props.passwords, masterPasswordKeys, props.masterPassword]);
|
||||
|
||||
const renderNeedUpgradeSection = () => {
|
||||
|
||||
@@ -11,6 +11,7 @@ import EncryptionService from '@joplin/lib/services/e2ee/EncryptionService';
|
||||
import KvStore from '@joplin/lib/services/KvStore';
|
||||
import ShareService from '@joplin/lib/services/share/ShareService';
|
||||
import LabelledPasswordInput from '../PasswordInput/LabelledPasswordInput';
|
||||
import shim from '@joplin/lib/shim';
|
||||
|
||||
interface Props {
|
||||
themeId: number;
|
||||
@@ -80,7 +81,7 @@ export default function(props: Props) {
|
||||
void reg.waitForSyncFinishedThenSync();
|
||||
onClose();
|
||||
} catch (error) {
|
||||
alert(error.message);
|
||||
void shim.showErrorDialog(error.message);
|
||||
} finally {
|
||||
setUpdatingPassword(false);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ const urlUtils = require('@joplin/lib/urlUtils');
|
||||
const ReactTooltip = require('react-tooltip');
|
||||
const { connect } = require('react-redux');
|
||||
import shared from '@joplin/lib/components/shared/note-screen-shared';
|
||||
import shim, { MessageBoxType } from '@joplin/lib/shim';
|
||||
|
||||
interface Props {
|
||||
themeId: number;
|
||||
@@ -97,7 +98,7 @@ class NoteRevisionViewerComponent extends React.PureComponent<Props, State> {
|
||||
this.setState({ restoring: true });
|
||||
await RevisionService.instance().importRevisionNote(this.state.note);
|
||||
this.setState({ restoring: false });
|
||||
alert(RevisionService.instance().restoreSuccessMessage(this.state.note));
|
||||
await shim.showMessageBox(RevisionService.instance().restoreSuccessMessage(this.state.note), { type: MessageBoxType.Info });
|
||||
}
|
||||
|
||||
private backButton_click() {
|
||||
|
||||
@@ -18,6 +18,7 @@ import { connect } from 'react-redux';
|
||||
import { reg } from '@joplin/lib/registry';
|
||||
import useAsyncEffect, { AsyncEffectEvent } from '@joplin/lib/hooks/useAsyncEffect';
|
||||
import { ChangeEvent, Dropdown, DropdownOptions, DropdownVariant } from '../Dropdown/Dropdown';
|
||||
import shim from '@joplin/lib/shim';
|
||||
|
||||
const logger = Logger.create('ShareFolderDialog');
|
||||
|
||||
@@ -242,13 +243,13 @@ function ShareFolderDialog(props: Props) {
|
||||
}
|
||||
|
||||
async function recipient_delete(event: RecipientDeleteEvent) {
|
||||
if (!confirm(_('Delete this invitation? The recipient will no longer have access to this shared notebook.'))) return;
|
||||
if (!await shim.showConfirmationDialog(_('Delete this invitation? The recipient will no longer have access to this shared notebook.'))) return;
|
||||
|
||||
try {
|
||||
await ShareService.instance().deleteShareRecipient(event.shareUserId);
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
alert(_('The recipient could not be removed from the list. Please try again.\n\nThe error was: "%s"', error.message));
|
||||
await shim.showErrorDialog(_('The recipient could not be removed from the list. Please try again.\n\nThe error was: "%s"', error.message));
|
||||
}
|
||||
|
||||
await ShareService.instance().refreshShareUsers(share.id);
|
||||
@@ -290,7 +291,7 @@ function ShareFolderDialog(props: Props) {
|
||||
});
|
||||
await ShareService.instance().setPermissions(share.id, shareUserId, permissionsFromString(value));
|
||||
} catch (error) {
|
||||
alert(`Could not set permissions: ${error.message}`);
|
||||
void shim.showErrorDialog(`Could not set permissions: ${error.message}`);
|
||||
logger.error(error);
|
||||
} finally {
|
||||
setRecipientsBeingUpdated(prev => {
|
||||
@@ -383,7 +384,9 @@ function ShareFolderDialog(props: Props) {
|
||||
|
||||
async function buttonRow_click(event: ClickEvent) {
|
||||
if (event.buttonName === 'unshare') {
|
||||
if (!confirm(_('Unshare this notebook? The recipients will no longer have access to its content.'))) return;
|
||||
if (!await shim.showConfirmationDialog(_('Unshare this notebook? The recipients will no longer have access to its content.'))) {
|
||||
return;
|
||||
}
|
||||
await ShareService.instance().unshareFolder(props.folderId);
|
||||
void synchronize();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import { connect } from 'react-redux';
|
||||
import { AppState } from '../app.reducer';
|
||||
import { getEncryptionEnabled } from '@joplin/lib/services/synchronizer/syncInfoUtils';
|
||||
import SyncTargetRegistry from '@joplin/lib/SyncTargetRegistry';
|
||||
import shim from '@joplin/lib/shim';
|
||||
const { clipboard } = require('electron');
|
||||
|
||||
interface Props {
|
||||
@@ -146,7 +147,7 @@ export function ShareNoteDialog(props: Props) {
|
||||
reg.logger().error('ShareNoteDialog: Cannot publish note:', error);
|
||||
|
||||
setSharesState('idle');
|
||||
alert(JoplinServerApi.connectionErrorMessage(error));
|
||||
void shim.showErrorDialog(JoplinServerApi.connectionErrorMessage(error));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -31,6 +31,7 @@ import HeaderItem from '../listItemComponents/HeaderItem';
|
||||
import AllNotesItem from '../listItemComponents/AllNotesItem';
|
||||
import ListItemWrapper from '../listItemComponents/ListItemWrapper';
|
||||
import { focus } from '@joplin/lib/utils/focusHandler';
|
||||
import shim from '@joplin/lib/shim';
|
||||
|
||||
const Menu = bridge().Menu;
|
||||
const MenuItem = bridge().MenuItem;
|
||||
@@ -309,7 +310,7 @@ const useOnRenderItem = (props: Props) => {
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
alert(error.message);
|
||||
await shim.showErrorDialog(error.message);
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { CommandRuntime, CommandDeclaration, CommandContext } from '@joplin/lib/
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import ShareService from '@joplin/lib/services/share/ShareService';
|
||||
import Logger from '@joplin/utils/Logger';
|
||||
import shim from '@joplin/lib/shim';
|
||||
|
||||
const logger = Logger.create('leaveSharedFolder');
|
||||
|
||||
@@ -13,7 +14,7 @@ export const declaration: CommandDeclaration = {
|
||||
export const runtime = (): CommandRuntime => {
|
||||
return {
|
||||
execute: async (_context: CommandContext, folderId: string = null) => {
|
||||
const answer = confirm(_('This will remove the notebook from your collection and you will no longer have access to its content. Do you wish to continue?'));
|
||||
const answer = await shim.showConfirmationDialog(_('This will remove the notebook from your collection and you will no longer have access to its content. Do you wish to continue?'));
|
||||
if (!answer) return;
|
||||
|
||||
try {
|
||||
@@ -28,7 +29,7 @@ export const runtime = (): CommandRuntime => {
|
||||
await ShareService.instance().leaveSharedFolder(folderId, share.user.id);
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
alert(_('Error: %s', error.message));
|
||||
await shim.showErrorDialog(_('Error: %s', error.message));
|
||||
}
|
||||
},
|
||||
enabledCondition: 'joplinServerConnected && folderIsShareRootAndNotOwnedByUser',
|
||||
|
||||
Reference in New Issue
Block a user