mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-18 09:35:20 +02:00
This commit is contained in:
parent
50b16c6054
commit
bb66e81abe
@ -37,7 +37,8 @@ const PADDING_V = 10;
|
|||||||
type OnPressCallback=()=> void;
|
type OnPressCallback=()=> void;
|
||||||
|
|
||||||
export interface FolderPickerOptions {
|
export interface FolderPickerOptions {
|
||||||
enabled: boolean;
|
visible: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
selectedFolderId?: string;
|
selectedFolderId?: string;
|
||||||
onValueChange?: OnValueChangedListener;
|
onValueChange?: OnValueChangedListener;
|
||||||
mustSelect?: boolean;
|
mustSelect?: boolean;
|
||||||
@ -517,10 +518,12 @@ class ScreenHeaderComponent extends PureComponent<ScreenHeaderProps, ScreenHeade
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const createTitleComponent = (disabled: boolean, hideableAfterTitleComponents: ReactElement) => {
|
const createTitleComponent = (hideableAfterTitleComponents: ReactElement) => {
|
||||||
const folderPickerOptions = this.props.folderPickerOptions;
|
const folderPickerOptions = this.props.folderPickerOptions;
|
||||||
|
|
||||||
if (folderPickerOptions && folderPickerOptions.enabled) {
|
if (folderPickerOptions && folderPickerOptions.visible) {
|
||||||
|
const hasSelectedNotes = this.props.selectedNoteIds.length > 0;
|
||||||
|
const disabled = this.props.folderPickerOptions.disabled ?? !hasSelectedNotes;
|
||||||
return (
|
return (
|
||||||
<FolderPicker
|
<FolderPicker
|
||||||
themeId={themeId}
|
themeId={themeId}
|
||||||
@ -599,7 +602,7 @@ class ScreenHeaderComponent extends PureComponent<ScreenHeaderProps, ScreenHeade
|
|||||||
{betaIconComp}
|
{betaIconComp}
|
||||||
</>;
|
</>;
|
||||||
|
|
||||||
const titleComp = createTitleComponent(headerItemDisabled, hideableRightComponents);
|
const titleComp = createTitleComponent(hideableRightComponents);
|
||||||
|
|
||||||
const contextMenuStyle: ViewStyle = {
|
const contextMenuStyle: ViewStyle = {
|
||||||
paddingTop: PADDING_V,
|
paddingTop: PADDING_V,
|
||||||
|
@ -50,7 +50,7 @@ import { isSupportedLanguage } from '../../services/voiceTyping/vosk';
|
|||||||
import { ChangeEvent as EditorChangeEvent, SelectionRangeChangeEvent, UndoRedoDepthChangeEvent } from '@joplin/editor/events';
|
import { ChangeEvent as EditorChangeEvent, SelectionRangeChangeEvent, UndoRedoDepthChangeEvent } from '@joplin/editor/events';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { Dispatch } from 'redux';
|
import { Dispatch } from 'redux';
|
||||||
import { RefObject } from 'react';
|
import { RefObject, useRef } from 'react';
|
||||||
import { SelectionRange } from '../NoteEditor/types';
|
import { SelectionRange } from '../NoteEditor/types';
|
||||||
import { getNoteCallbackUrl } from '@joplin/lib/callbackUrlUtils';
|
import { getNoteCallbackUrl } from '@joplin/lib/callbackUrlUtils';
|
||||||
import { AppState } from '../../utils/types';
|
import { AppState } from '../../utils/types';
|
||||||
@ -1372,7 +1372,8 @@ class NoteScreenComponent extends BaseScreenComponent<Props, State> implements B
|
|||||||
|
|
||||||
public folderPickerOptions() {
|
public folderPickerOptions() {
|
||||||
const options = {
|
const options = {
|
||||||
enabled: !this.state.readOnly,
|
visible: !this.state.readOnly,
|
||||||
|
disabled: false,
|
||||||
selectedFolderId: this.state.folder ? this.state.folder.id : null,
|
selectedFolderId: this.state.folder ? this.state.folder.id : null,
|
||||||
onValueChange: this.folderPickerOptions_valueChanged,
|
onValueChange: this.folderPickerOptions_valueChanged,
|
||||||
};
|
};
|
||||||
@ -1380,7 +1381,7 @@ class NoteScreenComponent extends BaseScreenComponent<Props, State> implements B
|
|||||||
if (
|
if (
|
||||||
this.folderPickerOptions_
|
this.folderPickerOptions_
|
||||||
&& options.selectedFolderId === this.folderPickerOptions_.selectedFolderId
|
&& options.selectedFolderId === this.folderPickerOptions_.selectedFolderId
|
||||||
&& options.enabled === this.folderPickerOptions_.enabled
|
&& options.visible === this.folderPickerOptions_.visible
|
||||||
) {
|
) {
|
||||||
return this.folderPickerOptions_;
|
return this.folderPickerOptions_;
|
||||||
}
|
}
|
||||||
@ -1639,8 +1640,18 @@ class NoteScreenComponent extends BaseScreenComponent<Props, State> implements B
|
|||||||
// which can cause some bugs where previously set state to another note would interfere
|
// which can cause some bugs where previously set state to another note would interfere
|
||||||
// how the new note should be rendered
|
// how the new note should be rendered
|
||||||
const NoteScreenWrapper = (props: Props) => {
|
const NoteScreenWrapper = (props: Props) => {
|
||||||
|
const lastNonNullNoteIdRef = useRef(props.noteId);
|
||||||
|
if (props.noteId) {
|
||||||
|
lastNonNullNoteIdRef.current = props.noteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This keeps the current note open even if it's no longer present in selectedNoteIds.
|
||||||
|
// This might happen, for example, if the selected note is moved to an unselected
|
||||||
|
// folder.
|
||||||
|
const noteId = lastNonNullNoteIdRef.current;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NoteScreenComponent key={props.noteId} {...props} />
|
<NoteScreenComponent key={noteId} {...props} noteId={noteId} />
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -222,11 +222,11 @@ class NotesScreenComponent extends BaseScreenComponent<Props, State> {
|
|||||||
|
|
||||||
public folderPickerOptions() {
|
public folderPickerOptions() {
|
||||||
const options = {
|
const options = {
|
||||||
enabled: this.props.noteSelectionEnabled,
|
visible: this.props.noteSelectionEnabled,
|
||||||
mustSelect: true,
|
mustSelect: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.folderPickerOptions_ && options.enabled === this.folderPickerOptions_.enabled) return this.folderPickerOptions_;
|
if (this.folderPickerOptions_ && options.visible === this.folderPickerOptions_.visible) return this.folderPickerOptions_;
|
||||||
|
|
||||||
this.folderPickerOptions_ = options;
|
this.folderPickerOptions_ = options;
|
||||||
return this.folderPickerOptions_;
|
return this.folderPickerOptions_;
|
||||||
|
@ -85,7 +85,7 @@ const SearchScreenComponent: React.FC<Props> = props => {
|
|||||||
<ScreenHeader
|
<ScreenHeader
|
||||||
title={_('Search')}
|
title={_('Search')}
|
||||||
folderPickerOptions={{
|
folderPickerOptions={{
|
||||||
enabled: props.noteSelectionEnabled,
|
visible: props.noteSelectionEnabled,
|
||||||
mustSelect: true,
|
mustSelect: true,
|
||||||
}}
|
}}
|
||||||
showSideMenuButton={false}
|
showSideMenuButton={false}
|
||||||
|
Loading…
Reference in New Issue
Block a user