-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: Fully re-render ads when navigating between pages (#188)
In the past, the ad plugin relied on two side-effects to achieve this behaviour: 1. Components being fully destroyed/rendered when navigating between pages. This stopped working when Discourse core moved to the more efficient 'loading slider' UI 2. The `listLoading` argument. This was an implementation detail of the old discovery routing infrastructure. Core recently overhauled this and removed the `listLoading` argument, because loading is now handled properly by the Ember router. Instead of these two properties, we can use the `currentRoute` property of Ember's router service to trigger changes when navigating between pages. A common `{{#each` trick is used to fully destroy/re-render components even if the ad network is unchanged.
- Loading branch information
1 parent
5ad841d
commit c88bb59
Showing
11 changed files
with
35 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
{{#each adComponents as |adComponent|}} | ||
{{component | ||
adComponent | ||
placement=placement | ||
refreshOnChange=refreshOnChange | ||
category=category | ||
listLoading=listLoading | ||
postNumber=postNumber | ||
indexNumber=indexNumber | ||
tagName=childTagName | ||
}} | ||
{{! Trick to force full destroy/re-render of component when route changes }} | ||
{{#each (array this.router.currentRoute)}} | ||
{{component | ||
adComponent | ||
placement=placement | ||
category=category | ||
postNumber=postNumber | ||
indexNumber=indexNumber | ||
tagName=childTagName | ||
}} | ||
{{/each}} | ||
{{/each}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
assets/javascripts/discourse/connectors/after-topic-list-item/discourse-adplugin.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
{{ad-slot | ||
placement="topic-list-between" | ||
refreshOnChange=listLoading | ||
category=category.slug | ||
listLoading=listLoading | ||
indexNumber=index | ||
childTagName="td" | ||
}} |
7 changes: 1 addition & 6 deletions
7
assets/javascripts/discourse/connectors/discovery-list-container-top/discourse-adplugin.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
{{ad-slot | ||
placement="topic-list-top" | ||
refreshOnChange=listLoading | ||
category=category.slug | ||
listLoading=listLoading | ||
}} | ||
{{ad-slot placement="topic-list-top" category=category.slug}} |
6 changes: 1 addition & 5 deletions
6
assets/javascripts/discourse/connectors/topic-above-post-stream/discourse-adplugin.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
{{ad-slot | ||
placement="topic-above-post-stream" | ||
refreshOnChange=model.id | ||
category=model.category.slug | ||
}} | ||
{{ad-slot placement="topic-above-post-stream" category=model.category.slug}} |
6 changes: 1 addition & 5 deletions
6
assets/javascripts/discourse/connectors/topic-above-suggested/discourse-adplugin.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
{{ad-slot | ||
placement="topic-above-suggested" | ||
refreshOnChange=model.id | ||
category=model.category.slug | ||
}} | ||
{{ad-slot placement="topic-above-suggested" category=model.category.slug}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters