-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Cleanup of events, reducers and actions #1382
Conversation
e3eefcd
to
342fa56
Compare
hostnameShouldBePinned (hostname) { | ||
return pins.some(pin => pin.url.test(hostname.toLowerCase().trim())); | ||
}, | ||
hostnameShouldBePinned: hostname => pins.some(pin => pin.url.test(hostname.toLowerCase().trim())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a real benefit to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the original version is more readable I would say..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's shorter 😃
@@ -41,12 +40,13 @@ const _authorizeApp = (url) => { | |||
setImmediate(() => { | |||
const title = win.getTitle(); | |||
|
|||
const [, , returnValue] = title.split(/[ =]/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is more cryptic than const returnValue = title.split(/[ =]/)[2];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it fails as soon as you enable magic number checking
@@ -41,12 +40,13 @@ const _authorizeApp = (url) => { | |||
setImmediate(() => { | |||
const title = win.getTitle(); | |||
|
|||
const [, , returnValue] = title.split(/[ =]/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const returnValue = title.split(/[ =]/)[2];
electron/js/lib/openGraph.js
Outdated
@@ -41,13 +41,13 @@ const _fetchImageAsBase64 = (url) => { | |||
}); | |||
}; | |||
|
|||
const _fetchOpenGraphData = (url) => { | |||
const fetchOpenGraphData = (url) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const fetchOpenGraphData = url => {
electron/js/lib/openGraph.js
Outdated
const _getOpenGraphData = (url, callback) => { | ||
return _fetchOpenGraphData(url) | ||
const getOpenGraphData = (url, callback) => { | ||
return fetchOpenGraphData(url) | ||
.then((meta) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.then(meta => {
electron/js/lib/openGraph.js
Outdated
return _fetchImageAsBase64(imageUrl) | ||
.then((uri) => _updateMetaDataWithImage(meta, uri)) | ||
return fetchImageAsBase64(imageUrl) | ||
.then((uri) => updateMetaDataWithImage(meta, uri)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.then(uri => updateMetaDataWithImage(meta, uri))
id, | ||
type: DELETE_ACCOUNT, | ||
type: UPDATE_ACCOUNT_BADGE, | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const updateAccountBadge = (id, count) => ({
count,
id,
type: UPDATE_ACCOUNT_BADGE,
});
Same for the other functions in this file.
export const setAccountContextHidden = () => { | ||
return { | ||
type: 'HIDE_CONTEXT_MENUS', | ||
type: HIDE_CONTEXT_MENUS, | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const setAccountContextHidden = () => ({
type: HIDE_CONTEXT_MENUS,
});
const is_visible = this.props.visible === true; | ||
if (is_visible) { | ||
const isVisible = this.props.visible === true; | ||
if (isVisible) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (this.props.visible === true) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or just if (this.props.visible)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the explicit test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's redundant since the variable name is already very clear.. https://softwareengineering.stackexchange.com/questions/12807/make-a-big-deal-out-of-true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plus it's shorter :)
export const ACTION = { | ||
NOTIFICATION_CLICK: 'EVENT_TYPE.ACTION.NOTIFICATION_CLICK', | ||
}; | ||
export const LIFECYCLE = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
};
export const LIFECYCLE = {
@@ -33,7 +32,7 @@ export const loadState = () => { | |||
export const saveState = (state) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const saveState = state => {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, yes, eventually...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe even tomorrow :) as @gregor has some ideas :) Robots will do their job, eventually..
teamID: undefined, | ||
userID: undefined, | ||
visible: true, | ||
}; | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const createAccount = sessionId => ({
accentID: undefined,
badgeCount: 0,
id: uuid(),
lifecycle: undefined,
name: undefined,
picture: undefined,
sessionID: sessionId,
teamID: undefined,
userID: undefined,
visible: true,
});
|
||
const accounts = (state = [createAccount()], action) => { | ||
const accountReducer = (state = [createAccount()], action) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
id, | ||
config.LOG_FILE_NAME | ||
); | ||
const logFilePath = path.join(app.getPath('userData'), 'logs', id, config.LOG_FILE_NAME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT about making the logs
dir name a constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the idea but I don't want to add more stuff to this PR than we already have.
'img', | ||
'notification.png' | ||
); | ||
global.notification_icon = path.join(app.getAppPath(), 'img', 'notification.png'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT about making the img
dir name a constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
No description provided.