-
Notifications
You must be signed in to change notification settings - Fork 51
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
[Cleanup] Adjusting Company Switcher Per New Design #2330
Changes from 9 commits
56fbd27
6cdb11b
ab1e615
c9d5029
f3161c4
4d5c084
0f04cbd
89027df
f0ef346
7897c25
7f2f9c3
48dbed3
428ea65
1547f30
93bd5fe
9bb2de5
e178ed5
99e4b5f
c6aaf87
9d2515b
9b40954
dd73bfb
fbd2306
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Invoice Ninja (https://invoiceninja.com). | ||
* | ||
* @link https://github.com/invoiceninja/invoiceninja source repository | ||
* | ||
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) | ||
* | ||
* @license https://www.elastic.co/licensing/elastic-license | ||
*/ | ||
|
||
import { useUpdateCompanyUser } from '$app/pages/settings/user/common/hooks/useUpdateCompanyUser'; | ||
import { cloneDeep, set } from 'lodash'; | ||
import { useHandleCurrentUserChangeProperty } from './useHandleCurrentUserChange'; | ||
import { useInjectUserChanges } from './useInjectUserChanges'; | ||
|
||
export function useHandleCollapseExpandSidebar() { | ||
const userChanges = useInjectUserChanges(); | ||
|
||
const updateCompanyUser = useUpdateCompanyUser(); | ||
const handleUserChange = useHandleCurrentUserChangeProperty(); | ||
|
||
return (value: boolean) => { | ||
handleUserChange('company_user.react_settings.show_mini_sidebar', value); | ||
|
||
if (userChanges) { | ||
const updatedUserChanges = cloneDeep(userChanges); | ||
|
||
set( | ||
updatedUserChanges, | ||
'company_user.react_settings.show_mini_sidebar', | ||
value | ||
); | ||
|
||
updateCompanyUser(updatedUserChanges); | ||
} | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ export function useInjectUserChanges(options?: Options) { | |
const changes = useUserChanges(); | ||
|
||
useEffect(() => { | ||
if (changes && options?.overwrite === false) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @beganovich I don't think this ever worked correctly. David reported that the speed of collapsing/expanding sidebar is really slow - the reason for that is exactly this logic. The changes object is constantly being injected again because this if statement is almost never true. By default, the changes object used in this if statement is an empty object ({}), it is never null/undefined. So, that part of the condition is always true, while the second part is equal to false only if the overwrite is passed through options. So, instead of comparing types also, we just want to check if the overwrite is set to true. The overwrite is never passed as a true value, but also I don't think we ever need to overwrite changes over the changes we currently have. The same thing applies to |
||
if (Object.keys(changes || {}).length && !options?.overwrite) { | ||
// We don't want to overwrite existing changes, | ||
// so let's just not inject anything if we already have a value, | ||
// and relative argument. | ||
|
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.
We definitely need to kick out this library. It wasn't updated in years and it will definitely block our path to React 19.
As replacement we can use ui-avatars.com, but we should be careful here as well.
@turbo124 should we use 3rd party website to generate nice avatars for us (due to privacy concerns).
Just to be clear
react-avatar
isn't fully offline either.