1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Tools: Implement "prefer-object-spread" eslint rule

This commit is contained in:
Laurent Cozic
2023-06-01 12:02:36 +01:00
parent 804d674d37
commit c89edd7b22
126 changed files with 588 additions and 909 deletions

View File

@ -143,6 +143,7 @@ module.exports = {
'spaced-comment': ['error', 'always'], 'spaced-comment': ['error', 'always'],
'keyword-spacing': ['error', { 'before': true, 'after': true }], 'keyword-spacing': ['error', { 'before': true, 'after': true }],
'no-multi-spaces': ['error'], 'no-multi-spaces': ['error'],
'prefer-object-spread': ['error'],
// Regarding the keyword blacklist: // Regarding the keyword blacklist:
// - err: We generally avoid using too many abbreviations, so it should // - err: We generally avoid using too many abbreviations, so it should

View File

@ -42,7 +42,7 @@ export function addJoplinChecklistCommands(editor, ToggleList) {
}); });
editor.addCommand('InsertJoplinChecklist', function (ui, detail) { editor.addCommand('InsertJoplinChecklist', function (ui, detail) {
detail = Object.assign({}, detail, { listType: 'joplinChecklist' }); detail = { ...detail, listType: 'joplinChecklist' };
ToggleList.toggleList(editor, 'UL', detail); ToggleList.toggleList(editor, 'UL', detail);
}); });
} }

View File

@ -302,7 +302,7 @@ class AppGui {
const output = []; const output = [];
for (let i = 0; i < keymap.length; i++) { for (let i = 0; i < keymap.length; i++) {
const item = Object.assign({}, keymap[i]); const item = { ...keymap[i] };
if (!item.command) throw new Error(`Missing command for keymap item: ${JSON.stringify(item)}`); if (!item.command) throw new Error(`Missing command for keymap item: ${JSON.stringify(item)}`);
@ -427,7 +427,7 @@ class AppGui {
async handleModelAction(action) { async handleModelAction(action) {
this.logger().info('Action:', action); this.logger().info('Action:', action);
const state = Object.assign({}, defaultState); const state = { ...defaultState };
state.notes = this.widget('noteList').items; state.notes = this.widget('noteList').items;
const newState = reducer(state, action); const newState = reducer(state, action);

View File

@ -192,7 +192,7 @@ class Application extends BaseApplication {
let output = await this.cache_.getItem('metadata'); let output = await this.cache_.getItem('metadata');
if (output) { if (output) {
this.commandMetadata_ = output; this.commandMetadata_ = output;
return Object.assign({}, this.commandMetadata_); return { ...this.commandMetadata_ };
} }
const commands = this.commands(); const commands = this.commands();
@ -207,7 +207,7 @@ class Application extends BaseApplication {
await this.cache_.setItem('metadata', output, 1000 * 60 * 60 * 24); await this.cache_.setItem('metadata', output, 1000 * 60 * 60 * 24);
this.commandMetadata_ = output; this.commandMetadata_ = output;
return Object.assign({}, this.commandMetadata_); return { ...this.commandMetadata_ };
} }
hasGui() { hasGui() {

View File

@ -94,12 +94,12 @@ browser_.runtime.onMessage.addListener(async (command) => {
const imageSize = await getImageSize(imageDataUrl); const imageSize = await getImageSize(imageDataUrl);
const imagePixelRatio = imageSize.width / command.content.windowInnerWidth; const imagePixelRatio = imageSize.width / command.content.windowInnerWidth;
const content = Object.assign({}, command.content); const content = { ...command.content };
content.image_data_url = imageDataUrl; content.image_data_url = imageDataUrl;
if ('url' in content) content.source_url = content.url; if ('url' in content) content.source_url = content.url;
const ratio = browserZoom * imagePixelRatio; const ratio = browserZoom * imagePixelRatio;
const newArea = Object.assign({}, command.content.crop_rect); const newArea = { ...command.content.crop_rect };
newArea.x *= ratio; newArea.x *= ratio;
newArea.y *= ratio; newArea.y *= ratio;
newArea.width *= ratio; newArea.width *= ratio;

View File

@ -378,7 +378,7 @@
tags: command.tags || '', tags: command.tags || '',
image_sizes: imageSizes, image_sizes: imageSizes,
anchor_names: anchorNames, anchor_names: anchorNames,
source_command: Object.assign({}, command), source_command: { ...command },
convert_to: convertToMarkup, convert_to: convertToMarkup,
stylesheets: stylesheets, stylesheets: stylesheets,
}; };
@ -392,7 +392,7 @@
} catch (error) { } catch (error) {
console.warn(error); console.warn(error);
console.warn('Sending full page HTML instead'); console.warn('Sending full page HTML instead');
const newCommand = Object.assign({}, command, { name: 'completePageHtml' }); const newCommand = { ...command, name: 'completePageHtml' };
const response = await prepareCommandResponse(newCommand); const response = await prepareCommandResponse(newCommand);
response.warning = 'Could not retrieve simplified version of page - full page has been saved instead.'; response.warning = 'Could not retrieve simplified version of page - full page has been saved instead.';
return response; return response;

View File

@ -67,7 +67,7 @@ class AppComponent extends Component {
}); });
this.confirm_click = async () => { this.confirm_click = async () => {
const content = Object.assign({}, this.props.clippedContent); const content = { ...this.props.clippedContent };
content.tags = this.state.selectedTags.join(','); content.tags = this.state.selectedTags.join(',');
content.parent_id = this.props.selectedFolderId; content.parent_id = this.props.selectedFolderId;
const response = await bridge().sendContentToJoplin(content); const response = await bridge().sendContentToJoplin(content);

View File

@ -410,7 +410,7 @@ class Bridge {
if (body) fetchOptions.body = typeof body === 'string' ? body : JSON.stringify(body); if (body) fetchOptions.body = typeof body === 'string' ? body : JSON.stringify(body);
query = Object.assign(query || {}, { token: this.token_ }); query = { ...query, token: this.token_ };
let queryString = ''; let queryString = '';
if (query) { if (query) {

View File

@ -40,34 +40,34 @@ function reducer(state = defaultState, action) {
if (action.type === 'WARNING_SET') { if (action.type === 'WARNING_SET') {
newState = Object.assign({}, state); newState = { ...state };
newState.warning = action.text; newState.warning = action.text;
} else if (action.type === 'IS_PROBABLY_READERABLE') { } else if (action.type === 'IS_PROBABLY_READERABLE') {
newState = Object.assign({}, state); newState = { ...state };
newState.isProbablyReaderable = action.value; newState.isProbablyReaderable = action.value;
} else if (action.type === 'CLIPPED_CONTENT_SET') { } else if (action.type === 'CLIPPED_CONTENT_SET') {
newState = Object.assign({}, state); newState = { ...state };
newState.clippedContent = action.content; newState.clippedContent = action.content;
} else if (action.type === 'CLIPPED_CONTENT_TITLE_SET') { } else if (action.type === 'CLIPPED_CONTENT_TITLE_SET') {
newState = Object.assign({}, state); newState = { ...state };
const newContent = newState.clippedContent ? Object.assign({}, newState.clippedContent) : {}; const newContent = newState.clippedContent ? { ...newState.clippedContent } : {};
newContent.title = action.text; newContent.title = action.text;
newState.clippedContent = newContent; newState.clippedContent = newContent;
} else if (action.type === 'CONTENT_UPLOAD') { } else if (action.type === 'CONTENT_UPLOAD') {
newState = Object.assign({}, state); newState = { ...state };
newState.contentUploadOperation = action.operation; newState.contentUploadOperation = action.operation;
} else if (action.type === 'FOLDERS_SET') { } else if (action.type === 'FOLDERS_SET') {
newState = Object.assign({}, state); newState = { ...state };
newState.folders = action.folders; newState.folders = action.folders;
if (!newState.selectedFolderId && action.folders.length) { if (!newState.selectedFolderId && action.folders.length) {
@ -76,30 +76,30 @@ function reducer(state = defaultState, action) {
} else if (action.type === 'TAGS_SET') { } else if (action.type === 'TAGS_SET') {
newState = Object.assign({}, state); newState = { ...state };
newState.tags = action.tags; newState.tags = action.tags;
} else if (action.type === 'SELECTED_FOLDER_SET') { } else if (action.type === 'SELECTED_FOLDER_SET') {
newState = Object.assign({}, state); newState = { ...state };
newState.selectedFolderId = action.id; newState.selectedFolderId = action.id;
} else if (action.type === 'CLIPPER_SERVER_SET') { } else if (action.type === 'CLIPPER_SERVER_SET') {
newState = Object.assign({}, state); newState = { ...state };
const clipperServer = Object.assign({}, newState.clipperServer); const clipperServer = { ...newState.clipperServer };
if ('foundState' in action) clipperServer.foundState = action.foundState; if ('foundState' in action) clipperServer.foundState = action.foundState;
if ('port' in action) clipperServer.port = action.port; if ('port' in action) clipperServer.port = action.port;
newState.clipperServer = clipperServer; newState.clipperServer = clipperServer;
} else if (action.type === 'ENV_SET') { } else if (action.type === 'ENV_SET') {
newState = Object.assign({}, state); newState = { ...state };
newState.env = action.env; newState.env = action.env;
} else if (action.type === 'AUTH_STATE_SET') { } else if (action.type === 'AUTH_STATE_SET') {
newState = Object.assign({}, state); newState = { ...state };
newState.authStatus = action.value; newState.authStatus = action.value;
} }

View File

@ -29,13 +29,11 @@ export default class InteropServiceHelper {
private static async exportNoteToHtmlFile(noteId: string, exportOptions: ExportNoteOptions) { private static async exportNoteToHtmlFile(noteId: string, exportOptions: ExportNoteOptions) {
const tempFile = `${Setting.value('tempDir')}/${md5(Date.now() + Math.random())}.html`; const tempFile = `${Setting.value('tempDir')}/${md5(Date.now() + Math.random())}.html`;
const fullExportOptions: ExportOptions = Object.assign({}, { const fullExportOptions: ExportOptions = { path: tempFile,
path: tempFile,
format: 'html', format: 'html',
target: FileSystemItem.File, target: FileSystemItem.File,
sourceNoteIds: [noteId], sourceNoteIds: [noteId],
customCss: '', customCss: '', ...exportOptions };
}, exportOptions);
const service = InteropService.instance(); const service = InteropService.instance();

View File

@ -82,7 +82,7 @@ export default function(state: AppState, action: any) {
const currentRoute = state.route; const currentRoute = state.route;
newState = Object.assign({}, state); newState = { ...state };
const newNavHistory = state.navHistory.slice(); const newNavHistory = state.navHistory.slice();
if (goingBack) { if (goingBack) {
@ -119,7 +119,7 @@ export default function(state: AppState, action: any) {
case 'WINDOW_CONTENT_SIZE_SET': case 'WINDOW_CONTENT_SIZE_SET':
newState = Object.assign({}, state); newState = { ...state };
newState.windowContentSize = action.size; newState.windowContentSize = action.size;
break; break;
@ -147,7 +147,7 @@ export default function(state: AppState, action: any) {
return nextLayout === 'both' ? ['editor', 'viewer'] : [nextLayout]; return nextLayout === 'both' ? ['editor', 'viewer'] : [nextLayout];
}; };
newState = Object.assign({}, state); newState = { ...state };
const panes = state.noteVisiblePanes.slice(); const panes = state.noteVisiblePanes.slice();
newState.noteVisiblePanes = getNextLayout(panes); newState.noteVisiblePanes = getNextLayout(panes);
@ -156,7 +156,7 @@ export default function(state: AppState, action: any) {
case 'NOTE_VISIBLE_PANES_SET': case 'NOTE_VISIBLE_PANES_SET':
newState = Object.assign({}, state); newState = { ...state };
newState.noteVisiblePanes = action.panes; newState.noteVisiblePanes = action.panes;
break; break;
@ -194,7 +194,7 @@ export default function(state: AppState, action: any) {
case 'NOTE_FILE_WATCHER_ADD': case 'NOTE_FILE_WATCHER_ADD':
if (newState.watchedNoteFiles.indexOf(action.id) < 0) { if (newState.watchedNoteFiles.indexOf(action.id) < 0) {
newState = Object.assign({}, state); newState = { ...state };
const watchedNoteFiles = newState.watchedNoteFiles.slice(); const watchedNoteFiles = newState.watchedNoteFiles.slice();
watchedNoteFiles.push(action.id); watchedNoteFiles.push(action.id);
newState.watchedNoteFiles = watchedNoteFiles; newState.watchedNoteFiles = watchedNoteFiles;
@ -204,7 +204,7 @@ export default function(state: AppState, action: any) {
case 'NOTE_FILE_WATCHER_REMOVE': case 'NOTE_FILE_WATCHER_REMOVE':
{ {
newState = Object.assign({}, state); newState = { ...state };
const idx = newState.watchedNoteFiles.indexOf(action.id); const idx = newState.watchedNoteFiles.indexOf(action.id);
if (idx >= 0) { if (idx >= 0) {
const watchedNoteFiles = newState.watchedNoteFiles.slice(); const watchedNoteFiles = newState.watchedNoteFiles.slice();
@ -217,7 +217,7 @@ export default function(state: AppState, action: any) {
case 'NOTE_FILE_WATCHER_CLEAR': case 'NOTE_FILE_WATCHER_CLEAR':
if (state.watchedNoteFiles.length) { if (state.watchedNoteFiles.length) {
newState = Object.assign({}, state); newState = { ...state };
newState.watchedNoteFiles = []; newState.watchedNoteFiles = [];
} }
break; break;
@ -225,38 +225,38 @@ export default function(state: AppState, action: any) {
case 'EDITOR_SCROLL_PERCENT_SET': case 'EDITOR_SCROLL_PERCENT_SET':
{ {
newState = Object.assign({}, state); newState = { ...state };
const newPercents = Object.assign({}, newState.lastEditorScrollPercents); const newPercents = { ...newState.lastEditorScrollPercents };
newPercents[action.noteId] = action.percent; newPercents[action.noteId] = action.percent;
newState.lastEditorScrollPercents = newPercents; newState.lastEditorScrollPercents = newPercents;
} }
break; break;
case 'NOTE_DEVTOOLS_TOGGLE': case 'NOTE_DEVTOOLS_TOGGLE':
newState = Object.assign({}, state); newState = { ...state };
newState.devToolsVisible = !newState.devToolsVisible; newState.devToolsVisible = !newState.devToolsVisible;
break; break;
case 'NOTE_DEVTOOLS_SET': case 'NOTE_DEVTOOLS_SET':
newState = Object.assign({}, state); newState = { ...state };
newState.devToolsVisible = action.value; newState.devToolsVisible = action.value;
break; break;
case 'VISIBLE_DIALOGS_ADD': case 'VISIBLE_DIALOGS_ADD':
newState = Object.assign({}, state); newState = { ...state };
newState.visibleDialogs = Object.assign({}, newState.visibleDialogs); newState.visibleDialogs = { ...newState.visibleDialogs };
newState.visibleDialogs[action.name] = true; newState.visibleDialogs[action.name] = true;
break; break;
case 'VISIBLE_DIALOGS_REMOVE': case 'VISIBLE_DIALOGS_REMOVE':
newState = Object.assign({}, state); newState = { ...state };
newState.visibleDialogs = Object.assign({}, newState.visibleDialogs); newState.visibleDialogs = { ...newState.visibleDialogs };
delete newState.visibleDialogs[action.name]; delete newState.visibleDialogs[action.name];
break; break;
case 'FOCUS_SET': case 'FOCUS_SET':
newState = Object.assign({}, state); newState = { ...state };
newState.focusedField = action.field; newState.focusedField = action.field;
break; break;
@ -264,7 +264,7 @@ export default function(state: AppState, action: any) {
// A field can only clear its own state // A field can only clear its own state
if (action.field === state.focusedField) { if (action.field === state.focusedField) {
newState = Object.assign({}, state); newState = { ...state };
newState.focusedField = null; newState.focusedField = null;
} }
break; break;
@ -281,7 +281,7 @@ export default function(state: AppState, action: any) {
isOpen = action.isOpen !== false; isOpen = action.isOpen !== false;
} }
newState = Object.assign({}, state); newState = { ...state };
if (isOpen) { if (isOpen) {
const newDialogs = newState.dialogs.slice(); const newDialogs = newState.dialogs.slice();

View File

@ -201,12 +201,10 @@ export class Bridge {
...options, ...options,
}; };
const result = this.showMessageBox_(this.window(), Object.assign({}, { const result = this.showMessageBox_(this.window(), { type: 'question',
type: 'question',
message: message, message: message,
cancelId: 1, cancelId: 1,
buttons: options.buttons, buttons: options.buttons, ...options });
}, options));
return result === 0; return result === 0;
} }
@ -215,21 +213,17 @@ export class Bridge {
public showMessageBox(message: string, options: any = null) { public showMessageBox(message: string, options: any = null) {
if (options === null) options = {}; if (options === null) options = {};
const result = this.showMessageBox_(this.window(), Object.assign({}, { const result = this.showMessageBox_(this.window(), { type: 'question',
type: 'question',
message: message, message: message,
buttons: [_('OK'), _('Cancel')], buttons: [_('OK'), _('Cancel')], ...options });
}, options));
return result; return result;
} }
public showInfoMessageBox(message: string, options: any = {}) { public showInfoMessageBox(message: string, options: any = {}) {
const result = this.showMessageBox_(this.window(), Object.assign({}, { const result = this.showMessageBox_(this.window(), { type: 'info',
type: 'info',
message: message, message: message,
buttons: [_('OK')], buttons: [_('OK')], ...options });
}, options));
return result === 0; return result === 0;
} }

View File

@ -34,7 +34,7 @@ function getMajorMinorTagName(tagName: string) {
} }
async function fetchLatestRelease(options: CheckForUpdateOptions) { async function fetchLatestRelease(options: CheckForUpdateOptions) {
options = Object.assign({}, { includePreReleases: false }, options); options = { includePreReleases: false, ...options };
const response = await shim.fetch('https://api.github.com/repos/laurent22/joplin/releases'); const response = await shim.fetch('https://api.github.com/repos/laurent22/joplin/releases');

View File

@ -46,13 +46,11 @@ class ClipperConfigScreenComponent extends React.Component {
public render() { public render() {
const theme = themeStyle(this.props.themeId); const theme = themeStyle(this.props.themeId);
const containerStyle = Object.assign({}, theme.containerStyle, { const containerStyle = { ...theme.containerStyle, overflowY: 'scroll',
overflowY: 'scroll',
// padding: theme.configScreenPadding, // padding: theme.configScreenPadding,
backgroundColor: theme.backgroundColor3, backgroundColor: theme.backgroundColor3 };
});
const buttonStyle = Object.assign({}, theme.buttonStyle, { marginRight: 10 }); const buttonStyle = { ...theme.buttonStyle, marginRight: 10 };
const stepBoxStyle = { const stepBoxStyle = {
border: '1px solid', border: '1px solid',
@ -106,18 +104,16 @@ class ClipperConfigScreenComponent extends React.Component {
); );
} }
const apiTokenStyle = Object.assign({}, theme.textStyle, { const apiTokenStyle = { ...theme.textStyle, color: theme.colorFaded,
color: theme.colorFaded,
wordBreak: 'break-all', wordBreak: 'break-all',
paddingTop: 10, paddingTop: 10,
paddingBottom: 10, paddingBottom: 10 };
});
return ( return (
<div> <div>
<div style={containerStyle}> <div style={containerStyle}>
<div> <div>
<p style={Object.assign({}, theme.textStyle, { marginTop: 0 })}>{_('Joplin Web Clipper allows saving web pages and screenshots from your browser to Joplin.')}</p> <p style={{ ...theme.textStyle, marginTop: 0 }}>{_('Joplin Web Clipper allows saving web pages and screenshots from your browser to Joplin.')}</p>
<p style={theme.textStyle}>{_('In order to use the web clipper, you need to do the following:')}</p> <p style={theme.textStyle}>{_('In order to use the web clipper, you need to do the following:')}</p>
<div style={stepBoxStyle}> <div style={stepBoxStyle}>

View File

@ -135,7 +135,7 @@ class ConfigScreenComponent extends React.Component<any, any> {
const theme = themeStyle(this.props.themeId); const theme = themeStyle(this.props.themeId);
return ( return (
<div style={Object.assign({}, theme.textStyle, { marginBottom: 15 })}> <div style={{ ...theme.textStyle, marginBottom: 15 }}>
{description} {description}
</div> </div>
); );
@ -177,7 +177,7 @@ class ConfigScreenComponent extends React.Component<any, any> {
if (section.name === 'sync') { if (section.name === 'sync') {
const syncTargetMd = SyncTargetRegistry.idToMetadata(settings['sync.target']); const syncTargetMd = SyncTargetRegistry.idToMetadata(settings['sync.target']);
const statusStyle = Object.assign({}, theme.textStyle, { marginTop: 10 }); const statusStyle = { ...theme.textStyle, marginTop: 10 };
if (syncTargetMd.supportsConfigCheck) { if (syncTargetMd.supportsConfigCheck) {
const messages = shared.checkSyncConfigMessages(this); const messages = shared.checkSyncConfigMessages(this);
@ -207,7 +207,7 @@ class ConfigScreenComponent extends React.Component<any, any> {
if (advancedSettingComps.length) { if (advancedSettingComps.length) {
const iconName = this.state.showAdvancedSettings ? 'fa fa-angle-down' : 'fa fa-angle-right'; const iconName = this.state.showAdvancedSettings ? 'fa fa-angle-down' : 'fa fa-angle-right';
// const advancedSettingsButtonStyle = Object.assign({}, theme.buttonStyle, { marginBottom: 10 }); // const advancedSettingsButtonStyle = { ...theme.buttonStyle, marginBottom: 10 };
advancedSettingsButton = ( advancedSettingsButton = (
<div style={{ marginBottom: 10 }}> <div style={{ marginBottom: 10 }}>
<Button <Button
@ -233,23 +233,19 @@ class ConfigScreenComponent extends React.Component<any, any> {
private labelStyle(themeId: number) { private labelStyle(themeId: number) {
const theme = themeStyle(themeId); const theme = themeStyle(themeId);
return Object.assign({}, theme.textStyle, { return { ...theme.textStyle, display: 'block',
display: 'block',
color: theme.color, color: theme.color,
fontSize: theme.fontSize * 1.083333, fontSize: theme.fontSize * 1.083333,
fontWeight: 500, fontWeight: 500,
marginBottom: theme.mainPadding / 2, marginBottom: theme.mainPadding / 2 };
});
} }
private descriptionStyle(themeId: number) { private descriptionStyle(themeId: number) {
const theme = themeStyle(themeId); const theme = themeStyle(themeId);
return Object.assign({}, theme.textStyle, { return { ...theme.textStyle, color: theme.colorFaded,
color: theme.colorFaded,
fontStyle: 'italic', fontStyle: 'italic',
maxWidth: '70em', maxWidth: '70em',
marginTop: 5, marginTop: 5 };
});
} }
private renderLabel(themeId: number, label: string) { private renderLabel(themeId: number, label: string) {
@ -264,14 +260,12 @@ class ConfigScreenComponent extends React.Component<any, any> {
private renderHeader(themeId: number, label: string, style: any = null) { private renderHeader(themeId: number, label: string, style: any = null) {
const theme = themeStyle(themeId); const theme = themeStyle(themeId);
const labelStyle = Object.assign({}, theme.textStyle, { const labelStyle = { ...theme.textStyle, display: 'block',
display: 'block',
color: theme.color, color: theme.color,
fontSize: theme.fontSize * 1.25, fontSize: theme.fontSize * 1.25,
fontWeight: 500, fontWeight: 500,
marginBottom: theme.mainPadding, marginBottom: theme.mainPadding,
...style, ...style };
});
return ( return (
<div style={labelStyle}> <div style={labelStyle}>
@ -295,17 +289,13 @@ class ConfigScreenComponent extends React.Component<any, any> {
const labelStyle = this.labelStyle(this.props.themeId); const labelStyle = this.labelStyle(this.props.themeId);
const subLabel = Object.assign({}, labelStyle, { const subLabel = { ...labelStyle, display: 'block',
display: 'block',
opacity: 0.7, opacity: 0.7,
marginBottom: labelStyle.marginBottom, marginBottom: labelStyle.marginBottom };
});
const checkboxLabelStyle = Object.assign({}, labelStyle, { const checkboxLabelStyle = { ...labelStyle, marginLeft: 8,
marginLeft: 8,
display: 'inline', display: 'inline',
backgroundColor: 'transparent', backgroundColor: 'transparent' };
});
const controlStyle = { const controlStyle = {
display: 'inline-block', display: 'inline-block',
@ -314,8 +304,7 @@ class ConfigScreenComponent extends React.Component<any, any> {
backgroundColor: theme.backgroundColor, backgroundColor: theme.backgroundColor,
}; };
const textInputBaseStyle = Object.assign({}, controlStyle, { const textInputBaseStyle = { ...controlStyle, fontFamily: theme.fontFamily,
fontFamily: theme.fontFamily,
border: '1px solid', border: '1px solid',
padding: '4px 6px', padding: '4px 6px',
boxSizing: 'border-box', boxSizing: 'border-box',
@ -324,8 +313,7 @@ class ConfigScreenComponent extends React.Component<any, any> {
paddingLeft: 6, paddingLeft: 6,
paddingRight: 6, paddingRight: 6,
paddingTop: 4, paddingTop: 4,
paddingBottom: 4, paddingBottom: 4 };
});
const updateSettingValue = (key: string, value: any) => { const updateSettingValue = (key: string, value: any) => {
const md = Setting.settingMetadata(key); const md = Setting.settingMetadata(key);
@ -381,14 +369,12 @@ class ConfigScreenComponent extends React.Component<any, any> {
); );
} }
const selectStyle = Object.assign({}, controlStyle, { const selectStyle = { ...controlStyle, paddingLeft: 6,
paddingLeft: 6,
paddingRight: 6, paddingRight: 6,
paddingTop: 4, paddingTop: 4,
paddingBottom: 4, paddingBottom: 4,
borderColor: theme.borderColor4, borderColor: theme.borderColor4,
borderRadius: 3, borderRadius: 3 };
});
return ( return (
<div key={key} style={rowStyle}> <div key={key} style={rowStyle}>
@ -443,10 +429,8 @@ class ConfigScreenComponent extends React.Component<any, any> {
</div> </div>
); );
} else if (md.type === Setting.TYPE_STRING) { } else if (md.type === Setting.TYPE_STRING) {
const inputStyle: any = Object.assign({}, textInputBaseStyle, { const inputStyle: any = { ...textInputBaseStyle, width: '50%',
width: '50%', minWidth: '20em' };
minWidth: '20em',
});
const inputType = md.secure === true ? 'password' : 'text'; const inputType = md.secure === true ? 'password' : 'text';
if (md.subType === 'file_path_and_args' || md.subType === 'file_path' || md.subType === 'directory_path') { if (md.subType === 'file_path_and_args' || md.subType === 'file_path' || md.subType === 'directory_path') {
@ -542,7 +526,7 @@ class ConfigScreenComponent extends React.Component<any, any> {
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', marginBottom: inputStyle.marginBottom }}> <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', marginBottom: inputStyle.marginBottom }}>
<input <input
type={inputType} type={inputType}
style={Object.assign({}, inputStyle, { marginBottom: 0, marginRight: 5 })} style={{ ...inputStyle, marginBottom: 0, marginRight: 5 }}
onChange={(event: any) => { onChange={(event: any) => {
onPathChange(event); onPathChange(event);
}} }}
@ -595,7 +579,7 @@ class ConfigScreenComponent extends React.Component<any, any> {
const label = [md.label()]; const label = [md.label()];
if (md.unitLabel) label.push(`(${md.unitLabel()})`); if (md.unitLabel) label.push(`(${md.unitLabel()})`);
const inputStyle: any = Object.assign({}, textInputBaseStyle); const inputStyle: any = { ...textInputBaseStyle };
return ( return (
<div key={key} style={rowStyle}> <div key={key} style={rowStyle}>
@ -679,15 +663,13 @@ class ConfigScreenComponent extends React.Component<any, any> {
public render() { public render() {
const theme = themeStyle(this.props.themeId); const theme = themeStyle(this.props.themeId);
const style = Object.assign({}, const style = {
this.props.style, ...this.props.style,
{
overflow: 'hidden', overflow: 'hidden',
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
backgroundColor: theme.backgroundColor3, backgroundColor: theme.backgroundColor3,
} };
);
const settings = this.state.settings; const settings = this.state.settings;

View File

@ -74,7 +74,7 @@ export default function DialogButtonRow(props: Props) {
if (props.cancelButtonShow !== false) { if (props.cancelButtonShow !== false) {
buttonComps.push( buttonComps.push(
<button disabled={props.cancelButtonDisabled} key="cancel" style={Object.assign({}, buttonStyle)} onClick={onCancelButtonClick}> <button disabled={props.cancelButtonDisabled} key="cancel" style={{ ...buttonStyle }} onClick={onCancelButtonClick}>
{props.cancelButtonLabel ? props.cancelButtonLabel : _('Cancel')} {props.cancelButtonLabel ? props.cancelButtonLabel : _('Cancel')}
</button> </button>
); );

View File

@ -29,15 +29,13 @@ class DropboxLoginScreenComponent extends React.Component<any, any> {
const style = this.props.style; const style = this.props.style;
const theme = themeStyle(this.props.themeId); const theme = themeStyle(this.props.themeId);
const containerStyle = Object.assign({}, theme.containerStyle, { const containerStyle = { ...theme.containerStyle, padding: theme.configScreenPadding,
padding: theme.configScreenPadding,
height: style.height - theme.margin * 2, height: style.height - theme.margin * 2,
flex: 1, flex: 1 };
});
const inputStyle = Object.assign({}, theme.inputStyle, { width: 500 }); const inputStyle = { ...theme.inputStyle, width: 500 };
const buttonStyle = Object.assign({}, theme.buttonStyle, { marginRight: 10 }); const buttonStyle = { ...theme.buttonStyle, marginRight: 10 };
return ( return (
<div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}> <div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>

View File

@ -82,7 +82,7 @@ function ExtensionBadge(props: Props) {
void bridge().openExternal(props.url); void bridge().openExternal(props.url);
}; };
const rootStyle = props.style ? Object.assign({}, style.root, props.style) : style.root; const rootStyle = props.style ? { ...style.root, ...props.style } : style.root;
return ( return (
<a style={rootStyle} onClick={onClick} href="#"> <a style={rootStyle} onClick={onClick} href="#">

View File

@ -23,7 +23,7 @@ class HelpButtonComponent extends React.Component<Props> {
public render() { public render() {
const theme = themeStyle(this.props.themeId); const theme = themeStyle(this.props.themeId);
const style = Object.assign({}, this.props.style, { color: theme.color, textDecoration: 'none' }); const style = { ...this.props.style, color: theme.color, textDecoration: 'none' };
const helpIconStyle = { flex: 0, width: 16, height: 16, marginLeft: 10 }; const helpIconStyle = { flex: 0, width: 16, height: 16, marginLeft: 10 };
const extraProps: any = {}; const extraProps: any = {};
if (this.props.tip) extraProps['data-tip'] = this.props.tip; if (this.props.tip) extraProps['data-tip'] = this.props.tip;

View File

@ -18,8 +18,7 @@ class IconButton extends React.Component<Props> {
}; };
const icon = <i style={iconStyle} className={`fas ${this.props.iconName}`}></i>; const icon = <i style={iconStyle} className={`fas ${this.props.iconName}`}></i>;
const rootStyle = Object.assign( const rootStyle = {
{
display: 'flex', display: 'flex',
textDecoration: 'none', textDecoration: 'none',
padding: 10, padding: 10,
@ -30,9 +29,8 @@ class IconButton extends React.Component<Props> {
justifyContent: 'center', justifyContent: 'center',
backgroundColor: theme.backgroundColor, backgroundColor: theme.backgroundColor,
cursor: 'default', cursor: 'default',
}, ...style,
style };
);
return ( return (
<a <a

View File

@ -148,10 +148,8 @@ class ItemList extends React.Component<Props, State> {
public render() { public render() {
const items = this.props.items; const items = this.props.items;
const style = Object.assign({}, this.props.style, { const style = { ...this.props.style, overflowX: 'hidden',
overflowX: 'hidden', overflowY: 'auto' };
overflowY: 'auto',
});
// if (this.props.disabled) style.opacity = 0.5; // if (this.props.disabled) style.opacity = 0.5;

View File

@ -501,16 +501,14 @@ class MainScreenComponent extends React.Component<Props, State> {
height: height, height: height,
}; };
this.styles_.modalLayer = Object.assign({}, theme.textStyle, { this.styles_.modalLayer = { ...theme.textStyle, zIndex: 10000,
zIndex: 10000,
position: 'absolute', position: 'absolute',
top: 0, top: 0,
left: 0, left: 0,
backgroundColor: theme.backgroundColor, backgroundColor: theme.backgroundColor,
width: width - 20, width: width - 20,
height: height - 20, height: height - 20,
padding: 10, padding: 10 };
});
return this.styles_; return this.styles_;
} }
@ -803,13 +801,11 @@ class MainScreenComponent extends React.Component<Props, State> {
public render() { public render() {
const theme = themeStyle(this.props.themeId); const theme = themeStyle(this.props.themeId);
const style = Object.assign( const style = {
{
color: theme.color, color: theme.color,
backgroundColor: theme.backgroundColor, backgroundColor: theme.backgroundColor,
}, ...this.props.style,
this.props.style };
);
const promptOptions = this.state.promptOptions; const promptOptions = this.state.promptOptions;
const styles = this.styles(this.props.themeId, style.width, style.height, this.messageBoxVisible()); const styles = this.styles(this.props.themeId, style.width, style.height, this.messageBoxVisible());
@ -824,7 +820,7 @@ class MainScreenComponent extends React.Component<Props, State> {
const dialogInfo = PluginManager.instance().pluginDialogToShow(this.props.pluginsLegacy); const dialogInfo = PluginManager.instance().pluginDialogToShow(this.props.pluginsLegacy);
const pluginDialog = !dialogInfo ? null : <dialogInfo.Dialog {...dialogInfo.props} />; const pluginDialog = !dialogInfo ? null : <dialogInfo.Dialog {...dialogInfo.props} />;
const modalLayerStyle = Object.assign({}, styles.modalLayer, { display: this.state.modalLayer.visible ? 'block' : 'none' }); const modalLayerStyle = { ...styles.modalLayer, display: this.state.modalLayer.visible ? 'block' : 'none' };
const notePropertiesDialogOptions = this.state.notePropertiesDialogOptions; const notePropertiesDialogOptions = this.state.notePropertiesDialogOptions;
const noteContentPropertiesDialogOptions = this.state.noteContentPropertiesDialogOptions; const noteContentPropertiesDialogOptions = this.state.noteContentPropertiesDialogOptions;

View File

@ -17,11 +17,9 @@ export const runtime = (): CommandRuntime => {
const defaultValues = Note.previewFieldsWithDefaultValues({ includeTimestamps: false }); const defaultValues = Note.previewFieldsWithDefaultValues({ includeTimestamps: false });
let newNote = Object.assign({}, defaultValues, { let newNote = { ...defaultValues, parent_id: folderId,
parent_id: folderId,
is_todo: isTodo ? 1 : 0, is_todo: isTodo ? 1 : 0,
body: body, body: body };
});
newNote = await Note.save(newNote, { provisional: true }); newNote = await Note.save(newNote, { provisional: true });

View File

@ -31,7 +31,7 @@ export default function useExternalPlugins(CodeMirror: any, plugins: PluginState
} }
if (mod.codeMirrorOptions) { if (mod.codeMirrorOptions) {
newOptions = Object.assign({}, newOptions, mod.codeMirrorOptions); newOptions = { ...newOptions, ...mod.codeMirrorOptions };
} }
if (mod.assets) { if (mod.assets) {

View File

@ -1544,7 +1544,7 @@
} }
}); });
editor.addCommand('InsertJoplinChecklist', function (ui, detail) { editor.addCommand('InsertJoplinChecklist', function (ui, detail) {
detail = Object.assign({}, detail, { listType: 'joplinChecklist' }); detail = { ...detail, listType: 'joplinChecklist' };
ToggleList.toggleList(editor, 'UL', detail); ToggleList.toggleList(editor, 'UL', detail);
}); });
} }

View File

@ -364,13 +364,11 @@ function NoteEditor(props: NoteEditorProps) {
}, [props.dispatch, formNote]); }, [props.dispatch, formNote]);
function renderNoNotes(rootStyle: any) { function renderNoNotes(rootStyle: any) {
const emptyDivStyle = Object.assign( const emptyDivStyle = {
{
backgroundColor: 'black', backgroundColor: 'black',
opacity: 0.1, opacity: 0.1,
}, ...rootStyle,
rootStyle };
);
return <div style={emptyDivStyle}></div>; return <div style={emptyDivStyle}></div>;
} }

View File

@ -59,14 +59,12 @@ export default function useMarkupToHtml(deps: HookDependencies) {
delete options.replaceResourceInternalToExternalLinks; delete options.replaceResourceInternalToExternalLinks;
const result = await markupToHtml.render(markupLanguage, md, theme, Object.assign({}, { const result = await markupToHtml.render(markupLanguage, md, theme, { codeTheme: theme.codeThemeCss,
codeTheme: theme.codeThemeCss,
resources: resources, resources: resources,
postMessageSyntax: 'ipcProxySendToHost', postMessageSyntax: 'ipcProxySendToHost',
splitted: true, splitted: true,
externalAssetsOnly: true, externalAssetsOnly: true,
codeHighlightCacheKey: 'useMarkupToHtml', codeHighlightCacheKey: 'useMarkupToHtml', ...options });
}, options));
return result; return result;
// eslint-disable-next-line @seiyab/react-hooks/exhaustive-deps -- Old code before rule was applied // eslint-disable-next-line @seiyab/react-hooks/exhaustive-deps -- Old code before rule was applied

View File

@ -62,7 +62,7 @@ export default function useNoteSearchBar({ noteSearchBarRef }: UseNoteSearchBarP
const noteSearchBarNextPrevious = useCallback((inc: number) => { const noteSearchBarNextPrevious = useCallback((inc: number) => {
setLocalSearch((prev: LocalSearch) => { setLocalSearch((prev: LocalSearch) => {
const ls = Object.assign({}, prev); const ls = { ...prev };
ls.selectedIndex += inc; ls.selectedIndex += inc;
ls.timestamp = Date.now(); ls.timestamp = Date.now();
if (ls.selectedIndex < 0) ls.selectedIndex = ls.resultCount - 1; if (ls.selectedIndex < 0) ls.selectedIndex = ls.resultCount - 1;

View File

@ -108,10 +108,10 @@ function NoteListItem(props: NoteListItemProps, ref: any) {
); );
} }
let listItemTitleStyle = Object.assign({}, props.style.listItemTitle); let listItemTitleStyle = { ...props.style.listItemTitle };
listItemTitleStyle.paddingLeft = !item.is_todo ? hPadding : 4; listItemTitleStyle.paddingLeft = !item.is_todo ? hPadding : 4;
if (item.is_shared) listItemTitleStyle.color = theme.colorWarn3; if (item.is_shared) listItemTitleStyle.color = theme.colorWarn3;
if (item.is_todo && !!item.todo_completed) listItemTitleStyle = Object.assign(listItemTitleStyle, props.style.listItemTitleCompleted); if (item.is_todo && !!item.todo_completed) listItemTitleStyle = { ...listItemTitleStyle, ...props.style.listItemTitleCompleted };
const displayTitle = Note.displayTitle(item); const displayTitle = Note.displayTitle(item);
let titleComp = null; let titleComp = null;

View File

@ -114,7 +114,7 @@ class NotePropertiesDialog extends React.Component<Props, State> {
} }
public formNoteToNote(formNote: any) { public formNoteToNote(formNote: any) {
const note = Object.assign({ id: formNote.id }, this.latLongFromLocation(formNote.location)); const note = { id: formNote.id, ...this.latLongFromLocation(formNote.location) };
note.user_created_time = time.formatLocalToMs(formNote.user_created_time); note.user_created_time = time.formatLocalToMs(formNote.user_created_time);
note.user_updated_time = time.formatLocalToMs(formNote.user_updated_time); note.user_updated_time = time.formatLocalToMs(formNote.user_updated_time);
@ -211,7 +211,7 @@ class NotePropertiesDialog extends React.Component<Props, State> {
if (!this.state.editedKey) return; if (!this.state.editedKey) return;
return new Promise((resolve: Function) => { return new Promise((resolve: Function) => {
const newFormNote = Object.assign({}, this.state.formNote); const newFormNote = { ...this.state.formNote };
if (this.state.editedKey.indexOf('_time') >= 0) { if (this.state.editedKey.indexOf('_time') >= 0) {
const dt = time.anythingToDateTime(this.state.editedValue, new Date()); const dt = time.anythingToDateTime(this.state.editedValue, new Date());
@ -248,7 +248,7 @@ class NotePropertiesDialog extends React.Component<Props, State> {
public createNoteField(key: string, value: any) { public createNoteField(key: string, value: any) {
const styles = this.styles(this.props.themeId); const styles = this.styles(this.props.themeId);
const theme = themeStyle(this.props.themeId); const theme = themeStyle(this.props.themeId);
const labelComp = <label style={Object.assign({}, theme.textStyle, theme.controlBoxLabel)}>{this.formatLabel(key)}</label>; const labelComp = <label style={{ ...theme.textStyle, ...theme.controlBoxLabel }}>{this.formatLabel(key)}</label>;
let controlComp = null; let controlComp = null;
let editComp = null; let editComp = null;
let editCompHandler = null; let editCompHandler = null;
@ -317,7 +317,7 @@ class NotePropertiesDialog extends React.Component<Props, State> {
const ll = this.latLongFromLocation(value); const ll = this.latLongFromLocation(value);
url = Note.geoLocationUrlFromLatLong(ll.latitude, ll.longitude); url = Note.geoLocationUrlFromLatLong(ll.latitude, ll.longitude);
} }
const urlStyle = Object.assign({}, theme.urlStyle, { maxWidth: '180px', overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }); const urlStyle = { ...theme.urlStyle, maxWidth: '180px', overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' };
controlComp = ( controlComp = (
<a href="#" onClick={() => bridge().openExternal(url)} style={urlStyle}> <a href="#" onClick={() => bridge().openExternal(url)} style={urlStyle}>
{displayedValue} {displayedValue}
@ -330,7 +330,7 @@ class NotePropertiesDialog extends React.Component<Props, State> {
</a> </a>
); );
} else { } else {
controlComp = <div style={Object.assign({}, theme.textStyle, theme.controlBoxValue)}>{displayedValue}</div>; controlComp = <div style={{ ...theme.textStyle, ...theme.controlBoxValue }}>{displayedValue}</div>;
} }
if (['id', 'revisionsLink', 'markup_language'].indexOf(key) < 0) { if (['id', 'revisionsLink', 'markup_language'].indexOf(key) < 0) {

View File

@ -67,8 +67,8 @@ class NoteRevisionViewerComponent extends React.PureComponent<Props, State> {
flex: 1, flex: 1,
flexDirection: 'column', flexDirection: 'column',
}, },
titleInput: Object.assign({}, theme.inputStyle, { flex: 1 }), titleInput: { ...theme.inputStyle, flex: 1 },
revisionList: Object.assign({}, theme.dropdownList, { marginLeft: 10, flex: 0.5 }), revisionList: { ...theme.dropdownList, marginLeft: 10, flex: 0.5 },
}; };
return style; return style;
@ -205,14 +205,14 @@ class NoteRevisionViewerComponent extends React.PureComponent<Props, State> {
const titleInput = ( const titleInput = (
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', marginBottom: 10, borderWidth: 1, borderBottomStyle: 'solid', borderColor: theme.dividerColor, paddingBottom: 10 }}> <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', marginBottom: 10, borderWidth: 1, borderBottomStyle: 'solid', borderColor: theme.dividerColor, paddingBottom: 10 }}>
<button onClick={this.backButton_click} style={Object.assign({}, theme.buttonStyle, { marginRight: 10, height: theme.inputStyle.height })}> <button onClick={this.backButton_click} style={{ ...theme.buttonStyle, marginRight: 10, height: theme.inputStyle.height }}>
<i style={theme.buttonIconStyle} className={'fa fa-chevron-left'}></i>{_('Back')} <i style={theme.buttonIconStyle} className={'fa fa-chevron-left'}></i>{_('Back')}
</button> </button>
<input readOnly type="text" style={style.titleInput} value={this.state.note ? this.state.note.title : ''} /> <input readOnly type="text" style={style.titleInput} value={this.state.note ? this.state.note.title : ''} />
<select disabled={!this.state.revisions.length} value={this.state.currentRevId} style={style.revisionList} onChange={this.revisionList_onChange}> <select disabled={!this.state.revisions.length} value={this.state.currentRevId} style={style.revisionList} onChange={this.revisionList_onChange}>
{revisionListItems} {revisionListItems}
</select> </select>
<button disabled={!this.state.revisions.length || this.state.restoring} onClick={this.importButton_onClick} style={Object.assign({}, theme.buttonStyle, { marginLeft: 10, height: theme.inputStyle.height })}> <button disabled={!this.state.revisions.length || this.state.restoring} onClick={this.importButton_onClick} style={{ ...theme.buttonStyle, marginLeft: 10, height: theme.inputStyle.height }}>
{restoreButtonTitle} {restoreButtonTitle}
</button> </button>
<HelpButton tip={helpMessage} id="noteRevisionHelpButton" onClick={this.helpButton_onClick} /> <HelpButton tip={helpMessage} id="noteRevisionHelpButton" onClick={this.helpButton_onClick} />

View File

@ -37,10 +37,8 @@ class NoteSearchBar extends React.Component<Props> {
const theme = themeStyle(this.props.themeId); const theme = themeStyle(this.props.themeId);
const style = { const style = {
root: Object.assign({}, theme.textStyle, { root: { ...theme.textStyle, backgroundColor: theme.backgroundColor,
backgroundColor: theme.backgroundColor, color: theme.colorFaded },
color: theme.colorFaded,
}),
}; };
return style; return style;
@ -150,12 +148,10 @@ class NoteSearchBar extends React.Component<Props> {
const previousButton = this.buttonIconComponent('fa-chevron-up', this.previousButton_click, buttonEnabled); const previousButton = this.buttonIconComponent('fa-chevron-up', this.previousButton_click, buttonEnabled);
const nextButton = this.buttonIconComponent('fa-chevron-down', this.nextButton_click, buttonEnabled); const nextButton = this.buttonIconComponent('fa-chevron-down', this.nextButton_click, buttonEnabled);
const textStyle = Object.assign({ const textStyle = { fontSize: theme.fontSize,
fontSize: theme.fontSize,
fontFamily: theme.fontFamily, fontFamily: theme.fontFamily,
color: theme.colorFaded, color: theme.colorFaded,
backgroundColor: theme.backgroundColor, backgroundColor: theme.backgroundColor };
});
const matchesFoundString = (query.length > 0) ? ( const matchesFoundString = (query.length > 0) ? (
<div style={textStyle}> <div style={textStyle}>

View File

@ -15,10 +15,8 @@ class NoteStatusBarComponent extends React.Component<Props> {
const theme = themeStyle(this.props.themeId); const theme = themeStyle(this.props.themeId);
const style = { const style = {
root: Object.assign({}, theme.textStyle, { root: { ...theme.textStyle, backgroundColor: theme.backgroundColor,
backgroundColor: theme.backgroundColor, color: theme.colorFaded },
color: theme.colorFaded,
}),
}; };
return style; return style;

View File

@ -173,7 +173,7 @@ export default class NoteTextViewerComponent extends React.Component<Props, any>
// ---------------------------------------------------------------- // ----------------------------------------------------------------
public render() { public render() {
const viewerStyle = Object.assign({}, { border: 'none' }, this.props.viewerStyle); const viewerStyle = { border: 'none', ...this.props.viewerStyle };
return <iframe className="noteTextViewer" ref={this.webviewRef_} style={viewerStyle} src="gui/note-viewer/index.html"></iframe>; return <iframe className="noteTextViewer" ref={this.webviewRef_} style={viewerStyle} src="gui/note-viewer/index.html"></iframe>;
} }
} }

View File

@ -132,43 +132,49 @@ export default class PromptDialog extends React.Component<Props, any> {
}; };
this.styles_.select = { this.styles_.select = {
control: (provided: any) => control: (provided: any) => {
Object.assign(provided, { return { ...provided,
minWidth: width * 0.2, minWidth: width * 0.2,
maxWidth: width * 0.5, maxWidth: width * 0.5,
fontFamily: theme.fontFamily, fontFamily: theme.fontFamily,
}), };
input: (provided: any) => },
Object.assign(provided, { input: (provided: any) => {
return { ...provided,
minWidth: '20px', minWidth: '20px',
color: theme.color, color: theme.color,
}), };
menu: (provided: any) => },
Object.assign(provided, { menu: (provided: any) => {
return { ...provided,
color: theme.color, color: theme.color,
fontFamily: theme.fontFamily, fontFamily: theme.fontFamily,
backgroundColor: theme.backgroundColor, backgroundColor: theme.backgroundColor,
}), };
option: (provided: any, state: any) => },
Object.assign(provided, { option: (provided: any, state: any) => {
return { ...provided,
color: theme.color, color: theme.color,
fontFamily: theme.fontFamily, fontFamily: theme.fontFamily,
paddingLeft: `${10 + (state.data.indentDepth || 0) * 20}px`, paddingLeft: `${10 + (state.data.indentDepth || 0) * 20}px`,
}), };
multiValueLabel: (provided: any) => },
Object.assign(provided, { multiValueLabel: (provided: any) => {
return { ...provided,
fontFamily: theme.fontFamily, fontFamily: theme.fontFamily,
}), };
multiValueRemove: (provided: any) => },
Object.assign(provided, { multiValueRemove: (provided: any) => {
return { ...provided,
color: theme.color, color: theme.color,
}), };
},
}; };
this.styles_.selectTheme = (tagTheme: any) => this.styles_.selectTheme = (tagTheme: any) => {
Object.assign(tagTheme, { return { ...tagTheme,
borderRadius: 2, borderRadius: 2,
colors: Object.assign(tagTheme.colors, { colors: { ...tagTheme.colors,
primary: theme.raisedBackgroundColor, primary: theme.raisedBackgroundColor,
primary25: theme.raisedBackgroundColor, primary25: theme.raisedBackgroundColor,
neutral0: theme.backgroundColor, neutral0: theme.backgroundColor,
@ -184,12 +190,11 @@ export default class PromptDialog extends React.Component<Props, any> {
neutral90: theme.color, neutral90: theme.color,
danger: theme.backgroundColor, danger: theme.backgroundColor,
dangerLight: theme.colorError2, dangerLight: theme.colorError2,
}), },
}); };
};
this.styles_.desc = Object.assign({}, theme.textStyle, { this.styles_.desc = { ...theme.textStyle, marginTop: 10 };
marginTop: 10,
});
return this.styles_; return this.styles_;
} }

View File

@ -56,15 +56,13 @@ function StatusScreen(props: Props) {
flexDirection: 'column', flexDirection: 'column',
}; };
const retryStyle = Object.assign({}, theme.urlStyle, { marginLeft: 5 }); const retryStyle = { ...theme.urlStyle, marginLeft: 5 };
const retryAllStyle = Object.assign({}, theme.urlStyle, { marginTop: 5, display: 'inline-block' }); const retryAllStyle = { ...theme.urlStyle, marginTop: 5, display: 'inline-block' };
const containerPadding = theme.configScreenPadding; const containerPadding = theme.configScreenPadding;
const containerStyle = Object.assign({}, theme.containerStyle, { const containerStyle = { ...theme.containerStyle, padding: containerPadding,
padding: containerPadding, flex: 1 };
flex: 1,
});
function renderSectionTitleHtml(key: string, title: string) { function renderSectionTitleHtml(key: string, title: string) {
return ( return (

View File

@ -7,7 +7,7 @@ import { AppState } from '../app.reducer';
class TagItemComponent extends React.Component { class TagItemComponent extends React.Component {
public render() { public render() {
const theme = themeStyle(this.props.themeId); const theme = themeStyle(this.props.themeId);
const style = Object.assign({}, theme.tagStyle); const style = { ...theme.tagStyle };
const { title, id } = this.props; const { title, id } = this.props;
return <button style={style} onClick={() => CommandService.instance().execute('openTag', id)}>{title}</button>; return <button style={style} onClick={() => CommandService.instance().execute('openTag', id)}>{title}</button>;

View File

@ -16,14 +16,12 @@ class ToolbarBaseComponent extends React.Component<Props, any> {
public render() { public render() {
const theme = themeStyle(this.props.themeId); const theme = themeStyle(this.props.themeId);
const style: any = Object.assign({ const style: any = { display: 'flex',
display: 'flex',
flexDirection: 'row', flexDirection: 'row',
boxSizing: 'border-box', boxSizing: 'border-box',
backgroundColor: theme.backgroundColor3, backgroundColor: theme.backgroundColor3,
padding: theme.toolbarPadding, padding: theme.toolbarPadding,
paddingRight: theme.mainPadding, paddingRight: theme.mainPadding, ...this.props.style };
}, this.props.style);
const groupStyle: any = { const groupStyle: any = {
display: 'flex', display: 'flex',
@ -45,13 +43,11 @@ class ToolbarBaseComponent extends React.Component<Props, any> {
if (!key) key = `${o.type}_${i}`; if (!key) key = `${o.type}_${i}`;
const props = Object.assign( const props = {
{
key: key, key: key,
themeId: this.props.themeId, themeId: this.props.themeId,
}, ...o,
o };
);
if (o.name === 'toggleEditors') { if (o.name === 'toggleEditors') {
rightItemComps.push(<ToggleEditorsButton rightItemComps.push(<ToggleEditorsButton
@ -77,7 +73,7 @@ class ToolbarBaseComponent extends React.Component<Props, any> {
<div style={groupStyle}> <div style={groupStyle}>
{centerItemComps} {centerItemComps}
</div> </div>
<div style={Object.assign({}, groupStyle, { flex: 1, justifyContent: 'flex-end' })}> <div style={{ ...groupStyle, flex: 1, justifyContent: 'flex-end' }}>
{rightItemComps} {rightItemComps}
</div> </div>
</div> </div>

View File

@ -8,7 +8,7 @@ interface Props {
class ToolbarSpace extends React.Component<Props> { class ToolbarSpace extends React.Component<Props> {
public render() { public render() {
const theme = themeStyle(this.props.themeId); const theme = themeStyle(this.props.themeId);
const style = Object.assign({}, theme.toolbarStyle); const style = { ...theme.toolbarStyle };
style.minWidth = style.height / 2; style.minWidth = style.height / 2;
return <span style={style}></span>; return <span style={style}></span>;

View File

@ -96,9 +96,8 @@ markJsUtils.markKeyword = (mark, keyword, stringUtils, extraOptions = null) => {
mark.mark( mark.mark(
[value], [value],
Object.assign(
{},
{ {
accuracy: accuracy, accuracy: accuracy,
filter: (node, _term, _totalCounter, _counter) => { filter: (node, _term, _totalCounter, _counter) => {
// We exclude SVG because it creates a "<mark>" tag inside // We exclude SVG because it creates a "<mark>" tag inside
@ -112,9 +111,8 @@ markJsUtils.markKeyword = (mark, keyword, stringUtils, extraOptions = null) => {
if (isInsideContainer(node, 'SVG')) return false; if (isInsideContainer(node, 'SVG')) return false;
return true; return true;
}, },
}, ...extraOptions,
extraOptions }
)
); );
}; };

View File

@ -41,13 +41,9 @@ const style = createSelector(
}, },
}; };
output.buttonIconSelected = Object.assign({}, output.buttonIcon, { output.buttonIconSelected = { ...output.buttonIcon, color: theme.highlightedColor };
color: theme.highlightedColor,
});
output.buttonLabelSelected = Object.assign({}, output.buttonLabel, { output.buttonLabelSelected = { ...output.buttonLabel, color: theme.color };
color: theme.color,
});
return output; return output;
} }

View File

@ -133,8 +133,8 @@ class Dialog extends React.PureComponent<Props, State> {
} }
this.styles_[styleKey] = { this.styles_[styleKey] = {
dialogBox: Object.assign({}, theme.dialogBox, { minWidth: '50%', maxWidth: '50%' }), dialogBox: { ...theme.dialogBox, minWidth: '50%', maxWidth: '50%' },
input: Object.assign({}, theme.inputStyle, { flex: 1 }), input: { ...theme.inputStyle, flex: 1 },
row: { row: {
overflow: 'hidden', overflow: 'hidden',
height: itemHeight, height: itemHeight,
@ -148,7 +148,7 @@ class Dialog extends React.PureComponent<Props, State> {
borderBottomColor: theme.dividerColor, borderBottomColor: theme.dividerColor,
boxSizing: 'border-box', boxSizing: 'border-box',
}, },
help: Object.assign({}, theme.textStyle, { marginBottom: 10 }), help: { ...theme.textStyle, marginBottom: 10 },
inputHelpWrapper: { display: 'flex', flexDirection: 'row', alignItems: 'center' }, inputHelpWrapper: { display: 'flex', flexDirection: 'row', alignItems: 'center' },
}; };
@ -163,19 +163,15 @@ class Dialog extends React.PureComponent<Props, State> {
userSelect: 'none', userSelect: 'none',
}; };
const rowTitleStyle = Object.assign({}, rowTextStyle, { const rowTitleStyle = { ...rowTextStyle, fontSize: rowTextStyle.fontSize * 1.4,
fontSize: rowTextStyle.fontSize * 1.4,
marginBottom: this.state.resultsInBody ? 6 : 4, marginBottom: this.state.resultsInBody ? 6 : 4,
color: theme.colorFaded, color: theme.colorFaded };
});
const rowFragmentsStyle = Object.assign({}, rowTextStyle, { const rowFragmentsStyle = { ...rowTextStyle, fontSize: rowTextStyle.fontSize * 1.2,
fontSize: rowTextStyle.fontSize * 1.2,
marginBottom: this.state.resultsInBody ? 8 : 6, marginBottom: this.state.resultsInBody ? 8 : 6,
color: theme.colorFaded, color: theme.colorFaded };
});
this.styles_[styleKey].rowSelected = Object.assign({}, this.styles_[styleKey].row, { backgroundColor: theme.selectedColor }); this.styles_[styleKey].rowSelected = { ...this.styles_[styleKey].row, backgroundColor: theme.selectedColor };
this.styles_[styleKey].rowPath = rowTextStyle; this.styles_[styleKey].rowPath = rowTextStyle;
this.styles_[styleKey].rowTitle = rowTitleStyle; this.styles_[styleKey].rowTitle = rowTitleStyle;
this.styles_[styleKey].rowFragments = rowFragmentsStyle; this.styles_[styleKey].rowFragments = rowFragmentsStyle;
@ -304,7 +300,7 @@ class Dialog extends React.PureComponent<Props, State> {
for (let i = 0; i < results.length; i++) { for (let i = 0; i < results.length; i++) {
const row = results[i]; const row = results[i];
const path = Folder.folderPathString(this.props.folders, row.parent_id); const path = Folder.folderPathString(this.props.folders, row.parent_id);
results[i] = Object.assign({}, row, { path: path ? path : '/' }); results[i] = { ...row, path: path ? path : '/' };
} }
} else { // Note TITLE or BODY } else { // Note TITLE or BODY
listType = BaseModel.TYPE_NOTE; listType = BaseModel.TYPE_NOTE;
@ -317,7 +313,7 @@ class Dialog extends React.PureComponent<Props, State> {
for (let i = 0; i < results.length; i++) { for (let i = 0; i < results.length; i++) {
const row = results[i]; const row = results[i];
const path = Folder.folderPathString(this.props.folders, row.parent_id); const path = Folder.folderPathString(this.props.folders, row.parent_id);
results[i] = Object.assign({}, row, { path: path }); results[i] = { ...row, path: path };
} }
} else { } else {
const limit = 20; const limit = 20;
@ -365,9 +361,9 @@ class Dialog extends React.PureComponent<Props, State> {
} }
results[i] = Object.assign({}, row, { path, fragments }); results[i] = { ...row, path, fragments };
} else { } else {
results[i] = Object.assign({}, row, { path: path, fragments: '' }); results[i] = { ...row, path: path, fragments: '' };
} }
} }

View File

@ -104,7 +104,7 @@ class CameraView extends Component {
} }
return ( return (
<TouchableOpacity onPress={onPress} style={Object.assign({}, style)}> <TouchableOpacity onPress={onPress} style={{ ...style }}>
<View style={{ borderRadius: 32, width: 60, height: 60, borderColor: '#00000040', borderWidth: 1, borderStyle: 'solid', backgroundColor: '#ffffff77', justifyContent: 'center', alignItems: 'center', alignSelf: 'baseline' }}> <View style={{ borderRadius: 32, width: 60, height: 60, borderColor: '#00000040', borderWidth: 1, borderStyle: 'solid', backgroundColor: '#ffffff77', justifyContent: 'center', alignItems: 'center', alignSelf: 'baseline' }}>
{ icon } { icon }
</View> </View>
@ -177,10 +177,10 @@ class CameraView extends Component {
cameraRect.top = (this.state.screenHeight - cameraRect.height) / 2; cameraRect.top = (this.state.screenHeight - cameraRect.height) / 2;
return ( return (
<View style={Object.assign({}, this.props.style, { position: 'relative' })} onLayout={this.onLayout}> <View style={{ ...this.props.style, position: 'relative' }} onLayout={this.onLayout}>
<View style={{ position: 'absolute', backgroundColor: '#000000', width: '100%', height: '100%' }}/> <View style={{ position: 'absolute', backgroundColor: '#000000', width: '100%', height: '100%' }}/>
<RNCamera <RNCamera
style={Object.assign({ position: 'absolute' }, cameraRect)} style={({ position: 'absolute', ...cameraRect })}
ref={(ref: any) => { ref={(ref: any) => {
this.camera = ref; this.camera = ref;
}} }}

View File

@ -84,36 +84,26 @@ class Dropdown extends Component<DropdownProps, DropdownState> {
width: windowWidth, width: windowWidth,
}; };
const itemListStyle = Object.assign({}, this.props.itemListStyle ? this.props.itemListStyle : {}, { const itemListStyle = { ...(this.props.itemListStyle ? this.props.itemListStyle : {}), borderWidth: 1,
borderWidth: 1, borderColor: '#ccc' };
borderColor: '#ccc',
});
const itemWrapperStyle = Object.assign({}, this.props.itemWrapperStyle ? this.props.itemWrapperStyle : {}, { const itemWrapperStyle = { ...(this.props.itemWrapperStyle ? this.props.itemWrapperStyle : {}), flex: 1,
flex: 1,
justifyContent: 'center', justifyContent: 'center',
height: itemHeight, height: itemHeight,
paddingLeft: 20, paddingLeft: 20,
paddingRight: 10, paddingRight: 10 };
});
const headerWrapperStyle = Object.assign({}, this.props.headerWrapperStyle ? this.props.headerWrapperStyle : {}, { const headerWrapperStyle = { ...(this.props.headerWrapperStyle ? this.props.headerWrapperStyle : {}), height: 35,
height: 35,
flex: 1, flex: 1,
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center' };
});
const headerStyle = Object.assign({}, this.props.headerStyle ? this.props.headerStyle : {}, { const headerStyle = { ...(this.props.headerStyle ? this.props.headerStyle : {}), flex: 1 };
flex: 1,
});
const headerArrowStyle = Object.assign({}, this.props.headerStyle ? this.props.headerStyle : {}, { const headerArrowStyle = { ...(this.props.headerStyle ? this.props.headerStyle : {}), flex: 0,
flex: 0, marginRight: 10 };
marginRight: 10,
});
const itemStyle = Object.assign({}, this.props.itemStyle ? this.props.itemStyle : {}, {}); const itemStyle = { ...(this.props.itemStyle ? this.props.itemStyle : {}) };
let headerLabel = '...'; let headerLabel = '...';
for (let i = 0; i < items.length; i++) { for (let i = 0; i < items.length; i++) {
@ -136,7 +126,7 @@ class Dropdown extends Component<DropdownProps, DropdownState> {
const key = item.value ? item.value.toString() : '__null'; // The top item ("Move item to notebook...") has a null value. const key = item.value ? item.value.toString() : '__null'; // The top item ("Move item to notebook...") has a null value.
return ( return (
<TouchableOpacity <TouchableOpacity
style={itemWrapperStyle} style={itemWrapperStyle as any}
accessibilityRole="menuitem" accessibilityRole="menuitem"
key={key} key={key}
onPress={() => { onPress={() => {
@ -170,7 +160,7 @@ class Dropdown extends Component<DropdownProps, DropdownState> {
return ( return (
<View style={{ flex: 1, flexDirection: 'column' }}> <View style={{ flex: 1, flexDirection: 'column' }}>
<TouchableOpacity <TouchableOpacity
style={headerWrapperStyle} style={headerWrapperStyle as any}
ref={ref => (this.headerRef = ref)} ref={ref => (this.headerRef = ref)}
disabled={this.props.disabled} disabled={this.props.disabled}
onPress={() => { onPress={() => {

View File

@ -34,12 +34,10 @@ class ModalDialog extends React.Component {
modalContentWrapper2: { modalContentWrapper2: {
flex: 1, flex: 1,
}, },
title: Object.assign({}, theme.normalText, { title: { ...theme.normalText, borderBottomWidth: 1,
borderBottomWidth: 1,
borderBottomColor: theme.dividerColor, borderBottomColor: theme.dividerColor,
paddingBottom: 10, paddingBottom: 10,
fontWeight: 'bold', fontWeight: 'bold' },
}),
buttonRow: { buttonRow: {
flexDirection: 'row', flexDirection: 'row',
borderTopWidth: 1, borderTopWidth: 1,

View File

@ -148,7 +148,7 @@ export const SearchPanel = (props: SearchPanelProps) => {
const control = props.searchControl; const control = props.searchControl;
const updateSearchState = (changedData: any) => { const updateSearchState = (changedData: any) => {
const newState = Object.assign({}, state, changedData); const newState = { ...state, ...changedData };
control.setSearchState(newState); control.setSearchState(newState);
}; };

View File

@ -20,7 +20,7 @@ function JoplinSafeAreaView(props) {
if (Platform.OS === 'ios') { if (Platform.OS === 'ios') {
return <SafeAreaView {...props}>{props.children}</SafeAreaView>; return <SafeAreaView {...props}>{props.children}</SafeAreaView>;
} else { } else {
const viewProps = Object.assign({}, props); const viewProps = { ...props };
const style = []; const style = [];

View File

@ -201,17 +201,17 @@ class ScreenHeaderComponent extends PureComponent<ScreenHeaderProps, ScreenHeade
}, },
}; };
styleObject.topIcon = Object.assign({}, theme.icon); styleObject.topIcon = { ...theme.icon };
styleObject.topIcon.flex = 1; styleObject.topIcon.flex = 1;
styleObject.topIcon.textAlignVertical = 'center'; styleObject.topIcon.textAlignVertical = 'center';
styleObject.topIcon.color = theme.colorBright2; styleObject.topIcon.color = theme.colorBright2;
styleObject.backButton = Object.assign({}, styleObject.iconButton); styleObject.backButton = { ...styleObject.iconButton };
styleObject.backButton.marginRight = 1; styleObject.backButton.marginRight = 1;
styleObject.backButtonDisabled = Object.assign({}, styleObject.backButton, { opacity: theme.disabledOpacity }); styleObject.backButtonDisabled = { ...styleObject.backButton, opacity: theme.disabledOpacity };
styleObject.saveButtonDisabled = Object.assign({}, styleObject.saveButton, { opacity: theme.disabledOpacity }); styleObject.saveButtonDisabled = { ...styleObject.saveButton, opacity: theme.disabledOpacity };
styleObject.iconButtonDisabled = Object.assign({}, styleObject.iconButton, { opacity: theme.disabledOpacity }); styleObject.iconButtonDisabled = { ...styleObject.iconButton, opacity: theme.disabledOpacity };
this.cachedStyles[themeId] = StyleSheet.create(styleObject); this.cachedStyles[themeId] = StyleSheet.create(styleObject);
return this.cachedStyles[themeId]; return this.cachedStyles[themeId];

View File

@ -42,11 +42,11 @@ class Checkbox extends Component {
render() { render() {
const iconName = this.state.checked ? 'md-checkbox-outline' : 'md-square-outline'; const iconName = this.state.checked ? 'md-checkbox-outline' : 'md-square-outline';
const style = this.props.style ? Object.assign({}, this.props.style) : {}; const style = this.props.style ? { ...this.props.style } : {};
style.justifyContent = 'center'; style.justifyContent = 'center';
style.alignItems = 'center'; style.alignItems = 'center';
const checkboxIconStyle = Object.assign({}, styles.checkboxIcon); const checkboxIconStyle = { ...styles.checkboxIcon };
if (style.color) checkboxIconStyle.color = style.color; if (style.color) checkboxIconStyle.color = style.color;
if (style.paddingTop) checkboxIconStyle.marginTop = style.paddingTop; if (style.paddingTop) checkboxIconStyle.marginTop = style.paddingTop;

View File

@ -100,7 +100,7 @@ function themeStyle(theme) {
const cacheKey = [theme].join('-'); const cacheKey = [theme].join('-');
if (themeCache_[cacheKey]) return themeCache_[cacheKey]; if (themeCache_[cacheKey]) return themeCache_[cacheKey];
const output = Object.assign({}, baseStyle, themeById(theme)); const output = { ...baseStyle, ...themeById(theme) };
themeCache_[cacheKey] = addExtraStyles(output); themeCache_[cacheKey] = addExtraStyles(output);
return themeCache_[cacheKey]; return themeCache_[cacheKey];
} }

View File

@ -51,16 +51,16 @@ class NoteItemComponent extends Component {
}, },
}; };
styles.listItemWithCheckbox = Object.assign({}, styles.listItem); styles.listItemWithCheckbox = { ...styles.listItem };
delete styles.listItemWithCheckbox.paddingTop; delete styles.listItemWithCheckbox.paddingTop;
delete styles.listItemWithCheckbox.paddingBottom; delete styles.listItemWithCheckbox.paddingBottom;
delete styles.listItemWithCheckbox.paddingLeft; delete styles.listItemWithCheckbox.paddingLeft;
styles.listItemTextWithCheckbox = Object.assign({}, styles.listItemText); styles.listItemTextWithCheckbox = { ...styles.listItemText };
styles.listItemTextWithCheckbox.marginTop = styles.listItem.paddingTop - 1; styles.listItemTextWithCheckbox.marginTop = styles.listItem.paddingTop - 1;
styles.listItemTextWithCheckbox.marginBottom = styles.listItem.paddingBottom; styles.listItemTextWithCheckbox.marginBottom = styles.listItem.paddingBottom;
styles.selectionWrapperSelected = Object.assign({}, styles.selectionWrapper); styles.selectionWrapperSelected = { ...styles.selectionWrapper };
styles.selectionWrapperSelected.backgroundColor = theme.selectedColor; styles.selectionWrapperSelected.backgroundColor = theme.selectedColor;
this.styles_[this.props.themeId] = StyleSheet.create(styles); this.styles_[this.props.themeId] = StyleSheet.create(styles);

View File

@ -284,30 +284,28 @@ class ConfigScreenComponent extends BaseScreenComponent {
}, },
}; };
styles.settingContainerNoBottomBorder = Object.assign({}, styles.settingContainer, { styles.settingContainerNoBottomBorder = { ...styles.settingContainer, borderBottomWidth: 0,
borderBottomWidth: 0, paddingBottom: theme.marginBottom / 2 };
paddingBottom: theme.marginBottom / 2,
});
styles.settingControl.borderBottomWidth = 1; styles.settingControl.borderBottomWidth = 1;
styles.settingControl.borderBottomColor = theme.dividerColor; styles.settingControl.borderBottomColor = theme.dividerColor;
styles.switchSettingText = Object.assign({}, styles.settingText); styles.switchSettingText = { ...styles.settingText };
styles.switchSettingText.width = '80%'; styles.switchSettingText.width = '80%';
styles.switchSettingContainer = Object.assign({}, styles.settingContainer); styles.switchSettingContainer = { ...styles.settingContainer };
styles.switchSettingContainer.flexDirection = 'row'; styles.switchSettingContainer.flexDirection = 'row';
styles.switchSettingContainer.justifyContent = 'space-between'; styles.switchSettingContainer.justifyContent = 'space-between';
styles.linkText = Object.assign({}, styles.settingText); styles.linkText = { ...styles.settingText };
styles.linkText.borderBottomWidth = 1; styles.linkText.borderBottomWidth = 1;
styles.linkText.borderBottomColor = theme.color; styles.linkText.borderBottomColor = theme.color;
styles.linkText.flex = 0; styles.linkText.flex = 0;
styles.linkText.fontWeight = 'normal'; styles.linkText.fontWeight = 'normal';
styles.headerWrapperStyle = Object.assign({}, styles.settingContainer, theme.headerWrapperStyle); styles.headerWrapperStyle = { ...styles.settingContainer, ...theme.headerWrapperStyle };
styles.switchSettingControl = Object.assign({}, styles.settingControl); styles.switchSettingControl = { ...styles.settingControl };
delete styles.switchSettingControl.color; delete styles.switchSettingControl.color;
// styles.switchSettingControl.width = '20%'; // styles.switchSettingControl.width = '20%';
styles.switchSettingControl.flex = 0; styles.switchSettingControl.flex = 0;

View File

@ -136,7 +136,7 @@ class NoteScreenComponent extends BaseScreenComponent {
Keyboard.dismiss(); Keyboard.dismiss();
this.setState({ this.setState({
note: Object.assign({}, this.state.lastSavedNote), note: { ...this.state.lastSavedNote },
mode: 'view', mode: 'view',
}); });
@ -281,7 +281,7 @@ class NoteScreenComponent extends BaseScreenComponent {
if (!undoState) return; if (!undoState) return;
this.setState((state: any) => { this.setState((state: any) => {
const newNote = Object.assign({}, state.note); const newNote = { ...state.note };
newNote.body = undoState.body; newNote.body = undoState.body;
return { return {
note: newNote, note: newNote,
@ -380,7 +380,7 @@ class NoteScreenComponent extends BaseScreenComponent {
borderBottomWidth: 1, borderBottomWidth: 1,
}; };
styles.titleContainerTodo = Object.assign({}, styles.titleContainer); styles.titleContainerTodo = { ...styles.titleContainer };
styles.titleContainerTodo.paddingLeft = 0; styles.titleContainerTodo.paddingLeft = 0;
styles.titleTextInput = { styles.titleTextInput = {
@ -692,7 +692,7 @@ class NoteScreenComponent extends BaseScreenComponent {
const resourceTag = Resource.markdownTag(resource); const resourceTag = Resource.markdownTag(resource);
const newNote = Object.assign({}, this.state.note); const newNote = { ...this.state.note };
if (this.state.mode === 'edit' && !!this.selection) { if (this.state.mode === 'edit' && !!this.selection) {
const newText = `\n${resourceTag}\n`; const newText = `\n${resourceTag}\n`;
@ -787,7 +787,7 @@ class NoteScreenComponent extends BaseScreenComponent {
} }
public async onAlarmDialogAccept(date: Date) { public async onAlarmDialogAccept(date: Date) {
const newNote = Object.assign({}, this.state.note); const newNote = { ...this.state.note };
newNote.todo_due = date ? date.getTime() : 0; newNote.todo_due = date ? date.getTime() : 0;
await this.saveOneProperty('todo_due', date ? date.getTime() : 0); await this.saveOneProperty('todo_due', date ? date.getTime() : 0);
@ -1085,7 +1085,7 @@ class NoteScreenComponent extends BaseScreenComponent {
const folder = await Folder.load(note.parent_id); const folder = await Folder.load(note.parent_id);
this.setState({ this.setState({
lastSavedNote: Object.assign({}, note), lastSavedNote: { ...note },
note: note, note: note,
folder: folder, folder: folder,
}); });

View File

@ -46,7 +46,7 @@ class NoteTagsDialogComponent extends React.Component {
for (let i = 0; i < newData.length; i++) { for (let i = 0; i < newData.length; i++) {
const t = newData[i]; const t = newData[i];
if (t.id === tagId) { if (t.id === tagId) {
const newTag = Object.assign({}, t); const newTag = { ...t };
newTag.selected = !newTag.selected; newTag.selected = !newTag.selected;
newData[i] = newTag; newData[i] = newTag;
break; break;
@ -142,7 +142,7 @@ class NoteTagsDialogComponent extends React.Component {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
}, },
tagText: Object.assign({}, theme.normalText), tagText: { ...theme.normalText },
tagCheckbox: { tagCheckbox: {
marginRight: 8, marginRight: 8,
fontSize: 20, fontSize: 20,
@ -156,8 +156,8 @@ class NoteTagsDialogComponent extends React.Component {
borderBottomWidth: 1, borderBottomWidth: 1,
borderBottomColor: theme.dividerColor, borderBottomColor: theme.dividerColor,
}, },
newTagBoxLabel: Object.assign({}, theme.normalText, { marginRight: 8 }), newTagBoxLabel: { ...theme.normalText, marginRight: 8 },
tagBoxInput: Object.assign({}, theme.lineInput, { flex: 1 }), tagBoxInput: { ...theme.lineInput, flex: 1 },
}; };
this.styles_[themeId] = StyleSheet.create(styles); this.styles_[themeId] = StyleSheet.create(styles);

View File

@ -26,7 +26,7 @@ class NotesScreenComponent extends BaseScreenComponent<any> {
this.onAppStateChange_ = async () => { this.onAppStateChange_ = async () => {
// Force an update to the notes list when app state changes // Force an update to the notes list when app state changes
const newProps = Object.assign({}, this.props); const newProps = { ...this.props };
newProps.notesSource = ''; newProps.notesSource = '';
await this.refreshNotes(newProps); await this.refreshNotes(newProps);
}; };

View File

@ -39,8 +39,8 @@ class DropboxLoginScreenComponent extends BaseScreenComponent {
padding: theme.margin, padding: theme.margin,
backgroundColor: theme.backgroundColor, backgroundColor: theme.backgroundColor,
}, },
stepText: Object.assign({}, theme.normalText, { marginBottom: theme.margin }), stepText: { ...theme.normalText, marginBottom: theme.margin },
urlText: Object.assign({}, theme.urlText, { marginBottom: theme.margin }), urlText: { ...theme.urlText, marginBottom: theme.margin },
}; };
this.styles_[themeId] = StyleSheet.create(styles); this.styles_[themeId] = StyleSheet.create(styles);

View File

@ -29,14 +29,14 @@ class FolderScreenComponent extends BaseScreenComponent {
const folder = Folder.new(); const folder = Folder.new();
this.setState({ this.setState({
folder: folder, folder: folder,
lastSavedFolder: Object.assign({}, folder), lastSavedFolder: { ...folder },
}); });
} else { } else {
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied // eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
Folder.load(this.props.folderId).then(folder => { Folder.load(this.props.folderId).then(folder => {
this.setState({ this.setState({
folder: folder, folder: folder,
lastSavedFolder: Object.assign({}, folder), lastSavedFolder: { ...folder },
}); });
}); });
} }
@ -51,7 +51,7 @@ class FolderScreenComponent extends BaseScreenComponent {
folderComponent_change(propName, propValue) { folderComponent_change(propName, propValue) {
this.setState((prevState) => { this.setState((prevState) => {
const folder = Object.assign({}, prevState.folder); const folder = { ...prevState.folder };
folder[propName] = propValue; folder[propName] = propValue;
return { folder: folder }; return { folder: folder };
}); });
@ -67,7 +67,7 @@ class FolderScreenComponent extends BaseScreenComponent {
async saveFolderButton_press() { async saveFolderButton_press() {
let folder = Object.assign({}, this.state.folder); let folder = { ...this.state.folder };
try { try {
if (folder.id && !(await Folder.canNestUnder(folder.id, folder.parent_id))) throw new Error(_('Cannot move notebook to this location')); if (folder.id && !(await Folder.canNestUnder(folder.id, folder.parent_id))) throw new Error(_('Cannot move notebook to this location'));
@ -78,7 +78,7 @@ class FolderScreenComponent extends BaseScreenComponent {
} }
this.setState({ this.setState({
lastSavedFolder: Object.assign({}, folder), lastSavedFolder: { ...folder },
folder: folder, folder: folder,
}); });

View File

@ -50,10 +50,10 @@ class LogScreenComponent extends BaseScreenComponent {
styles.rowText.fontFamily = 'monospace'; styles.rowText.fontFamily = 'monospace';
} }
styles.rowTextError = Object.assign({}, styles.rowText); styles.rowTextError = { ...styles.rowText };
styles.rowTextError.color = theme.colorError; styles.rowTextError.color = theme.colorError;
styles.rowTextWarn = Object.assign({}, styles.rowText); styles.rowTextWarn = { ...styles.rowText };
styles.rowTextWarn.color = theme.colorWarn; styles.rowTextWarn.color = theme.colorWarn;
this.styles_[this.props.themeId] = StyleSheet.create(styles); this.styles_[this.props.themeId] = StyleSheet.create(styles);

View File

@ -57,13 +57,13 @@ class SearchScreenComponent extends BaseScreenComponent {
}, },
}; };
styles.searchTextInput = Object.assign({}, theme.lineInput); styles.searchTextInput = { ...theme.lineInput };
styles.searchTextInput.paddingLeft = theme.marginLeft; styles.searchTextInput.paddingLeft = theme.marginLeft;
styles.searchTextInput.flex = 1; styles.searchTextInput.flex = 1;
styles.searchTextInput.backgroundColor = theme.backgroundColor; styles.searchTextInput.backgroundColor = theme.backgroundColor;
styles.searchTextInput.color = theme.color; styles.searchTextInput.color = theme.color;
styles.clearIcon = Object.assign({}, theme.icon); styles.clearIcon = { ...theme.icon };
styles.clearIcon.color = theme.colorFaded; styles.clearIcon.color = theme.colorFaded;
styles.clearIcon.paddingRight = theme.marginRight; styles.clearIcon.paddingRight = theme.marginRight;
styles.clearIcon.backgroundColor = theme.backgroundColor; styles.clearIcon.backgroundColor = theme.backgroundColor;

View File

@ -60,7 +60,7 @@ class StatusScreenComponent extends BaseScreenComponent {
for (let i = 0; i < report.length; i++) { for (let i = 0; i < report.length; i++) {
const section = report[i]; const section = report[i];
let style = Object.assign({}, baseStyle); let style = { ...baseStyle };
style.fontWeight = 'bold'; style.fontWeight = 'bold';
if (i > 0) style.paddingTop = 20; if (i > 0) style.paddingTop = 20;
lines.push({ key: `section_${i}`, isSection: true, text: section.title }); lines.push({ key: `section_${i}`, isSection: true, text: section.title });
@ -70,7 +70,7 @@ class StatusScreenComponent extends BaseScreenComponent {
for (const n in section.body) { for (const n in section.body) {
if (!section.body.hasOwnProperty(n)) continue; if (!section.body.hasOwnProperty(n)) continue;
style = Object.assign({}, baseStyle); style = { ...baseStyle };
const item = section.body[n]; const item = section.body[n];
let text = ''; let text = '';
@ -98,7 +98,7 @@ class StatusScreenComponent extends BaseScreenComponent {
<FlatList <FlatList
data={lines} data={lines}
renderItem={({ item }) => { renderItem={({ item }) => {
const style = Object.assign({}, baseStyle); const style = { ...baseStyle };
if (item.isSection === true) { if (item.isSection === true) {
style.fontWeight = 'bold'; style.fontWeight = 'bold';

View File

@ -45,8 +45,8 @@ class SideMenuContentNoteComponent extends Component {
}, },
}; };
styles.sideButton = Object.assign({}, styles.button, { flex: 0 }); styles.sideButton = { ...styles.button, flex: 0 };
styles.sideButtonDisabled = Object.assign({}, styles.sideButton, { opacity: 0.6 }); styles.sideButtonDisabled = { ...styles.sideButton, opacity: 0.6 };
this.styles_[this.props.themeId] = StyleSheet.create(styles); this.styles_[this.props.themeId] = StyleSheet.create(styles);
return this.styles_[this.props.themeId]; return this.styles_[this.props.themeId];

View File

@ -85,18 +85,18 @@ const SideMenuContentComponent = (props: Props) => {
}, },
}; };
styles.folderButton = Object.assign({}, styles.button); styles.folderButton = { ...styles.button };
styles.folderButton.paddingLeft = 0; styles.folderButton.paddingLeft = 0;
styles.folderButtonText = Object.assign({}, styles.buttonText, { paddingLeft: 0 }); styles.folderButtonText = { ...styles.buttonText, paddingLeft: 0 };
styles.folderButtonSelected = Object.assign({}, styles.folderButton); styles.folderButtonSelected = { ...styles.folderButton };
styles.folderButtonSelected.backgroundColor = theme.selectedColor; styles.folderButtonSelected.backgroundColor = theme.selectedColor;
styles.folderIcon = Object.assign({}, theme.icon); styles.folderIcon = { ...theme.icon };
styles.folderIcon.color = theme.colorFaded; // '#0072d5'; styles.folderIcon.color = theme.colorFaded; // '#0072d5';
styles.folderIcon.paddingTop = 3; styles.folderIcon.paddingTop = 3;
styles.sideButton = Object.assign({}, styles.button, { flex: 0 }); styles.sideButton = { ...styles.button, flex: 0 };
styles.sideButtonSelected = Object.assign({}, styles.sideButton, { backgroundColor: theme.selectedColor }); styles.sideButtonSelected = { ...styles.sideButton, backgroundColor: theme.selectedColor };
styles.sideButtonText = Object.assign({}, styles.buttonText); styles.sideButtonText = { ...styles.buttonText };
styles.emptyFolderIcon = { ...styles.sidebarIcon, marginRight: folderIconRightMargin, width: 20 }; styles.emptyFolderIcon = { ...styles.sidebarIcon, marginRight: folderIconRightMargin, width: 20 };

View File

@ -216,13 +216,11 @@ const DEFAULT_ROUTE = {
smartFilterId: 'c3176726992c11e9ac940492261af972', smartFilterId: 'c3176726992c11e9ac940492261af972',
}; };
const appDefaultState: AppState = Object.assign({}, defaultState, { const appDefaultState: AppState = { ...defaultState, sideMenuOpenPercent: 0,
sideMenuOpenPercent: 0,
route: DEFAULT_ROUTE, route: DEFAULT_ROUTE,
noteSelectionEnabled: false, noteSelectionEnabled: false,
noteSideMenuOptions: null, noteSideMenuOptions: null,
isOnMobileData: false, isOnMobileData: false };
});
const appReducer = (state = appDefaultState, action: any) => { const appReducer = (state = appDefaultState, action: any) => {
let newState = state; let newState = state;
@ -275,11 +273,11 @@ const appReducer = (state = appDefaultState, action: any) => {
for (let i = 0; i < navHistory.length; i++) { for (let i = 0; i < navHistory.length; i++) {
const n = navHistory[i]; const n = navHistory[i];
if (n.routeName === action.routeName) { if (n.routeName === action.routeName) {
navHistory[i] = Object.assign({}, action); navHistory[i] = { ...action };
} }
} }
newState = Object.assign({}, state); newState = { ...state };
newState.selectedNoteHash = ''; newState.selectedNoteHash = '';
@ -323,32 +321,32 @@ const appReducer = (state = appDefaultState, action: any) => {
case 'SIDE_MENU_TOGGLE': case 'SIDE_MENU_TOGGLE':
newState = Object.assign({}, state); newState = { ...state };
newState.showSideMenu = !newState.showSideMenu; newState.showSideMenu = !newState.showSideMenu;
break; break;
case 'SIDE_MENU_OPEN': case 'SIDE_MENU_OPEN':
newState = Object.assign({}, state); newState = { ...state };
newState.showSideMenu = true; newState.showSideMenu = true;
break; break;
case 'SIDE_MENU_CLOSE': case 'SIDE_MENU_CLOSE':
newState = Object.assign({}, state); newState = { ...state };
newState.showSideMenu = false; newState.showSideMenu = false;
break; break;
case 'SIDE_MENU_OPEN_PERCENT': case 'SIDE_MENU_OPEN_PERCENT':
newState = Object.assign({}, state); newState = { ...state };
newState.sideMenuOpenPercent = action.value; newState.sideMenuOpenPercent = action.value;
break; break;
case 'NOTE_SELECTION_TOGGLE': case 'NOTE_SELECTION_TOGGLE':
{ {
newState = Object.assign({}, state); newState = { ...state };
const noteId = action.id; const noteId = action.id;
const newSelectedNoteIds = state.selectedNoteIds.slice(); const newSelectedNoteIds = state.selectedNoteIds.slice();
@ -368,7 +366,7 @@ const appReducer = (state = appDefaultState, action: any) => {
case 'NOTE_SELECTION_START': case 'NOTE_SELECTION_START':
if (!state.noteSelectionEnabled) { if (!state.noteSelectionEnabled) {
newState = Object.assign({}, state); newState = { ...state };
newState.noteSelectionEnabled = true; newState.noteSelectionEnabled = true;
newState.selectedNoteIds = [action.id]; newState.selectedNoteIds = [action.id];
} }
@ -376,20 +374,20 @@ const appReducer = (state = appDefaultState, action: any) => {
case 'NOTE_SELECTION_END': case 'NOTE_SELECTION_END':
newState = Object.assign({}, state); newState = { ...state };
newState.noteSelectionEnabled = false; newState.noteSelectionEnabled = false;
newState.selectedNoteIds = []; newState.selectedNoteIds = [];
break; break;
case 'NOTE_SIDE_MENU_OPTIONS_SET': case 'NOTE_SIDE_MENU_OPTIONS_SET':
newState = Object.assign({}, state); newState = { ...state };
newState.noteSideMenuOptions = action.options; newState.noteSideMenuOptions = action.options;
break; break;
case 'MOBILE_DATA_WARNING_UPDATE': case 'MOBILE_DATA_WARNING_UPDATE':
newState = Object.assign({}, state); newState = { ...state };
newState.isOnMobileData = action.isOnMobileData; newState.isOnMobileData = action.isOnMobileData;
break; break;

View File

@ -251,7 +251,7 @@ function shimInit() {
await shim.fsDriver().copy(filePath, targetPath); await shim.fsDriver().copy(filePath, targetPath);
if (defaultProps) { if (defaultProps) {
resource = Object.assign({}, resource, defaultProps); resource = { ...resource, ...defaultProps };
} }
const itDoes = await shim.fsDriver().waitTillExists(targetPath); const itDoes = await shim.fsDriver().waitTillExists(targetPath);

View File

@ -100,7 +100,7 @@ module.exports = class extends Generator {
if (!derivedProps.packageName) derivedProps.packageName = defaultPackageName; if (!derivedProps.packageName) derivedProps.packageName = defaultPackageName;
this.props = Object.assign({}, initialProps, derivedProps); this.props = { ...initialProps, ...derivedProps };
} }
} }

View File

@ -25,9 +25,7 @@ const distDir = path.resolve(rootDir, 'dist');
const srcDir = path.resolve(rootDir, 'src'); const srcDir = path.resolve(rootDir, 'src');
const publishDir = path.resolve(rootDir, 'publish'); const publishDir = path.resolve(rootDir, 'publish');
const userConfig = Object.assign({}, { const userConfig = { extraScripts: [], ...(fs.pathExistsSync(userConfigPath) ? require(userConfigFilename) : {}) };
extraScripts: [],
}, fs.pathExistsSync(userConfigPath) ? require(userConfigFilename) : {});
const manifestPath = `${srcDir}/manifest.json`; const manifestPath = `${srcDir}/manifest.json`;
const packageJsonPath = `${rootDir}/package.json`; const packageJsonPath = `${rootDir}/package.json`;
@ -169,8 +167,7 @@ const baseConfig = {
}, },
}; };
const pluginConfig = Object.assign({}, baseConfig, { const pluginConfig = { ...baseConfig, entry: './src/index.ts',
entry: './src/index.ts',
resolve: { resolve: {
alias: { alias: {
api: path.resolve(__dirname, 'api'), api: path.resolve(__dirname, 'api'),
@ -202,18 +199,15 @@ const pluginConfig = Object.assign({}, baseConfig, {
}, },
], ],
}), }),
], ] };
});
const extraScriptConfig = Object.assign({}, baseConfig, { const extraScriptConfig = { ...baseConfig, resolve: {
resolve: {
alias: { alias: {
api: path.resolve(__dirname, 'api'), api: path.resolve(__dirname, 'api'),
}, },
fallback: moduleFallback, fallback: moduleFallback,
extensions: ['.js', '.tsx', '.ts', '.json'], extensions: ['.js', '.tsx', '.ts', '.json'],
}, } };
});
const createArchiveConfig = { const createArchiveConfig = {
stats: 'errors-only', stats: 'errors-only',
@ -261,10 +255,8 @@ function buildExtraScriptConfigs(userConfig) {
for (const scriptName of userConfig.extraScripts) { for (const scriptName of userConfig.extraScripts) {
const scriptPaths = resolveExtraScriptPath(scriptName); const scriptPaths = resolveExtraScriptPath(scriptName);
output.push(Object.assign({}, extraScriptConfig, { output.push({ ...extraScriptConfig, entry: scriptPaths.entry,
entry: scriptPaths.entry, output: scriptPaths.output });
output: scriptPaths.output,
}));
} }
return output; return output;

View File

@ -3,7 +3,7 @@ const slugify = require('slugify');
// "source" is the framework current version. // "source" is the framework current version.
// "dest" is the user existing version. // "dest" is the user existing version.
function mergePackageKey(parentKey, source, dest) { function mergePackageKey(parentKey, source, dest) {
const output = Object.assign({}, dest); const output = { ...dest };
for (const k in source) { for (const k in source) {
if (k === 'keywords' && !Array.isArray(output[k])) { if (k === 'keywords' && !Array.isArray(output[k])) {

View File

@ -145,7 +145,7 @@ export default class BaseApplication {
public switchCurrentFolder(folder: any) { public switchCurrentFolder(folder: any) {
if (!this.hasGui()) { if (!this.hasGui()) {
this.currentFolder_ = Object.assign({}, folder); this.currentFolder_ = { ...folder };
Setting.setValue('activeFolderId', folder ? folder.id : ''); Setting.setValue('activeFolderId', folder ? folder.id : '');
} else { } else {
this.dispatch({ this.dispatch({
@ -792,7 +792,7 @@ export default class BaseApplication {
await shim.fsDriver().removeAllThatStartWith(profileDir, 'edit-'); await shim.fsDriver().removeAllThatStartWith(profileDir, 'edit-');
const extraFlags = await this.readFlagsFromFile(`${profileDir}/flags.txt`); const extraFlags = await this.readFlagsFromFile(`${profileDir}/flags.txt`);
initArgs = Object.assign(initArgs, extraFlags); initArgs = { ...initArgs, ...extraFlags };

View File

@ -107,7 +107,7 @@ class BaseModel {
} }
return output; return output;
} else { } else {
model = Object.assign({}, model); model = { ...model };
model.type_ = this.modelType(); model.type_ = this.modelType();
return model; return model;
} }
@ -234,7 +234,7 @@ class BaseModel {
if (!options) { if (!options) {
options = {}; options = {};
} else { } else {
options = Object.assign({}, options); options = { ...options };
} }
if (!('isNew' in options)) options.isNew = 'auto'; if (!('isNew' in options)) options.isNew = 'auto';
if (!('autoTimestamp' in options)) options.autoTimestamp = true; if (!('autoTimestamp' in options)) options.autoTimestamp = true;
@ -509,7 +509,7 @@ class BaseModel {
query = Database.insertQuery(this.tableName(), o); query = Database.insertQuery(this.tableName(), o);
} else { } else {
const where = { id: o.id }; const where = { id: o.id };
const temp = Object.assign({}, o); const temp = { ...o };
delete temp.id; delete temp.id;
query = Database.updateQuery(this.tableName(), temp, where); query = Database.updateQuery(this.tableName(), temp, where);
@ -578,7 +578,7 @@ class BaseModel {
try { try {
await this.db().transactionExecBatch(queries); await this.db().transactionExecBatch(queries);
o = Object.assign({}, o); o = { ...o };
if (modelId) o.id = modelId; if (modelId) o.id = modelId;
if ('updated_time' in saveQuery.modObject) o.updated_time = saveQuery.modObject.updated_time; if ('updated_time' in saveQuery.modObject) o.updated_time = saveQuery.modObject.updated_time;
if ('created_time' in saveQuery.modObject) o.created_time = saveQuery.modObject.created_time; if ('created_time' in saveQuery.modObject) o.created_time = saveQuery.modObject.created_time;
@ -623,7 +623,7 @@ class BaseModel {
public static filter(model: any) { public static filter(model: any) {
if (!model) return model; if (!model) return model;
const output = Object.assign({}, model); const output = { ...model };
for (const n in output) { for (const n in output) {
if (!output.hasOwnProperty(n)) continue; if (!output.hasOwnProperty(n)) continue;

View File

@ -119,16 +119,14 @@ export default class ClipperServer {
this.server_.on('request', async (request: any, response: any) => { this.server_.on('request', async (request: any, response: any) => {
const writeCorsHeaders = (code: any, contentType = 'application/json', additionalHeaders: any = null) => { const writeCorsHeaders = (code: any, contentType = 'application/json', additionalHeaders: any = null) => {
const headers = Object.assign( const headers = {
{},
{
'Content-Type': contentType, 'Content-Type': contentType,
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS, PUT, PATCH, DELETE', 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS, PUT, PATCH, DELETE',
'Access-Control-Allow-Headers': 'X-Requested-With,content-type', 'Access-Control-Allow-Headers': 'X-Requested-With,content-type',
}, ...(additionalHeaders ? additionalHeaders : {}),
additionalHeaders ? additionalHeaders : {} };
);
response.writeHead(code, headers); response.writeHead(code, headers);
}; };

View File

@ -388,7 +388,7 @@ export default class Synchronizer {
const synchronizationId = time.unixMs().toString(); const synchronizationId = time.unixMs().toString();
const outputContext = Object.assign({}, lastContext); const outputContext = { ...lastContext };
this.progressReport_.startTime = time.unixMs(); this.progressReport_.startTime = time.unixMs();
@ -1036,7 +1036,7 @@ export default class Synchronizer {
// the update will simply be skipped. // the update will simply be skipped.
if (!hasCancelled) { if (!hasCancelled) {
if (options.saveContextHandler) { if (options.saveContextHandler) {
const deltaToSave = Object.assign({}, listResult.context); const deltaToSave = { ...listResult.context };
// Remove these two variables because they can be large and can be rebuilt // Remove these two variables because they can be large and can be rebuilt
// the next time the sync is started. // the next time the sync is started.
delete deltaToSave.statsCache; delete deltaToSave.statsCache;

View File

@ -24,12 +24,12 @@ class WebDavApi {
if (this.lastRequests_.length > 10) this.lastRequests_.splice(0, 1); if (this.lastRequests_.length > 10) this.lastRequests_.splice(0, 1);
const serializeRequest = (r) => { const serializeRequest = (r) => {
const options = Object.assign({}, r.options); const options = { ...r.options };
if (typeof options.body === 'string') options.body = options.body.substr(0, 4096); if (typeof options.body === 'string') options.body = options.body.substr(0, 4096);
const output = []; const output = [];
output.push(options.method ? options.method : 'GET'); output.push(options.method ? options.method : 'GET');
output.push(r.url); output.push(r.url);
options.headers = Object.assign({}, options.headers); options.headers = { ...options.headers };
if (options.headers['Authorization']) options.headers['Authorization'] = '********'; if (options.headers['Authorization']) options.headers['Authorization'] = '********';
delete options.method; delete options.method;
delete options.agent; delete options.agent;
@ -335,8 +335,8 @@ class WebDavApi {
// </d:propfind>' // </d:propfind>'
async exec(method, path = '', body = null, headers = null, options = null) { async exec(method, path = '', body = null, headers = null, options = null) {
headers = Object.assign({}, headers); headers = { ...headers };
options = Object.assign({}, options); options = { ...options };
if (!options.responseFormat) options.responseFormat = 'json'; if (!options.responseFormat) options.responseFormat = 'json';
if (!options.target) options.target = 'string'; if (!options.target) options.target = 'string';

View File

@ -44,9 +44,9 @@ shared.checkSyncConfig = async function(comp, settings) {
const syncTargetId = settings['sync.target']; const syncTargetId = settings['sync.target'];
const SyncTargetClass = SyncTargetRegistry.classById(syncTargetId); const SyncTargetClass = SyncTargetRegistry.classById(syncTargetId);
const options = Object.assign({}, const options = {
Setting.subValues(`sync.${syncTargetId}`, settings), ...Setting.subValues(`sync.${syncTargetId}`, settings),
Setting.subValues('net', settings)); ...Setting.subValues('net', settings) };
comp.setState({ checkSyncConfigResult: 'checking' }); comp.setState({ checkSyncConfigResult: 'checking' });
const result = await SyncTargetClass.checkConfig(ObjectUtils.convertValuesToFunctions(options)); const result = await SyncTargetClass.checkConfig(ObjectUtils.convertValuesToFunctions(options));
@ -92,7 +92,7 @@ shared.updateSettingValue = function(comp, key, value, callback = null) {
return {}; return {};
} }
const settings = Object.assign({}, state.settings); const settings = { ...state.settings };
const changedSettingKeys = state.changedSettingKeys.slice(); const changedSettingKeys = state.changedSettingKeys.slice();
settings[key] = Setting.formatValue(key, value); settings[key] = Setting.formatValue(key, value);
if (changedSettingKeys.indexOf(key) < 0) changedSettingKeys.push(key); if (changedSettingKeys.indexOf(key) < 0) changedSettingKeys.push(key);

View File

@ -44,7 +44,7 @@ shared.handleNoteDeletedWhileEditing_ = async (note: NoteEntity) => {
reg.logger().info('Note has been deleted while it was being edited - recreating it.'); reg.logger().info('Note has been deleted while it was being edited - recreating it.');
let newNote = Object.assign({}, note); let newNote = { ...note };
delete newNote.id; delete newNote.id;
newNote = await Note.save(newNote); newNote = await Note.save(newNote);
@ -52,13 +52,11 @@ shared.handleNoteDeletedWhileEditing_ = async (note: NoteEntity) => {
}; };
shared.saveNoteButton_press = async function(comp: any, folderId: string = null, options: any = null) { shared.saveNoteButton_press = async function(comp: any, folderId: string = null, options: any = null) {
options = Object.assign({}, { options = { autoTitle: true, ...options };
autoTitle: true,
}, options);
const releaseMutex = await saveNoteMutex_.acquire(); const releaseMutex = await saveNoteMutex_.acquire();
let note = Object.assign({}, comp.state.note); let note = { ...comp.state.note };
const recreatedNote = await shared.handleNoteDeletedWhileEditing_(note); const recreatedNote = await shared.handleNoteDeletedWhileEditing_(note);
if (recreatedNote) note = recreatedNote; if (recreatedNote) note = recreatedNote;
@ -86,7 +84,7 @@ shared.saveNoteButton_press = async function(comp: any, folderId: string = null,
if (saveOptions.fields && saveOptions.fields.indexOf('title') < 0) saveOptions.fields.push('title'); if (saveOptions.fields && saveOptions.fields.indexOf('title') < 0) saveOptions.fields.push('title');
} }
const savedNote = 'fields' in saveOptions && !saveOptions.fields.length ? Object.assign({}, note) : await Note.save(note, saveOptions); const savedNote = 'fields' in saveOptions && !saveOptions.fields.length ? { ...note } : await Note.save(note, saveOptions);
const stateNote = comp.state.note; const stateNote = comp.state.note;
@ -94,7 +92,7 @@ shared.saveNoteButton_press = async function(comp: any, folderId: string = null,
if (!recreatedNote && (!stateNote || stateNote.id !== savedNote.id)) return releaseMutex(); if (!recreatedNote && (!stateNote || stateNote.id !== savedNote.id)) return releaseMutex();
// Re-assign any property that might have changed during saving (updated_time, etc.) // Re-assign any property that might have changed during saving (updated_time, etc.)
note = Object.assign(note, savedNote); note = { ...note, ...savedNote };
if (stateNote.id === note.id) { if (stateNote.id === note.id) {
// But we preserve the current title and body because // But we preserve the current title and body because
@ -109,7 +107,7 @@ shared.saveNoteButton_press = async function(comp: any, folderId: string = null,
} }
const newState: any = { const newState: any = {
lastSavedNote: Object.assign({}, note), lastSavedNote: { ...note },
note: note, note: note,
}; };
@ -136,8 +134,8 @@ shared.saveNoteButton_press = async function(comp: any, folderId: string = null,
altitude: geoNote.altitude, altitude: geoNote.altitude,
}; };
const modNote = Object.assign({}, stateNote, geoInfo); const modNote = { ...stateNote, ...geoInfo };
const modLastSavedNote = Object.assign({}, comp.state.lastSavedNote, geoInfo); const modLastSavedNote = { ...comp.state.lastSavedNote, ...geoInfo };
comp.setState({ note: modNote, lastSavedNote: modLastSavedNote }); comp.setState({ note: modNote, lastSavedNote: modLastSavedNote });
}; };
@ -150,7 +148,7 @@ shared.saveNoteButton_press = async function(comp: any, folderId: string = null,
}; };
shared.saveOneProperty = async function(comp: any, name: string, value: any) { shared.saveOneProperty = async function(comp: any, name: string, value: any) {
let note = Object.assign({}, comp.state.note); let note = { ...comp.state.note };
const recreatedNote = await shared.handleNoteDeletedWhileEditing_(note); const recreatedNote = await shared.handleNoteDeletedWhileEditing_(note);
if (recreatedNote) note = recreatedNote; if (recreatedNote) note = recreatedNote;
@ -161,7 +159,7 @@ shared.saveOneProperty = async function(comp: any, name: string, value: any) {
note[name] = toSave[name]; note[name] = toSave[name];
comp.setState({ comp.setState({
lastSavedNote: Object.assign({}, note), lastSavedNote: { ...note },
note: note, note: note,
}); });
}; };
@ -169,7 +167,7 @@ shared.saveOneProperty = async function(comp: any, name: string, value: any) {
shared.noteComponent_change = function(comp: any, propName: string, propValue: any) { shared.noteComponent_change = function(comp: any, propName: string, propValue: any) {
const newState: any = {}; const newState: any = {};
const note = Object.assign({}, comp.state.note); const note = { ...comp.state.note };
note[propName] = propValue; note[propName] = propValue;
newState.note = note; newState.note = note;
@ -231,7 +229,7 @@ shared.initState = async function(comp: any) {
const folder = Folder.byId(comp.props.folders, note.parent_id); const folder = Folder.byId(comp.props.folders, note.parent_id);
comp.setState({ comp.setState({
lastSavedNote: Object.assign({}, note), lastSavedNote: { ...note },
note: note, note: note,
mode: mode, mode: mode,
folder: folder, folder: folder,

View File

@ -57,7 +57,7 @@ export default class FileApiDriverMemory {
public stat(path: string) { public stat(path: string) {
const item = this.itemByPath(path); const item = this.itemByPath(path);
return Promise.resolve(item ? Object.assign({}, item) : null); return Promise.resolve(item ? { ...item } : null);
} }
public async setTimestamp(path: string, timestampMs: number): Promise<any> { public async setTimestamp(path: string, timestampMs: number): Promise<any> {
@ -75,7 +75,7 @@ export default class FileApiDriverMemory {
if (item.path.indexOf(`${path}/`) === 0) { if (item.path.indexOf(`${path}/`) === 0) {
const s = item.path.substr(path.length + 1); const s = item.path.substr(path.length + 1);
if (s.split('/').length === 1) { if (s.split('/').length === 1) {
const it = Object.assign({}, item); const it = { ...item };
it.path = it.path.substr(path.length + 1); it.path = it.path.substr(path.length + 1);
output.push(it); output.push(it);
} }
@ -155,7 +155,7 @@ export default class FileApiDriverMemory {
public async delete(path: string) { public async delete(path: string) {
const index = this.itemIndexByPath(path); const index = this.itemIndexByPath(path);
if (index >= 0) { if (index >= 0) {
const item = Object.assign({}, this.items_[index]); const item = { ...this.items_[index] };
item.isDeleted = true; item.isDeleted = true;
item.updated_time = time.unixMs(); item.updated_time = time.unixMs();
this.deletedItems_.push(item); this.deletedItems_.push(item);
@ -178,7 +178,7 @@ export default class FileApiDriverMemory {
const getStatFn = async (path: string) => { const getStatFn = async (path: string) => {
const output = this.items_.slice(); const output = this.items_.slice();
for (let i = 0; i < output.length; i++) { for (let i = 0; i < output.length; i++) {
const item = Object.assign({}, output[i]); const item = { ...output[i] };
item.path = item.path.substr(path.length + 1); item.path = item.path.substr(path.length + 1);
output[i] = item; output[i] = item;
} }

View File

@ -80,11 +80,9 @@ class FileApiDriverOneDrive {
} }
async list(path, options = null) { async list(path, options = null) {
options = Object.assign({}, { options = { context: null, ...options };
context: null,
}, options);
let query = Object.assign({}, this.itemFilter_(), { '$top': 1000 }); let query = { ...this.itemFilter_(), '$top': 1000 };
let url = `${this.makePath_(path)}:/children`; let url = `${this.makePath_(path)}:/children`;
if (options.context) { if (options.context) {

View File

@ -6,9 +6,8 @@ class FoldersScreenUtils {
static async allForDisplay(options = {}) { static async allForDisplay(options = {}) {
const orderDir = Setting.value('folders.sortOrder.reverse') ? 'DESC' : 'ASC'; const orderDir = Setting.value('folders.sortOrder.reverse') ? 'DESC' : 'ASC';
const folderOptions = Object.assign( const folderOptions = {
{},
{
caseInsensitive: true, caseInsensitive: true,
order: [ order: [
{ {
@ -16,9 +15,8 @@ class FoldersScreenUtils {
dir: orderDir, dir: orderDir,
}, },
], ],
}, ...options,
options };
);
let folders = await Folder.all(folderOptions); let folders = await Folder.all(folderOptions);

View File

@ -103,7 +103,7 @@ function enexXmlToHtml_(stream, resources) {
for (let i = 0; i < remainingResources.length; i++) { for (let i = 0; i < remainingResources.length; i++) {
const r = remainingResources[i]; const r = remainingResources[i];
if (!r.id) { if (!r.id) {
resource = Object.assign({}, r); resource = { ...r };
resource.id = hash; resource.id = hash;
remainingResources.splice(i, 1); remainingResources.splice(i, 1);
found = true; found = true;

View File

@ -884,7 +884,7 @@ function enexXmlToMdArray(stream: any, resources: ResourceEntity[]): Promise<Ene
for (let i = 0; i < remainingResources.length; i++) { for (let i = 0; i < remainingResources.length; i++) {
const r = remainingResources[i]; const r = remainingResources[i];
if (!r.id) { if (!r.id) {
resource = Object.assign({}, r); resource = { ...r };
resource.id = hash; resource.id = hash;
remainingResources.splice(i, 1); remainingResources.splice(i, 1);
found = true; found = true;

View File

@ -175,7 +175,7 @@ async function processNoteResource(resource: ExtractedResource) {
} }
if (!resource.id || !resource.size) { if (!resource.id || !resource.size) {
const debugTemp = Object.assign({}, resource); const debugTemp = { ...resource };
debugTemp.data = debugTemp.data ? `${debugTemp.data.substr(0, 32)}...` : debugTemp.data; debugTemp.data = debugTemp.data ? `${debugTemp.data.substr(0, 32)}...` : debugTemp.data;
throw new Error(`This resource was not added because it has no ID or no content: ${JSON.stringify(debugTemp)}`); throw new Error(`This resource was not added because it has no ID or no content: ${JSON.stringify(debugTemp)}`);
} }
@ -189,7 +189,7 @@ async function saveNoteResources(note: ExtractedNote) {
for (let i = 0; i < note.resources.length; i++) { for (let i = 0; i < note.resources.length; i++) {
const resource = note.resources[i]; const resource = note.resources[i];
const toSave = Object.assign({}, resource); const toSave = { ...resource };
delete toSave.dataFilePath; delete toSave.dataFilePath;
delete toSave.dataEncoding; delete toSave.dataEncoding;
delete toSave.hasData; delete toSave.hasData;
@ -230,9 +230,7 @@ interface ImportOptions {
} }
async function saveNoteToStorage(note: ExtractedNote, importOptions: ImportOptions) { async function saveNoteToStorage(note: ExtractedNote, importOptions: ImportOptions) {
importOptions = Object.assign({}, { importOptions = { fuzzyMatching: false, ...importOptions };
fuzzyMatching: false,
}, importOptions);
note = Note.filter(note as any); note = Note.filter(note as any);

View File

@ -559,7 +559,7 @@ function localeStrings(canonicalName: string) {
if (loadedLocales_[locale]) return loadedLocales_[locale]; if (loadedLocales_[locale]) return loadedLocales_[locale];
loadedLocales_[locale] = Object.assign({}, supportedLocales_[locale]); loadedLocales_[locale] = { ...supportedLocales_[locale] };
return loadedLocales_[locale]; return loadedLocales_[locale];
} }

View File

@ -40,9 +40,8 @@ markJsUtils.markKeyword = (mark, keyword, stringUtils, extraOptions = null) => {
mark.mark( mark.mark(
[value], [value],
Object.assign(
{},
{ {
accuracy: accuracy, accuracy: accuracy,
filter: (node, _term, _totalCounter, _counter) => { filter: (node, _term, _totalCounter, _counter) => {
// We exclude SVG because it creates a "<mark>" tag inside // We exclude SVG because it creates a "<mark>" tag inside
@ -56,9 +55,8 @@ markJsUtils.markKeyword = (mark, keyword, stringUtils, extraOptions = null) => {
if (isInsideContainer(node, 'SVG')) return false; if (isInsideContainer(node, 'SVG')) return false;
return true; return true;
}, },
}, ...extraOptions,
extraOptions }
)
); );
}; };

View File

@ -48,13 +48,11 @@ export class MarkupLanguageUtils {
pluginOptions[n] = { enabled: subValues[n] }; pluginOptions[n] = { enabled: subValues[n] };
} }
options = Object.assign({ options = { ResourceModel: Resource,
ResourceModel: Resource,
pluginOptions: pluginOptions, pluginOptions: pluginOptions,
tempDir: Setting.value('tempDir'), tempDir: Setting.value('tempDir'),
fsDriver: shim.fsDriver(), fsDriver: shim.fsDriver(),
isSafeMode: Setting.value('isSafeMode'), isSafeMode: Setting.value('isSafeMode'), ...options };
}, options);
return new MarkupToHtml(options); return new MarkupToHtml(options);
} }

View File

@ -44,9 +44,7 @@ export default class Folder extends BaseItem {
} }
public static noteIds(parentId: string, options: any = null) { public static noteIds(parentId: string, options: any = null) {
options = Object.assign({}, { options = { includeConflicts: false, ...options };
includeConflicts: false,
}, options);
const where = ['parent_id = ?']; const where = ['parent_id = ?'];
if (!options.includeConflicts) { if (!options.includeConflicts) {
@ -619,7 +617,7 @@ export default class Folder extends BaseItem {
public static buildTree(folders: FolderEntity[]): FolderEntityWithChildren[] { public static buildTree(folders: FolderEntity[]): FolderEntityWithChildren[] {
const idToFolders: Record<string, any> = {}; const idToFolders: Record<string, any> = {};
for (let i = 0; i < folders.length; i++) { for (let i = 0; i < folders.length; i++) {
idToFolders[folders[i].id] = Object.assign({}, folders[i]); idToFolders[folders[i].id] = { ...folders[i] };
idToFolders[folders[i].id].children = []; idToFolders[folders[i].id].children = [];
} }

View File

@ -62,7 +62,7 @@ export default class Note extends BaseItem {
} }
public static minimalSerializeForDisplay(note: NoteEntity) { public static minimalSerializeForDisplay(note: NoteEntity) {
const n = Object.assign({}, note); const n = { ...note };
const fieldNames = this.fieldNames(); const fieldNames = this.fieldNames();
@ -146,9 +146,7 @@ export default class Note extends BaseItem {
} }
public static async replaceResourceInternalToExternalLinks(body: string, options: any = null) { public static async replaceResourceInternalToExternalLinks(body: string, options: any = null) {
options = Object.assign({}, { options = { useAbsolutePaths: false, ...options };
useAbsolutePaths: false,
}, options);
// this.logger().debug('replaceResourceInternalToExternalLinks', 'options:', options, 'body:', body); // this.logger().debug('replaceResourceInternalToExternalLinks', 'options:', options, 'body:', body);
@ -176,9 +174,7 @@ export default class Note extends BaseItem {
} }
public static async replaceResourceExternalToInternalLinks(body: string, options: any = null) { public static async replaceResourceExternalToInternalLinks(body: string, options: any = null) {
options = Object.assign({}, { options = { useAbsolutePaths: false, ...options };
useAbsolutePaths: false,
}, options);
const resourceDir = toForwardSlashes(Setting.value('resourceDir')); const resourceDir = toForwardSlashes(Setting.value('resourceDir'));
@ -313,9 +309,7 @@ export default class Note extends BaseItem {
} }
public static previewFields(options: any = null) { public static previewFields(options: any = null) {
options = Object.assign({ options = { includeTimestamps: true, ...options };
includeTimestamps: true,
}, options);
const output = ['id', 'title', 'is_todo', 'todo_completed', 'todo_due', 'parent_id', 'encryption_applied', 'order', 'markup_language', 'is_conflict', 'is_shared']; const output = ['id', 'title', 'is_todo', 'todo_completed', 'todo_due', 'parent_id', 'encryption_applied', 'order', 'markup_language', 'is_conflict', 'is_shared'];
@ -400,7 +394,7 @@ export default class Note extends BaseItem {
let cond = options.conditions.slice(); let cond = options.conditions.slice();
cond.push('is_todo = 1'); cond.push('is_todo = 1');
cond.push('(todo_completed <= 0 OR todo_completed IS NULL)'); cond.push('(todo_completed <= 0 OR todo_completed IS NULL)');
let tempOptions = Object.assign({}, options); let tempOptions = { ...options };
tempOptions.conditions = cond; tempOptions.conditions = cond;
const uncompletedTodos = await this.search(tempOptions); const uncompletedTodos = await this.search(tempOptions);
@ -413,7 +407,7 @@ export default class Note extends BaseItem {
cond.push('(is_todo = 1 AND todo_completed > 0)'); cond.push('(is_todo = 1 AND todo_completed > 0)');
} }
tempOptions = Object.assign({}, options); tempOptions = { ...options };
tempOptions.conditions = cond; tempOptions.conditions = cond;
if ('limit' in tempOptions) tempOptions.limit -= uncompletedTodos.length; if ('limit' in tempOptions) tempOptions.limit -= uncompletedTodos.length;
const theRest = await this.search(tempOptions); const theRest = await this.search(tempOptions);
@ -485,7 +479,7 @@ export default class Note extends BaseItem {
let geoData = null; let geoData = null;
if (this.geolocationCache_ && this.geolocationCache_.timestamp + 1000 * 60 * 10 > time.unixMs()) { if (this.geolocationCache_ && this.geolocationCache_.timestamp + 1000 * 60 * 10 > time.unixMs()) {
geoData = Object.assign({}, this.geolocationCache_); geoData = { ...this.geolocationCache_ };
} else { } else {
this.geolocationUpdating_ = true; this.geolocationUpdating_ = true;
@ -564,7 +558,7 @@ export default class Note extends BaseItem {
if (Number(note.is_todo) === newIsTodo) return note; if (Number(note.is_todo) === newIsTodo) return note;
const output = Object.assign({}, note); const output = { ...note };
output.is_todo = newIsTodo; output.is_todo = newIsTodo;
output.todo_due = 0; output.todo_due = 0;
output.todo_completed = 0; output.todo_completed = 0;
@ -579,7 +573,7 @@ export default class Note extends BaseItem {
public static toggleTodoCompleted(note: NoteEntity) { public static toggleTodoCompleted(note: NoteEntity) {
if (!('todo_completed' in note)) throw new Error('Missing "todo_completed" property'); if (!('todo_completed' in note)) throw new Error('Missing "todo_completed" property');
note = Object.assign({}, note); note = { ...note };
if (note.todo_completed) { if (note.todo_completed) {
note.todo_completed = 0; note.todo_completed = 0;
} else { } else {
@ -627,7 +621,7 @@ export default class Note extends BaseItem {
const originalNote: NoteEntity = await Note.load(noteId); const originalNote: NoteEntity = await Note.load(noteId);
if (!originalNote) throw new Error(`Unknown note: ${noteId}`); if (!originalNote) throw new Error(`Unknown note: ${noteId}`);
const newNote = Object.assign({}, originalNote); const newNote = { ...originalNote };
const fieldsToReset = ['id', 'created_time', 'updated_time', 'user_created_time', 'user_updated_time']; const fieldsToReset = ['id', 'created_time', 'updated_time', 'user_created_time', 'user_updated_time'];
for (const field of fieldsToReset) { for (const field of fieldsToReset) {
@ -825,11 +819,9 @@ export default class Note extends BaseItem {
// Update the note "order" field without changing the user timestamps, // Update the note "order" field without changing the user timestamps,
// which is generally what we want. // which is generally what we want.
private static async updateNoteOrder_(note: NoteEntity, order: any) { private static async updateNoteOrder_(note: NoteEntity, order: any) {
return Note.save(Object.assign({}, note, { return Note.save({ ...note, order: order,
order: order,
user_updated_time: note.user_updated_time, user_updated_time: note.user_updated_time,
updated_time: time.unixMs(), updated_time: time.unixMs() }, { autoTimestamp: false, dispatchUpdateAction: false });
}), { autoTimestamp: false, dispatchUpdateAction: false });
} }
// This method will disable the NOTE_UPDATE_ONE action to prevent a lot // This method will disable the NOTE_UPDATE_ONE action to prevent a lot
@ -957,7 +949,7 @@ export default class Note extends BaseItem {
if (n.order <= previousOrder) { if (n.order <= previousOrder) {
const o = previousOrder + defaultIntevalBetweeNotes; const o = previousOrder + defaultIntevalBetweeNotes;
const updatedNote = await this.updateNoteOrder_(n, o); const updatedNote = await this.updateNoteOrder_(n, o);
notes[i] = Object.assign({}, n, updatedNote); notes[i] = { ...n, ...updatedNote };
previousOrder = o; previousOrder = o;
} else { } else {
previousOrder = n.order; previousOrder = n.order;
@ -1003,7 +995,7 @@ export default class Note extends BaseItem {
public static async createConflictNote(sourceNote: NoteEntity, changeSource: number): Promise<NoteEntity> { public static async createConflictNote(sourceNote: NoteEntity, changeSource: number): Promise<NoteEntity> {
const conflictNote = Object.assign({}, sourceNote); const conflictNote = { ...sourceNote };
delete conflictNote.id; delete conflictNote.id;
conflictNote.is_conflict = 1; conflictNote.is_conflict = 1;
conflictNote.conflict_original_id = sourceNote.id; conflictNote.conflict_original_id = sourceNote.id;

View File

@ -157,7 +157,7 @@ export default class Resource extends BaseItem {
public static async decrypt(item: ResourceEntity) { public static async decrypt(item: ResourceEntity) {
// The item might already be decrypted but not the blob (for instance if it crashes while // The item might already be decrypted but not the blob (for instance if it crashes while
// decrypting the blob or was otherwise interrupted). // decrypting the blob or was otherwise interrupted).
const decryptedItem = item.encryption_cipher_text ? await super.decrypt(item) : Object.assign({}, item); const decryptedItem = item.encryption_cipher_text ? await super.decrypt(item) : { ...item };
if (!decryptedItem.encryption_blob_encrypted) return decryptedItem; if (!decryptedItem.encryption_blob_encrypted) return decryptedItem;
const localState = await this.localState(item); const localState = await this.localState(item);
@ -225,7 +225,7 @@ export default class Resource extends BaseItem {
throw error; throw error;
} }
const resourceCopy = Object.assign({}, resource); const resourceCopy = { ...resource };
resourceCopy.encryption_blob_encrypted = 1; resourceCopy.encryption_blob_encrypted = 1;
return { path: encryptedPath, resource: resourceCopy }; return { path: encryptedPath, resource: resourceCopy };
} }
@ -273,7 +273,7 @@ export default class Resource extends BaseItem {
public static async setLocalState(resourceOrId: any, state: ResourceLocalStateEntity) { public static async setLocalState(resourceOrId: any, state: ResourceLocalStateEntity) {
const id = typeof resourceOrId === 'object' ? resourceOrId.id : resourceOrId; const id = typeof resourceOrId === 'object' ? resourceOrId.id : resourceOrId;
await ResourceLocalState.save(Object.assign({}, state, { resource_id: id })); await ResourceLocalState.save({ ...state, resource_id: id });
} }
public static async needFileSizeSet() { public static async needFileSizeSet() {

View File

@ -33,7 +33,7 @@ export default class ResourceLocalState extends BaseModel {
} }
public static batchDelete(ids: string[], options: any = null) { public static batchDelete(ids: string[], options: any = null) {
options = options ? Object.assign({}, options) : {}; options = options ? { ...options } : {};
options.idFieldName = 'resource_id'; options.idFieldName = 'resource_id';
return super.batchDelete(ids, options); return super.batchDelete(ids, options);
} }

View File

@ -113,7 +113,7 @@ export default class Revision extends BaseItem {
public static applyObjectPatch(object: any, patch: string) { public static applyObjectPatch(object: any, patch: string) {
const parsedPatch: ObjectPatch = JSON.parse(this.sanitizeObjectPatch(patch)); const parsedPatch: ObjectPatch = JSON.parse(this.sanitizeObjectPatch(patch));
const output = Object.assign({}, object); const output = { ...object };
for (const k in parsedPatch.new) { for (const k in parsedPatch.new) {
output[k] = parsedPatch.new[k]; output[k] = parsedPatch.new[k];

View File

@ -1700,7 +1700,7 @@ class Setting extends BaseModel {
this.metadata_ = { ...this.buildInMetadata_ }; this.metadata_ = { ...this.buildInMetadata_ };
this.metadata_ = Object.assign(this.metadata_, this.customMetadata_); this.metadata_ = { ...this.metadata_, ...this.customMetadata_ };
if (this.constants_.env === Env.Dev) this.validateMetadata(this.metadata_); if (this.constants_.env === Env.Dev) this.validateMetadata(this.metadata_);
@ -1819,7 +1819,7 @@ class Setting extends BaseModel {
public static settingMetadata(key: string): SettingItem { public static settingMetadata(key: string): SettingItem {
const metadata = this.metadata(); const metadata = this.metadata();
if (!(key in metadata)) throw new JoplinError(`Unknown key: ${key}`, 'unknown_key'); if (!(key in metadata)) throw new JoplinError(`Unknown key: ${key}`, 'unknown_key');
const output = Object.assign({}, metadata[key]); const output = { ...metadata[key] };
output.key = key; output.key = key;
return output; return output;
} }
@ -1849,9 +1849,7 @@ class Setting extends BaseModel {
} }
public static keys(publicOnly: boolean = false, appType: AppType = null, options: KeysOptions = null) { public static keys(publicOnly: boolean = false, appType: AppType = null, options: KeysOptions = null) {
options = Object.assign({}, { options = { secureOnly: false, ...options };
secureOnly: false,
}, options);
if (!this.keys_) { if (!this.keys_) {
const metadata = this.metadata(); const metadata = this.metadata();
@ -2209,7 +2207,7 @@ class Setting extends BaseModel {
function copyIfNeeded(value: any) { function copyIfNeeded(value: any) {
if (value === null || value === undefined) return value; if (value === null || value === undefined) return value;
if (Array.isArray(value)) return value.slice(); if (Array.isArray(value)) return value.slice();
if (typeof value === 'object') return Object.assign({}, value); if (typeof value === 'object') return { ...value };
return value; return value;
} }
@ -2317,7 +2315,7 @@ class Setting extends BaseModel {
queries.push(`DELETE FROM settings WHERE key IN ("${keys.join('","')}")`); queries.push(`DELETE FROM settings WHERE key IN ("${keys.join('","')}")`);
for (let i = 0; i < this.cache_.length; i++) { for (let i = 0; i < this.cache_.length; i++) {
const s = Object.assign({}, this.cache_[i]); const s = { ...this.cache_[i] };
const valueAsString = this.valueToString(s.key, s.value); const valueAsString = this.valueToString(s.key, s.value);
if (this.isSecureKey(s.key)) { if (this.isSecureKey(s.key)) {
@ -2441,7 +2439,7 @@ class Setting extends BaseModel {
const output: any = {}; const output: any = {};
for (const key in metadata) { for (const key in metadata) {
if (!metadata.hasOwnProperty(key)) continue; if (!metadata.hasOwnProperty(key)) continue;
const s = Object.assign({}, metadata[key]); const s = { ...metadata[key] };
if (!s.public) continue; if (!s.public) continue;
if (s.appTypes && s.appTypes.indexOf(appType) < 0) continue; if (s.appTypes && s.appTypes.indexOf(appType) < 0) continue;
s.value = this.value(key); s.value = this.value(key);

View File

@ -32,9 +32,7 @@ export default class Tag extends BaseItem {
return Note.previews( return Note.previews(
null, null,
Object.assign({}, options, { { ...options, conditions: [`id IN ("${noteIds.join('","')}")`] }
conditions: [`id IN ("${noteIds.join('","')}")`],
})
); );
} }
@ -191,10 +189,8 @@ export default class Tag extends BaseItem {
} }
public static async save(o: TagEntity, options: any = null) { public static async save(o: TagEntity, options: any = null) {
options = Object.assign({}, { options = { dispatchUpdateAction: true,
dispatchUpdateAction: true, userSideValidation: false, ...options };
userSideValidation: false,
}, options);
if (options.userSideValidation) { if (options.userSideValidation) {
if ('title' in o) { if ('title' in o) {

View File

@ -141,7 +141,7 @@ export default class OneDriveApi {
} }
public async uploadChunk(url: string, handle: any, buffer: any, options: any) { public async uploadChunk(url: string, handle: any, buffer: any, options: any) {
options = Object.assign({}, options); options = { ...options };
if (!options.method) { options.method = 'POST'; } if (!options.method) { options.method = 'POST'; }
if (!options.contentLength) throw new Error('uploadChunk: contentLength is missing'); if (!options.contentLength) throw new Error('uploadChunk: contentLength is missing');

View File

@ -421,7 +421,7 @@ function updateOneItem(draft: Draft<State>, action: any, keyName: string = '') {
for (let i = 0; i < newItems.length; i++) { for (let i = 0; i < newItems.length; i++) {
const n = newItems[i]; const n = newItems[i];
if (n.id === item.id) { if (n.id === item.id) {
newItems[i] = Object.assign({}, newItems[i], item); newItems[i] = { ...newItems[i], ...item };
found = true; found = true;
break; break;
} }
@ -474,11 +474,11 @@ function changeSelectedFolder(draft: Draft<State>, action: any, options: any = n
} }
function recordLastSelectedNoteIds(draft: Draft<State>, noteIds: string[]) { function recordLastSelectedNoteIds(draft: Draft<State>, noteIds: string[]) {
const newOnes: any = Object.assign({}, draft.lastSelectedNotesIds); const newOnes: any = { ...draft.lastSelectedNotesIds };
const parent = stateUtils.parentItem(draft); const parent = stateUtils.parentItem(draft);
if (!parent) return; if (!parent) return;
newOnes[parent.type] = Object.assign({}, newOnes[parent.type]); newOnes[parent.type] = { ...newOnes[parent.type] };
newOnes[parent.type][parent.id] = noteIds.slice(); newOnes[parent.type][parent.id] = noteIds.slice();
draft.lastSelectedNotesIds = newOnes; draft.lastSelectedNotesIds = newOnes;
@ -583,8 +583,8 @@ function handleHistory(draft: Draft<State>, action: any) {
draft.forwardHistoryNotes = draft.forwardHistoryNotes.concat(currentNote).slice(-MAX_HISTORY); draft.forwardHistoryNotes = draft.forwardHistoryNotes.concat(currentNote).slice(-MAX_HISTORY);
} }
changeSelectedFolder(draft, Object.assign({}, action, { type: 'FOLDER_SELECT', folderId: note.parent_id })); changeSelectedFolder(draft, { ...action, type: 'FOLDER_SELECT', folderId: note.parent_id });
changeSelectedNotes(draft, Object.assign({}, action, { type: 'NOTE_SELECT', noteId: note.id })); changeSelectedNotes(draft, { ...action, type: 'NOTE_SELECT', noteId: note.id });
const ctx = draft.backwardHistoryNotes[draft.backwardHistoryNotes.length - 1]; const ctx = draft.backwardHistoryNotes[draft.backwardHistoryNotes.length - 1];
Object.assign(draft, getContextFromHistory(ctx)); Object.assign(draft, getContextFromHistory(ctx));
@ -599,8 +599,8 @@ function handleHistory(draft: Draft<State>, action: any) {
draft.backwardHistoryNotes = draft.backwardHistoryNotes.concat(currentNote).slice(-MAX_HISTORY); draft.backwardHistoryNotes = draft.backwardHistoryNotes.concat(currentNote).slice(-MAX_HISTORY);
} }
changeSelectedFolder(draft, Object.assign({}, action, { type: 'FOLDER_SELECT', folderId: note.parent_id })); changeSelectedFolder(draft, { ...action, type: 'FOLDER_SELECT', folderId: note.parent_id });
changeSelectedNotes(draft, Object.assign({}, action, { type: 'NOTE_SELECT', noteId: note.id })); changeSelectedNotes(draft, { ...action, type: 'NOTE_SELECT', noteId: note.id });
const ctx = draft.forwardHistoryNotes[draft.forwardHistoryNotes.length - 1]; const ctx = draft.forwardHistoryNotes[draft.forwardHistoryNotes.length - 1];
Object.assign(draft, getContextFromHistory(ctx)); Object.assign(draft, getContextFromHistory(ctx));
@ -633,14 +633,14 @@ function handleHistory(draft: Draft<State>, action: any) {
draft.backwardHistoryNotes = draft.backwardHistoryNotes.map(note => { draft.backwardHistoryNotes = draft.backwardHistoryNotes.map(note => {
if (note.id === modNote.id) { if (note.id === modNote.id) {
return Object.assign({}, note, { parent_id: modNote.parent_id, selectedFolderId: modNote.parent_id }); return { ...note, parent_id: modNote.parent_id, selectedFolderId: modNote.parent_id };
} }
return note; return note;
}); });
draft.forwardHistoryNotes = draft.forwardHistoryNotes.map(note => { draft.forwardHistoryNotes = draft.forwardHistoryNotes.map(note => {
if (note.id === modNote.id) { if (note.id === modNote.id) {
return Object.assign({}, note, { parent_id: modNote.parent_id, selectedFolderId: modNote.parent_id }); return { ...note, parent_id: modNote.parent_id, selectedFolderId: modNote.parent_id };
} }
return note; return note;
}); });
@ -763,7 +763,7 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
case 'FOLDER_AND_NOTE_SELECT': case 'FOLDER_AND_NOTE_SELECT':
{ {
changeSelectedFolder(draft, action); changeSelectedFolder(draft, action);
const noteSelectAction = Object.assign({}, action, { type: 'NOTE_SELECT' }); const noteSelectAction = { ...action, type: 'NOTE_SELECT' };
changeSelectedNotes(draft, noteSelectAction); changeSelectedNotes(draft, noteSelectAction);
} }
break; break;
@ -774,7 +774,7 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
case 'SETTING_UPDATE_ONE': case 'SETTING_UPDATE_ONE':
{ {
const newSettings = Object.assign({}, draft.settings); const newSettings = { ...draft.settings };
newSettings[action.key] = action.value; newSettings[action.key] = action.value;
draft.settings = newSettings; draft.settings = newSettings;
} }
@ -827,7 +827,7 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
// Note is still in the same folder // Note is still in the same folder
// Merge the properties that have changed (in modNote) into // Merge the properties that have changed (in modNote) into
// the object we already have. // the object we already have.
newNotes[i] = Object.assign({}, newNotes[i]); newNotes[i] = { ...newNotes[i] };
for (const n in modNote) { for (const n in modNote) {
if (!modNote.hasOwnProperty(n)) continue; if (!modNote.hasOwnProperty(n)) continue;
@ -918,9 +918,9 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
case 'FOLDER_TOGGLE': case 'FOLDER_TOGGLE':
if (draft.collapsedFolderIds.indexOf(action.id) >= 0) { if (draft.collapsedFolderIds.indexOf(action.id) >= 0) {
folderSetCollapsed(draft, Object.assign({ collapsed: false }, action)); folderSetCollapsed(draft, { collapsed: false, ...action });
} else { } else {
folderSetCollapsed(draft, Object.assign({ collapsed: true }, action)); folderSetCollapsed(draft, { collapsed: true, ...action });
} }
break; break;
@ -1054,7 +1054,7 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
let found = false; let found = false;
for (let i = 0; i < searches.length; i++) { for (let i = 0; i < searches.length; i++) {
if (searches[i].id === action.search.id) { if (searches[i].id === action.search.id) {
searches[i] = Object.assign({}, action.search); searches[i] = { ...action.search };
found = true; found = true;
break; break;
} }
@ -1102,7 +1102,7 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
case 'CLIPPER_SERVER_SET': case 'CLIPPER_SERVER_SET':
{ {
const clipperServer = Object.assign({}, draft.clipperServer); const clipperServer = { ...draft.clipperServer };
if ('startState' in action) clipperServer.startState = action.startState; if ('startState' in action) clipperServer.startState = action.startState;
if ('port' in action) clipperServer.port = action.port; if ('port' in action) clipperServer.port = action.port;
draft.clipperServer = clipperServer; draft.clipperServer = clipperServer;
@ -1111,7 +1111,7 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
case 'DECRYPTION_WORKER_SET': case 'DECRYPTION_WORKER_SET':
{ {
const decryptionWorker = Object.assign({}, draft.decryptionWorker); const decryptionWorker = { ...draft.decryptionWorker };
for (const n in action) { for (const n in action) {
if (!action.hasOwnProperty(n) || n === 'type') continue; if (!action.hasOwnProperty(n) || n === 'type') continue;
(decryptionWorker as any)[n] = action[n]; (decryptionWorker as any)[n] = action[n];
@ -1122,7 +1122,7 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
case 'RESOURCE_FETCHER_SET': case 'RESOURCE_FETCHER_SET':
{ {
const rf = Object.assign({}, action); const rf = { ...action };
delete rf.type; delete rf.type;
draft.resourceFetcher = rf; draft.resourceFetcher = rf;
} }
@ -1141,8 +1141,8 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
case 'PLUGINLEGACY_DIALOG_SET': case 'PLUGINLEGACY_DIALOG_SET':
{ {
if (!action.pluginName) throw new Error('action.pluginName not specified'); if (!action.pluginName) throw new Error('action.pluginName not specified');
const newPluginsLegacy = Object.assign({}, draft.pluginsLegacy); const newPluginsLegacy = { ...draft.pluginsLegacy };
const newPlugin = draft.pluginsLegacy[action.pluginName] ? Object.assign({}, draft.pluginsLegacy[action.pluginName]) : {}; const newPlugin = draft.pluginsLegacy[action.pluginName] ? { ...draft.pluginsLegacy[action.pluginName] } : {};
if ('open' in action) newPlugin.dialogOpen = action.open; if ('open' in action) newPlugin.dialogOpen = action.open;
if ('userData' in action) newPlugin.userData = action.userData; if ('userData' in action) newPlugin.userData = action.userData;
newPluginsLegacy[action.pluginName] = newPlugin; newPluginsLegacy[action.pluginName] = newPlugin;

View File

@ -154,7 +154,7 @@ class Registry {
try { try {
this.logger().info('Starting scheduled sync'); this.logger().info('Starting scheduled sync');
const options = Object.assign({}, syncOptions, { context: context }); const options = { ...syncOptions, context: context };
if (!options.saveContextHandler) { if (!options.saveContextHandler) {
options.saveContextHandler = (newContext: any) => { options.saveContextHandler = (newContext: any) => {
Setting.setValue(contextKey, JSON.stringify(newContext)); Setting.setValue(contextKey, JSON.stringify(newContext));

View File

@ -177,7 +177,7 @@ export default class AlarmServiceDriverNode {
}, interval); }, interval);
} }
this.notifications_[notification.id] = Object.assign({}, notification); this.notifications_[notification.id] = { ...notification };
this.notifications_[notification.id].timeoutId = timeoutId; this.notifications_[notification.id].timeoutId = timeoutId;
} }
} }

View File

@ -194,7 +194,7 @@ export default class CommandService extends BaseService {
const command = this.commandByName(commandName); const command = this.commandByName(commandName);
runtime = Object.assign({}, runtime); runtime = { ...runtime };
if (!runtime.enabledCondition) runtime.enabledCondition = 'true'; if (!runtime.enabledCondition) runtime.enabledCondition = 'true';
command.runtime = runtime; command.runtime = runtime;
} }

View File

@ -110,7 +110,7 @@ export default class DecryptionWorker {
} }
public dispatchReport(report: any) { public dispatchReport(report: any) {
const action = Object.assign({}, report); const action = { ...report };
action.type = 'DECRYPTION_WORKER_SET'; action.type = 'DECRYPTION_WORKER_SET';
this.dispatch(action); this.dispatch(action);
} }
@ -280,7 +280,7 @@ export default class DecryptionWorker {
error: null, error: null,
}; };
this.dispatchReport(Object.assign({}, finalReport, { state: 'idle' })); this.dispatchReport({ ...finalReport, state: 'idle' });
if (downloadedButEncryptedBlobCount) { if (downloadedButEncryptedBlobCount) {
this.logger().info(`DecryptionWorker: Some resources have been downloaded but are not decrypted yet. Scheduling another decryption. Resource count: ${downloadedButEncryptedBlobCount}`); this.logger().info(`DecryptionWorker: Some resources have been downloaded but are not decrypted yet. Scheduling another decryption. Resource count: ${downloadedButEncryptedBlobCount}`);

View File

@ -65,7 +65,7 @@ class PluginManager {
return { return {
Dialog: Class.Dialog, Dialog: Class.Dialog,
props: Object.assign({}, this.dialogProps_(name), { userData: p.userData }), props: { ...this.dialogProps_(name), userData: p.userData },
}; };
} }
@ -86,7 +86,7 @@ class PluginManager {
if (!menuItems) continue; if (!menuItems) continue;
for (let i = 0; i < menuItems.length; i++) { for (let i = 0; i < menuItems.length; i++) {
const item = Object.assign({}, menuItems[i]); const item = { ...menuItems[i] };
item.click = () => { item.click = () => {
this.onPluginMenuItemTrigger_({ this.onPluginMenuItemTrigger_({

View File

@ -224,13 +224,11 @@ export default class RevisionService extends BaseService {
const rev = revisions[index]; const rev = revisions[index];
const merged = await Revision.mergeDiffs(rev, revisions); const merged = await Revision.mergeDiffs(rev, revisions);
const output: NoteEntity = Object.assign( const output: NoteEntity = {
{
title: merged.title, title: merged.title,
body: merged.body, body: merged.body,
}, ...merged.metadata,
merged.metadata };
);
output.updated_time = output.user_updated_time; output.updated_time = output.user_updated_time;
output.created_time = output.user_created_time; output.created_time = output.user_created_time;
(output as any).type_ = BaseModel.TYPE_NOTE; (output as any).type_ = BaseModel.TYPE_NOTE;
@ -268,7 +266,7 @@ export default class RevisionService extends BaseService {
} }
public async importRevisionNote(note: NoteEntity): Promise<NoteEntity> { public async importRevisionNote(note: NoteEntity): Promise<NoteEntity> {
const toImport = Object.assign({}, note); const toImport = { ...note };
delete toImport.id; delete toImport.id;
delete toImport.updated_time; delete toImport.updated_time;
delete toImport.created_time; delete toImport.created_time;

View File

@ -237,9 +237,7 @@ export default class EncryptionService {
} }
private async generateMasterKeyContent_(password: string, options: EncryptOptions = null) { private async generateMasterKeyContent_(password: string, options: EncryptOptions = null) {
options = Object.assign({}, { options = { encryptionMethod: this.defaultMasterKeyEncryptionMethod_, ...options };
encryptionMethod: this.defaultMasterKeyEncryptionMethod_,
}, options);
const bytes: any[] = await shim.randomBytes(256); const bytes: any[] = await shim.randomBytes(256);
const hexaBytes = bytes.map(a => hexPad(a.toString(16), 2)).join(''); const hexaBytes = bytes.map(a => hexPad(a.toString(16), 2)).join('');
@ -412,9 +410,7 @@ export default class EncryptionService {
} }
private async encryptAbstract_(source: any, destination: any, options: EncryptOptions = null) { private async encryptAbstract_(source: any, destination: any, options: EncryptOptions = null) {
options = Object.assign({}, { options = { encryptionMethod: this.defaultEncryptionMethod(), ...options };
encryptionMethod: this.defaultEncryptionMethod(),
}, options);
const method = options.encryptionMethod; const method = options.encryptionMethod;
const masterKeyId = options.masterKeyId ? options.masterKeyId : this.activeMasterKeyId(); const masterKeyId = options.masterKeyId ? options.masterKeyId : this.activeMasterKeyId();

View File

@ -25,7 +25,7 @@ export default class InteropService_Exporter_Base {
} }
public updateContext(context: any) { public updateContext(context: any) {
this.context_ = Object.assign({}, this.context_, context); this.context_ = { ...this.context_, ...context };
} }
public context() { public context() {

Some files were not shown because too many files have changed in this diff Show More