Skip to content

Commit

Permalink
fix: deal with some issues in the gpt story
Browse files Browse the repository at this point in the history
  • Loading branch information
JGAntunes committed Jun 23, 2017
1 parent 7e4fcc3 commit 7289088
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
5 changes: 3 additions & 2 deletions packages/gpt/ad-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ AdManager.prototype.display = function display (callback) {
console.log('refresh')
pbjsManager.pbjs.setTargetingForGPTAsync();
gptManager.googletag.pubads().refresh();
return callback();
if(callback) callback();
});
});
};
Expand All @@ -79,7 +79,6 @@ AdManager.prototype._pushAdToGPT = function pushAdToGPT (adSlotId, sizingMap, op

gptManager.googletag.cmd.push(() => {
const slot = this._createSlot(adSlotId, this.section);
console.log('Slot', slot)
slot.addService(gptManager.googletag.pubads());
slot.defineSizeMapping(this._generateSizings(sizingMap));

Expand All @@ -90,6 +89,8 @@ AdManager.prototype._pushAdToGPT = function pushAdToGPT (adSlotId, sizingMap, op

// Display the ad
gptManager.googletag.display(adSlotId);
console.log('Display slot', slot)
console.log('Sizing map', sizingMap)
});
};

Expand Down
24 changes: 13 additions & 11 deletions packages/gpt/gpt.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,30 @@ import GPT from "./gpt.web";

class Wrapper extends Component {

constructor (props) {
super(props);
this.adManager = new AdManager({
networkId: '25436805',
adUnit: 'd.thetimes.co.uk',
section: 'home'
});
}

componentDidMount () {
console.log('Component did mount wrapper')
this.props.adManager.init(() => {
this.props.adManager.display();
this.adManager.init(() => {
this.adManager.display();
});
}

render() {
return (
<div>
<GPT code='ad-header' adManager={this.props.adManager} />
<GPT adManager={this.adManager} code='ad-header' />
</div>
);
}
}

storiesOf("GPT", module).add("GPT", () => {
const adManager = new AdManager({
networkId: '25436805',
adUnit: 'd.thetimes.co.uk',
section: 'article'
});

return (<Wrapper adManager={adManager} />);
return (<Wrapper />);
});

0 comments on commit 7289088

Please sign in to comment.