Skip to content

Commit

Permalink
fix: show latest app data (#96)
Browse files Browse the repository at this point in the history
* fix: show latest app data

---------

Co-authored-by: spaenleh <[email protected]>
  • Loading branch information
pyphilia and spaenleh authored Jul 18, 2023
1 parent d8fe69f commit 26bed01
Show file tree
Hide file tree
Showing 5 changed files with 1,302 additions and 211 deletions.
5 changes: 5 additions & 0 deletions cypress/e2e/PlayerView.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ describe('<PlayerView />', () => {
.should('be.visible')
.should('have.attr', 'disabled');
cy.get(inputTextFieldSelector).contains(text);

// input new content and should display it
const text2 = 'new text again';
cy.enterStudentResponse(text2);
cy.get(inputTextFieldSelector).contains(text2);
});
});

Expand Down
16 changes: 16 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"es5",
"dom"
],
"types": [
"cypress",
"node"
]
},
"include": [
"**/*.ts"
]
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "graasp-app-text-input",
"version": "1.0.0-rc.1",
"private": true,
"author": "React EPFL",
"author": "Graasp",
"contributors": [
"Juan Carlos Farah",
"Kim Lan Phan Hoang"
Expand All @@ -11,8 +11,8 @@
"license": "AGPL3.0-only",
"dependencies": {
"@emotion/styled": "11.11.0",
"@graasp/apps-query-client": "2.0.0-rc.1",
"@graasp/sdk": "1.0.0-rc1",
"@graasp/apps-query-client": "2.0.1",
"@graasp/sdk": "1.1.2",
"@json2csv/plainjs": "7.0.1",
"@mui/icons-material": "5.11.16",
"@mui/material": "5.13.3",
Expand Down
13 changes: 9 additions & 4 deletions src/components/views/read/PlayerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,15 @@ const PlayerView = (): JSX.Element => {

useEffect(() => {
if (isAppDataSuccess) {
const data = appData.find(
({ type, creator }) =>
type === APP_DATA_TYPES.INPUT && creator?.id === memberId
);
// for security we get the latest of all the app data
const appDataForMemberId = appData
.filter(
({ type, creator }) =>
type === APP_DATA_TYPES.INPUT && creator?.id === memberId
)
.sort((a, b) => (a.updatedAt > b.updatedAt ? 1 : -1));
const data = appDataForMemberId.last();

if (data) {
setInputResource(data);
const feedback = appData.find(
Expand Down
Loading

0 comments on commit 26bed01

Please sign in to comment.