Skip to content

Commit

Permalink
fix(app): use memberId for legacy apps (#1045)
Browse files Browse the repository at this point in the history
* refactor: update sdk

* refactor: resolve PR requested issues
  • Loading branch information
pyphilia authored Sep 18, 2024
1 parent c555bba commit 37791ad
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion 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 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
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
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

0 comments on commit 37791ad

Please sign in to comment.