You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-23 22:36:32 +02:00
Mobile: Fix homescreen new-note shortcuts are re-applied after switching notes (#11779)
This commit is contained in:
@@ -36,9 +36,10 @@ interface WrapperProps {
|
||||
|
||||
let store: Store<AppState>;
|
||||
|
||||
const mockNavigation = { state: { } };
|
||||
const WrappedNoteScreen: React.FC<WrapperProps> = _props => {
|
||||
return <TestProviderStack store={store}>
|
||||
<NoteScreen />
|
||||
<NoteScreen navigation={mockNavigation}/>
|
||||
</TestProviderStack>;
|
||||
};
|
||||
|
||||
|
||||
@@ -73,8 +73,16 @@ interface InsertTextOptions {
|
||||
newLine?: boolean;
|
||||
}
|
||||
|
||||
interface NoteNavigation {
|
||||
// Arguments passed to the NAV_GO action
|
||||
state: {
|
||||
newNoteAttachFileAction?: AttachFileAction;
|
||||
};
|
||||
}
|
||||
|
||||
interface Props extends BaseProps {
|
||||
provisionalNoteIds: string[];
|
||||
navigation: NoteNavigation;
|
||||
dispatch: Dispatch;
|
||||
noteId: string;
|
||||
useEditorBeta: boolean;
|
||||
@@ -89,7 +97,6 @@ interface Props extends BaseProps {
|
||||
highlightedWords: string[];
|
||||
noteHash: string;
|
||||
toolbarEnabled: boolean;
|
||||
newNoteAttachFileAction: AttachFileAction;
|
||||
}
|
||||
|
||||
interface ComponentProps extends Props {
|
||||
@@ -531,13 +538,14 @@ class NoteScreenComponent extends BaseScreenComponent<ComponentProps, State> imp
|
||||
// been granted, the popup will open anyway.
|
||||
void this.requestGeoLocationPermissions();
|
||||
|
||||
if (this.props.newNoteAttachFileAction) {
|
||||
const action = this.props.navigation.state?.newNoteAttachFileAction;
|
||||
if (action) {
|
||||
setTimeout(async () => {
|
||||
if (this.props.newNoteAttachFileAction === AttachFileAction.AttachDrawing) {
|
||||
if (action === AttachFileAction.AttachDrawing) {
|
||||
await this.drawPicture_onPress();
|
||||
} else {
|
||||
const options: AttachFileOptions = {
|
||||
action: this.props.newNoteAttachFileAction,
|
||||
action: action,
|
||||
};
|
||||
await CommandService.instance().execute('attachFile', '', options);
|
||||
}
|
||||
@@ -1632,7 +1640,6 @@ const NoteScreen = connect((state: AppState) => {
|
||||
return {
|
||||
noteId: state.selectedNoteIds.length ? state.selectedNoteIds[0] : null,
|
||||
noteHash: state.selectedNoteHash,
|
||||
newNoteAttachFileAction: state.newNoteAttachFileAction,
|
||||
itemType: state.selectedItemType,
|
||||
folders: state.folders,
|
||||
searchQuery: state.searchQuery,
|
||||
|
||||
@@ -354,10 +354,6 @@ const appReducer = (state = appDefaultState, action: any) => {
|
||||
newState.selectedNoteHash = action.noteHash;
|
||||
}
|
||||
|
||||
if ('newNoteAttachFileAction' in action) {
|
||||
newState.newNoteAttachFileAction = action.newNoteAttachFileAction;
|
||||
}
|
||||
|
||||
if ('sharedData' in action) {
|
||||
newState.sharedData = action.sharedData;
|
||||
} else {
|
||||
|
||||
@@ -16,7 +16,6 @@ const appDefaultState: AppState = {
|
||||
isOnMobileData: false,
|
||||
disableSideMenuGestures: false,
|
||||
showPanelsDialog: false,
|
||||
newNoteAttachFileAction: null,
|
||||
...defaultState,
|
||||
|
||||
// On mobile, it's possible to select notes that aren't in the selected folder/tag/etc.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { State } from '@joplin/lib/reducer';
|
||||
import { AttachFileAction } from '../components/screens/Note/commands/attachFile';
|
||||
|
||||
export interface AppState extends State {
|
||||
showPanelsDialog: boolean;
|
||||
@@ -11,6 +10,4 @@ export interface AppState extends State {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
||||
noteSideMenuOptions: any;
|
||||
disableSideMenuGestures: boolean;
|
||||
|
||||
newNoteAttachFileAction: AttachFileAction | null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user