Skip to content

Commit

Permalink
removes onDisplayPhoto and onHidePhoto
Browse files Browse the repository at this point in the history
Co-authored-by: Nick Sellen <[email protected]>
  • Loading branch information
edvardmk and nicksellen committed May 22, 2020
1 parent 1961172 commit 21be47d
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 48 deletions.
8 changes: 1 addition & 7 deletions modules/core/client/components/Board.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ export default function Board({
names = 'bokeh',
style = null,
children,
onDisplayPhoto = () => {},
onHidePhoto = () => {},
className,
...rest
}) {
Expand All @@ -46,15 +44,13 @@ export default function Board({

// inform the parent that the photo is displayed
// ...useful e.g. for displaying photo credits elsewere
onDisplayPhoto(photoObject);
$broadcast('photoCreditsUpdated', photoObject);

// inform the parent that the photo is not displayed anymore
return () => {
onHidePhoto(photoObject);
$broadcast('photoCreditsRemoved', photoObject);
};
}, []);
}, [names]);

if (photo) {
style
Expand All @@ -80,6 +76,4 @@ Board.propTypes = {
style: PropTypes.object,
className: PropTypes.string,
children: PropTypes.node,
onDisplayPhoto: PropTypes.func,
onHidePhoto: PropTypes.func,
};
1 change: 0 additions & 1 deletion modules/core/client/components/BoardCredits.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default function BoardCredits({ photoCredits: initialPhotoCredits }) {
});

$on('photoCreditsRemoved', (scope, photo) => {
// setPhotoCredits({ ...photoCredits, ...photo });
setPhotoCredits(omit(photoCredits, Object.keys(photo)));
});
};
Expand Down
1 change: 0 additions & 1 deletion modules/pages/client/components/Home.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export default function Home({ user, isNativeMobileApp, photoCredits }) {
<>
{!user && (
// TODO apply tr-boards-ignore-small attribute here and implement functionality in the Board.js controller
// TODO check if onDisplayPhoto/onHidePhoto should be applied here and implement functionality in the Board.js controller
<Board
className="board-primary container home-intro"
names={boards}
Expand Down
2 changes: 2 additions & 0 deletions modules/pages/tests/client/pages.client.routes.tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import '@/modules/pages/client/pages.client.module';
import AppConfig from '@/modules/core/client/app/config';
// TODO import { $broadcast } from '@/modules/core/client/services/angular-compat';
// TODO jest.mock('@/modules/core/client/services/angular-compat');

describe('Pages Route Tests', function() {
// We can start by loading the main application module
Expand Down
15 changes: 2 additions & 13 deletions modules/tribes/client/components/TribesHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@ import PropTypes from 'prop-types';
import { useTranslation } from 'react-i18next';
import Board from '@/modules/core/client/components/Board';

export default function TribesHeader({
isLoggedIn,
onDisplayPhoto,
onHidePhoto,
}) {
export default function TribesHeader({ isLoggedIn }) {
const { t } = useTranslation('tribes');

return (
<Board
names="tribes-1"
className="tribes-header"
onDisplayPhoto={onDisplayPhoto}
onHidePhoto={onHidePhoto}
>
<Board names="tribes-1" className="tribes-header">
<div className="container">
<div className="row">
<div className="col-xs-12 text-center">
Expand Down Expand Up @@ -46,6 +37,4 @@ export default function TribesHeader({

TribesHeader.propTypes = {
isLoggedIn: PropTypes.bool.isRequired,
onDisplayPhoto: PropTypes.func,
onHidePhoto: PropTypes.func,
};
15 changes: 2 additions & 13 deletions modules/tribes/client/components/TribesPage.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ import TribesJoinTrustroots from './TribesJoinTrustroots';

import * as api from '../api/tribes.api';

export default function TribesPage({
user,
onDisplayPhoto,
onHidePhoto,
onMembershipUpdated,
}) {
export default function TribesPage({ user, onMembershipUpdated }) {
const [tribes, setTribes] = useState([]);

const handleMembershipUpdated = data => {
Expand Down Expand Up @@ -43,11 +38,7 @@ export default function TribesPage({

return (
<>
<TribesHeader
isLoggedIn={!!user}
onDisplayPhoto={onDisplayPhoto}
onHidePhoto={onHidePhoto}
/>
<TribesHeader isLoggedIn={!!user} />

<section className="container container-spacer">
<div className="row">
Expand All @@ -69,6 +60,4 @@ export default function TribesPage({
TribesPage.propTypes = {
user: PropTypes.object,
onMembershipUpdated: PropTypes.func.isRequired,
onDisplayPhoto: PropTypes.func,
onHidePhoto: PropTypes.func,
};
2 changes: 0 additions & 2 deletions modules/tribes/client/config/tribes.client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ function TribesRoutes($stateProvider) {
template: `
<tribes-page
user="app.user"
onDisplayPhoto="tribesList.addPhotoCredits"
onHidePhoto="tribesList.removePhotoCredits"
onMembershipUpdated="tribesList.broadcastUpdatedUser"
></tribes-page>
`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ angular
.controller('TribesListController', TribesListController);

/* @ngInject */
function TribesListController(Authentication, $rootScope, $scope) {
function TribesListController(Authentication, $rootScope) {
// ViewModel
const vm = this;

Expand All @@ -21,14 +21,4 @@ function TribesListController(Authentication, $rootScope, $scope) {
$rootScope.$broadcast('userUpdated');
}
};

/**
* Emit photo credits info
*/
vm.addPhotoCredits = function addPhotoCredits(photo) {
$scope.$emit('photoCreditsUpdated', photo);
};
vm.removePhotoCredits = function removePhotoCredits(photo) {
$scope.$emit('photoCreditsRemoved', photo);
};
}

0 comments on commit 21be47d

Please sign in to comment.