-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
151 additions
and
540 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
diff --git a/packages/components/hooks/usePendingUserInvitations.ts b/packages/components/hooks/usePendingUserInvitations.ts | ||
index d61e10f07..6cc0d2097 100644 | ||
--- a/packages/components/hooks/usePendingUserInvitations.ts | ||
+++ b/packages/components/hooks/usePendingUserInvitations.ts | ||
@@ -1,7 +1,7 @@ | ||
import { useCallback } from 'react'; | ||
|
||
import { PendingInvitation as PendingUserInvitation } from '@proton/shared/lib/interfaces'; | ||
-import { UserInvitationModel } from '@proton/shared/lib/models'; | ||
+import { UserInvitationModelKey } from '@proton/shared/lib/models/userInvitationModel.key'; | ||
import { fetchPendingUserInvitations } from '@proton/shared/lib/models/userInvitationModelApi'; | ||
|
||
import useApi from './useApi'; | ||
@@ -13,7 +13,7 @@ const usePendingUserInvitations = (): [PendingUserInvitation[] | undefined, bool | ||
const cache = useCache(); | ||
|
||
const miss = useCallback(() => fetchPendingUserInvitations(api), [api]); | ||
- return useCachedModelResult(cache, UserInvitationModel.key, miss); | ||
+ return useCachedModelResult(cache, UserInvitationModelKey, miss); | ||
}; | ||
|
||
export default usePendingUserInvitations; | ||
diff --git a/packages/shared/lib/models/userInvitationModel.js b/packages/shared/lib/models/userInvitationModel.js | ||
index ec3e45c0e..c8b5672ed 100644 | ||
--- a/packages/shared/lib/models/userInvitationModel.js | ||
+++ b/packages/shared/lib/models/userInvitationModel.js | ||
@@ -1,8 +1,9 @@ | ||
import updateCollection from '../helpers/updateCollection'; | ||
import { fetchPendingUserInvitations } from './userInvitationModelApi'; | ||
+import { UserInvitationModelKey as key } from './userInvitationModel.key'; | ||
|
||
export const UserInvitationModel = { | ||
- key: 'UserInvitations', | ||
+ key, | ||
get: fetchPendingUserInvitations, | ||
update: (model, events) => updateCollection({ model, events, itemKey: 'UserInvitation' }), | ||
}; | ||
diff --git a/packages/shared/lib/models/userInvitationModel.key.js b/packages/shared/lib/models/userInvitationModel.key.js | ||
new file mode 100644 | ||
index 000000000..c07ff03fa | ||
--- /dev/null | ||
+++ b/packages/shared/lib/models/userInvitationModel.key.js | ||
@@ -0,0 +1 @@ | ||
+export const UserInvitationModelKey = 'UserInvitations'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
diff --git a/packages/components/hooks/usePendingUserInvitations.ts b/packages/components/hooks/usePendingUserInvitations.ts | ||
index 6044196e1..b35ae94f5 100644 | ||
--- a/packages/components/hooks/usePendingUserInvitations.ts | ||
+++ b/packages/components/hooks/usePendingUserInvitations.ts | ||
@@ -2,11 +2,11 @@ import { useCallback } from 'react'; | ||
|
||
import { getInvitations } from '@proton/shared/lib/api/user'; | ||
import { Api, PendingInvitation as PendingUserInvitation } from '@proton/shared/lib/interfaces'; | ||
-import { UserInvitationModel } from '@proton/shared/lib/models'; | ||
|
||
import useApi from './useApi'; | ||
import useCache from './useCache'; | ||
import useCachedModelResult from './useCachedModelResult'; | ||
+import { UserInvitationModelKey } from '@proton/shared/lib/models/userInvitationModel.key'; | ||
|
||
export const fetchPendingUserInvitations = (api: Api) => | ||
api<{ UserInvitations: PendingUserInvitation[] }>(getInvitations()).then(({ UserInvitations }) => { | ||
@@ -18,7 +18,7 @@ const usePendingUserInvitations = (): [PendingUserInvitation[] | undefined, bool | ||
const cache = useCache(); | ||
|
||
const miss = useCallback(() => fetchPendingUserInvitations(api), [api]); | ||
- return useCachedModelResult(cache, UserInvitationModel.key, miss); | ||
+ return useCachedModelResult(cache, UserInvitationModelKey, miss); | ||
}; | ||
|
||
export default usePendingUserInvitations; | ||
diff --git a/packages/shared/lib/models/userInvitationModel.js b/packages/shared/lib/models/userInvitationModel.js | ||
index 1fa9690b7..a9035e06d 100644 | ||
--- a/packages/shared/lib/models/userInvitationModel.js | ||
+++ b/packages/shared/lib/models/userInvitationModel.js | ||
@@ -1,9 +1,10 @@ | ||
import { fetchPendingUserInvitations } from '@proton/components/hooks/usePendingUserInvitations'; | ||
|
||
import updateCollection from '../helpers/updateCollection'; | ||
+import { UserInvitationModelKey as key } from './userInvitationModel.key'; | ||
|
||
export const UserInvitationModel = { | ||
- key: 'UserInvitations', | ||
+ key, | ||
get: fetchPendingUserInvitations, | ||
update: (model, events) => updateCollection({ model, events, itemKey: 'UserInvitation' }), | ||
}; | ||
diff --git a/packages/shared/lib/models/userInvitationModel.key.js b/packages/shared/lib/models/userInvitationModel.key.js | ||
new file mode 100644 | ||
index 000000000..c07ff03fa | ||
--- /dev/null | ||
+++ b/packages/shared/lib/models/userInvitationModel.key.js | ||
@@ -0,0 +1 @@ | ||
+export const UserInvitationModelKey = 'UserInvitations'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.