Skip to content
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

fix(app): use memberId for legacy apps #1045

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"@emotion/cache": "~11.10.7 || ~11.11.0 || ~11.13.0",
"@emotion/react": "~11.10.6 || ~11.11.0 || ~11.13.0",
"@emotion/styled": "~11.10.6 || ~11.11.0 || ~11.13.0",
"@graasp/sdk": "^4.14.0",
"@graasp/sdk": "^4.29.0",
"@graasp/stylis-plugin-rtl": "^2",
"@graasp/translations": "^1.23.0",
"@mui/icons-material": "~5.14.0 || ~5.15.0 || ~5.16.0",
Expand All @@ -108,7 +108,7 @@
"@eslint/compat": "1.1.1",
"@eslint/eslintrc": "3.1.0",
"@eslint/js": "9.10.0",
"@graasp/sdk": "4.28.0",
"@graasp/sdk": "4.29.0",
"@graasp/stylis-plugin-rtl": "2.2.0",
"@mui/icons-material": "5.16.7",
"@mui/lab": "5.0.0-alpha.173",
Expand Down
37 changes: 19 additions & 18 deletions src/items/appItemHooks.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
import { useEffect } from 'react';

import {
AppItemType,
Context,
DiscriminatedItem,
Member,
PermissionLevel,
UUID,
} from '@graasp/sdk';
import { DiscriminatedItem, LocalContext, UUID } from '@graasp/sdk';

export type Token = string;

export type ContextPayload = {
apiHost: string;
itemId: AppItemType['id'];
settings: AppItemType['settings'];
memberId?: Member['id'];
permission: `${PermissionLevel}` | PermissionLevel;
lang: string;
context: `${Context}` | Context;
};
export type ContextPayload = Pick<
LocalContext,
| 'apiHost'
| 'itemId'
| 'settings'
| 'permission'
| 'lang'
| 'context'
| 'accountId'
>;

const buildPostMessageKeys = (
itemId: UUID,
Expand Down Expand Up @@ -129,7 +123,14 @@ const useAppCommunication = ({
iFrameRef?.current?.contentWindow?.postMessage(
JSON.stringify({
type: POST_MESSAGE_KEYS.GET_CONTEXT_SUCCESS,
payload: contextPayload,

payload: {
/**
* Legacy for old apps or apps that does not use apps-query-client
*/
memberId: contextPayload.accountId,
...contextPayload,
},
}),
targetOrigin,
[channel.port2],
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1314,9 +1314,9 @@ __metadata:
languageName: node
linkType: hard

"@graasp/sdk@npm:4.28.0":
version: 4.28.0
resolution: "@graasp/sdk@npm:4.28.0"
"@graasp/sdk@npm:4.29.0":
version: 4.29.0
resolution: "@graasp/sdk@npm:4.29.0"
dependencies:
"@faker-js/faker": "npm:9.0.0"
filesize: "npm:10.1.6"
Expand All @@ -1325,7 +1325,7 @@ __metadata:
peerDependencies:
date-fns: ^3
uuid: ^9 || ^10
checksum: 10/89f9c559154896637ac6d02daa710288de6ac2b753270037eef95dc32a763d6b597aeaafedab312bfd558d1b42b265d23066ffa640197acf4ef1883f4029ba48
checksum: 10/9801f0429172f325d14b378d4d2b2ec1ada679da736901e8ae9fca2f52f1b29b508809b686ee0b3fd8944262958a1e9c4b77936f57e5f448ad1ca8cc5632c50b
languageName: node
linkType: hard

Expand All @@ -1352,7 +1352,7 @@ __metadata:
"@eslint/compat": "npm:1.1.1"
"@eslint/eslintrc": "npm:3.1.0"
"@eslint/js": "npm:9.10.0"
"@graasp/sdk": "npm:4.28.0"
"@graasp/sdk": "npm:4.29.0"
"@graasp/stylis-plugin-rtl": "npm:2.2.0"
"@mui/icons-material": "npm:5.16.7"
"@mui/lab": "npm:5.0.0-alpha.173"
Expand Down Expand Up @@ -1430,7 +1430,7 @@ __metadata:
"@emotion/cache": ~11.10.7 || ~11.11.0 || ~11.13.0
"@emotion/react": ~11.10.6 || ~11.11.0 || ~11.13.0
"@emotion/styled": ~11.10.6 || ~11.11.0 || ~11.13.0
"@graasp/sdk": ^4.14.0
"@graasp/sdk": ^4.29.0
"@graasp/stylis-plugin-rtl": ^2
"@graasp/translations": ^1.23.0
"@mui/icons-material": ~5.14.0 || ~5.15.0 || ~5.16.0
Expand Down