-
Notifications
You must be signed in to change notification settings - Fork 168
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
Add Accept-Language
header to requests
#8621
Conversation
4ce3a00
to
7a4b86e
Compare
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.
Love it! 😍
|
||
describe('avatarUrl', () => { | ||
it('throws an error', async () => { | ||
const defaultOptions = getDefaultOptions() | ||
defaultOptions.clientService.httpAuthenticated.head.mockResolvedValue({ status: 200 }) | ||
defaultOptions.clientService.owncloudSdk.signUrl.mockRejectedValue(new Error('error')) |
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.
woah! 😍
This is so much more readable than before.
packages/web-app-files/tests/unit/mixins/spaces/setImage.spec.ts
Outdated
Show resolved
Hide resolved
packages/web-app-files/tests/unit/mixins/spaces/uploadImage.spec.ts
Outdated
Show resolved
Hide resolved
} as any) | ||
) | ||
const clientService = mockDeep<ClientService>() | ||
clientService.owncloudSdk.files.search.mockImplementation(searchMock) |
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.
Value of this composable has significantly dropped with it just not having to handle access token and store. By now it only destructures the return value of useClientService().
We could/should consider to drop this composable.
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.
Yep, good point. I'll check when rebasing the PR the next time!
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'd rather do this in a follow-up, it's being used quite a few times actually.
graph: Graph | ||
ocs: OCS | ||
} | ||
|
||
const createAxiosInstance = (authParams: AuthParameters): AxiosInstance => { | ||
interface HttpClient { | ||
client: _HttpClient |
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 a little confusing, but I don't have better name recommendations either
7a4b86e
to
09ed997
Compare
09ed997
to
89571db
Compare
89571db
to
9344a3f
Compare
Kudos, SonarCloud Quality Gate passed! |
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.
Love it, thanks a lot!
token?: string | ||
} | ||
|
||
const createAxiosInstance = (authParams: AuthParameters, language): AxiosInstance => { |
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.
language has no type, but we can sneak that in in the next PR no need to trigger a new CI run for this
Description
Adds the
Accept-Language
header to all outgoing requests so the server can deliver proper translations if necessary.This includes a few refactorings:
selectedLanguage
in the runtime has been removed. The current language now gets set by theUserManager
each time the user context is updated as well as when the user updates their language. This change was made because theUserManager
needs to fetch the current language anyways as it needs to initialize the SDK with it.ClientService
is now being initialized properly when bootstrapping the app, hence the singleton has been removed. Please use theuseClientService
composable to access the service.ClientService
can now be accessed via a simple getter, there is not need to pass things like anaccessToken
every time (withocsPublicLinkContext
being the only exception because we need to pass apassword
).Related Issue
Types of changes
Follow-Ups
useGraphClient
composable