mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Mobile: Fixed issue that could slow down app when displaying large list of notes
This commit is contained in:
parent
0255546ae1
commit
bdb31f2890
@ -100,15 +100,15 @@ class NotesScreenComponent extends BaseScreenComponent {
|
||||
AppState.removeEventListener('change', this.onAppStateChange_);
|
||||
}
|
||||
|
||||
async UNSAFE_componentWillReceiveProps(newProps) {
|
||||
if (newProps.notesOrder !== this.props.notesOrder ||
|
||||
newProps.selectedFolderId != this.props.selectedFolderId ||
|
||||
newProps.selectedTagId != this.props.selectedTagId ||
|
||||
newProps.selectedSmartFilterId != this.props.selectedSmartFilterId ||
|
||||
newProps.notesParentType != this.props.notesParentType) {
|
||||
await this.refreshNotes(newProps);
|
||||
async componentDidUpdate(prevProps) {
|
||||
if (prevProps.notesOrder !== this.props.notesOrder ||
|
||||
prevProps.selectedFolderId != this.props.selectedFolderId ||
|
||||
prevProps.selectedTagId != this.props.selectedTagId ||
|
||||
prevProps.selectedSmartFilterId != this.props.selectedSmartFilterId ||
|
||||
prevProps.notesParentType != this.props.notesParentType) {
|
||||
await this.refreshNotes(this.props);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async refreshNotes(props = null) {
|
||||
if (props === null) props = this.props;
|
||||
@ -144,6 +144,8 @@ class NotesScreenComponent extends BaseScreenComponent {
|
||||
notes: notes,
|
||||
notesSource: source,
|
||||
});
|
||||
|
||||
console.info('Done', Date.now() - startTime);
|
||||
}
|
||||
|
||||
deleteFolder_onPress(folderId) {
|
||||
|
@ -53,18 +53,30 @@ const defaultState = {
|
||||
|
||||
const stateUtils = {};
|
||||
|
||||
const derivedStateCache_ = {};
|
||||
|
||||
// Allows, for a given state, to return the same derived
|
||||
// objects, to prevent unecessary updates on calling components.
|
||||
const cacheEnabledOutput = (key, output) => {
|
||||
key = key + '_' + JSON.stringify(output);
|
||||
if (derivedStateCache_[key]) return derivedStateCache_[key];
|
||||
|
||||
derivedStateCache_[key] = output;
|
||||
return derivedStateCache_[key];
|
||||
}
|
||||
|
||||
stateUtils.notesOrder = function(stateSettings) {
|
||||
return [{
|
||||
return cacheEnabledOutput('notesOrder', [{
|
||||
by: stateSettings['notes.sortOrder.field'],
|
||||
dir: stateSettings['notes.sortOrder.reverse'] ? 'DESC' : 'ASC',
|
||||
}];
|
||||
}]);
|
||||
}
|
||||
|
||||
stateUtils.foldersOrder = function(stateSettings) {
|
||||
return [{
|
||||
return cacheEnabledOutput('foldersOrder', [{
|
||||
by: stateSettings['folders.sortOrder.field'],
|
||||
dir: stateSettings['folders.sortOrder.reverse'] ? 'DESC' : 'ASC',
|
||||
}];
|
||||
}]);
|
||||
}
|
||||
|
||||
stateUtils.parentItem = function(state) {
|
||||
|
Loading…
Reference in New Issue
Block a user