Skip to content

Commit 86eb249

Browse files
Revert "T271904: Trending articles feed (#322)" (#339)
This reverts commit 3456a08.
1 parent 3b709d6 commit 86eb249

File tree

12 files changed

+34
-242
lines changed

12 files changed

+34
-242
lines changed

cypress/integration/article-view-spec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ describe('Article view', () => {
126126
cy.getCenterSoftkeyButton().click()
127127
articlePage.getArticleText().should('have.css', 'font-size', '14px')
128128
articlePage.selectOptionFromArticleMenu('Search Wikipedia')
129-
searchPage.search('cattle')
129+
cy.get('input[type=text]').type('cattle')
130130
searchPage.results().first()
131-
cy.enter().downArrow().enter()
131+
cy.downArrow()
132+
cy.enter()
132133
articlePage.getArticleText().should('have.css', 'font-size', '14px')
133134
})
134135

cypress/integration/search-spec.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ describe('Article search', () => {
3030
})
3131

3232
it('article should open from search results page', () => {
33-
searchPage.search('cattle')
33+
searchPage.search('catt')
3434
searchPage.results().first()
35-
cy.enter().downArrow().enter()
36-
articlePage.title().should('have.text', 'Cattle')
35+
cy.downArrow()
36+
searchPage.selectOptionFromSearchResultsList('Catt')
37+
articlePage.title().should('have.text', 'Catt')
3738
})
3839

3940
it('back button should take us to search page with results', () => {

cypress/page-objects/search-page.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,18 @@ export class SearchPage {
2222
getSearchTextBox () {
2323
return cy.get('input[type=text]')
2424
}
25+
26+
selectOptionFromSearchResultsList (option) {
27+
this.results()
28+
.each(($el, index, $list) => {
29+
if ($el.attr('data-selected-key') === option) {
30+
return false
31+
} else {
32+
cy.downArrow()
33+
}
34+
})
35+
.then(() => {
36+
cy.enter()
37+
})
38+
}
2539
}

cypress/support/commands.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ Cypress.Commands.add('clickMenuButton', () => {
4949
Cypress.Commands.add('navigateToHomePage', () => {
5050
cy.setLocalStorage('has-onboard-before', true)
5151
cy.setLocalStorage('usage-data-consent', '{}') // Don't display consent screen
52-
cy.setLocalStorage('2021-KaiOS-app-homepage-content-suggestions', 'control')
5352
cy.visit('/')
5453
})
5554

src/components/Feed.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/components/ListView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const ListView = ({ items = [], header, containerRef, empty }) => {
1414
<div class='item' dir={item.dir} data-selectable data-title={item.title} data-selected-key={item.title} key={item.title}>
1515
<div class='info'>
1616
<bdi class='title' dangerouslySetInnerHTML={{ __html: item.displayTitle || item.title }} />
17-
{ item.description && <bdi class={`description${item.imageUrl ? ' withImg' : ''}`} dangerouslySetInnerHTML={{ __html: item.description }} /> }
17+
{ item.description && <bdi class='description' dangerouslySetInnerHTML={{ __html: item.description }} /> }
1818
</div>
1919
{ item.imageUrl && <div class='img' style={{ backgroundImage: `url(${item.imageUrl})` }} /> }
2020
{ item.link && <div class='link'><img src='images/link.svg' /></div> }

src/components/Search.js

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { h } from 'preact'
2-
import { useRef, useEffect, useState } from 'preact/hooks'
3-
import { ListView, OfflinePanel, Consent, SearchLoading, Feed } from 'components'
2+
import { useRef, useEffect } from 'preact/hooks'
3+
import { ListView, OfflinePanel, Consent, SearchLoading } from 'components'
44
import {
55
useNavigation, useSearch, useI18n, useSoftkey,
6-
useOnlineStatus, useTracking, usePopup, useHistoryState
6+
useOnlineStatus, useTracking, usePopup
77
} from 'hooks'
88
import {
99
articleHistory, goto, getAppLanguage,
10-
isRandomEnabled, confirmDialog, isConsentGranted,
11-
isTrendingArticlesGroup, skipIntroAnchor
10+
isRandomEnabled, confirmDialog, skipIntroAnchor,
11+
isConsentGranted
1212
} from 'utils'
1313
import { getRandomArticleTitle } from 'api'
1414

@@ -17,9 +17,7 @@ export const Search = () => {
1717
const inputRef = useRef()
1818
const listRef = useRef()
1919
const i18n = useI18n()
20-
const [isFeedExpanded, setIsFeedExpanded] = useState(false)
21-
const [lastFeedIndex, setLastFeedIndex] = useHistoryState('lastFeedIndex', null)
22-
const [current, setNavigation, getCurrent, getAllElements, navigateNext, navigatePrevious] = useNavigation('Search', containerRef, listRef, 'y')
20+
const [current, setNavigation, getCurrent] = useNavigation('Search', containerRef, listRef, 'y')
2321
const lang = getAppLanguage()
2422
const [query, setQuery, searchResults, loading] = useSearch(lang)
2523
const [showConsentPopup, closeConsentPopup] = usePopup(Consent)
@@ -32,9 +30,6 @@ export const Search = () => {
3230
const onKeyCenter = () => {
3331
if (allowUsage()) {
3432
const { index, key } = getCurrent()
35-
if (index && isFeedExpanded) {
36-
setLastFeedIndex(index)
37-
}
3833
if (index) {
3934
goto.article(lang, key)
4035
} else if (isRandomEnabled() && !query) {
@@ -43,41 +38,6 @@ export const Search = () => {
4338
}
4439
}
4540

46-
const onKeyBackSpace = () => {
47-
if (isFeedExpanded) {
48-
setIsFeedExpanded(false)
49-
listRef.current.scrollTop = 0
50-
setNavigation(0)
51-
} else {
52-
onExitConfirmDialog()
53-
}
54-
}
55-
56-
const onKeyArrowDown = () => {
57-
const index = getCurrent().index
58-
if (!isFeedExpanded && !searchResults && index === 0) {
59-
setIsFeedExpanded(true)
60-
navigateNext()
61-
} else if (isFeedExpanded && index + 1 > getAllElements().length - 1) {
62-
setNavigation(1)
63-
} else {
64-
navigateNext()
65-
}
66-
}
67-
68-
const onKeyArrowUp = () => {
69-
const index = getCurrent().index
70-
if (isFeedExpanded && !searchResults && index === 1) {
71-
setIsFeedExpanded(false)
72-
setLastFeedIndex(null)
73-
navigatePrevious()
74-
} else if (!isFeedExpanded && !searchResults && index === 0) {
75-
setNavigation(0)
76-
} else {
77-
navigatePrevious()
78-
}
79-
}
80-
8141
const onInput = ({ target }) => {
8242
if (isOnline) {
8343
setQuery(target.value)
@@ -114,10 +74,8 @@ export const Search = () => {
11474
onKeyCenter,
11575
left: allowUsage() ? i18n('softkey-tips') : '',
11676
onKeyLeft: allowUsage() ? goto.tips : null,
117-
onKeyBackspace: !(query && current.type === 'INPUT') && onKeyBackSpace,
118-
onKeyArrowDown: !loading && onKeyArrowDown,
119-
onKeyArrowUp: !loading && onKeyArrowUp
120-
}, [current.type, query, isOnline, searchResults, loading])
77+
onKeyBackspace: !(query && current.type === 'INPUT') && onExitConfirmDialog
78+
}, [current.type, query, isOnline])
12179

12280
useTracking('Search', lang)
12381

@@ -131,12 +89,11 @@ export const Search = () => {
13189
}
13290
}, [consentGranted, isOnline])
13391

134-
const hideW = (searchResults || !isOnline || loading || (isFeedExpanded && isTrendingArticlesGroup()))
92+
const hideW = (searchResults || !isOnline || loading)
13593
const showSearchBar = allowUsage()
13694
const showResultsList = isOnline && searchResults && !loading
13795
const showLoading = isOnline && loading
13896
const showOfflinePanel = !isOnline
139-
const showFeed = (isOnline && !searchResults && !showLoading && !showOfflinePanel && (isTrendingArticlesGroup()))
14097

14198
return (
14299
<div class='search' ref={containerRef}>
@@ -145,7 +102,6 @@ export const Search = () => {
145102
{ showResultsList && <ListView header={i18n('header-search')} items={searchResults} containerRef={listRef} empty={i18n('no-result-found')} /> }
146103
{ showLoading && <SearchLoading /> }
147104
{ showOfflinePanel && <OfflinePanel /> }
148-
{ showFeed && <Feed lang={lang} isExpanded={isFeedExpanded} setIsExpanded={setIsFeedExpanded} lastIndex={lastFeedIndex} setNavigation={setNavigation} containerRef={listRef} /> }
149105
</div>
150106
)
151107
}

src/components/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export * from './ArticleToc'
1111
export * from './ConfirmDialog'
1212
export * from './Consent'
1313
export * from './Error'
14-
export * from './Feed'
1514
export * from './Feedback'
1615
export * from './Gallery'
1716
export * from './Language'

src/hooks/useNavigation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,5 @@ export const useNavigation = (origin, containerRef, listRef, axis, elementsSelec
8787
}
8888
})
8989

90-
return [current, setNavigation, getCurrent, getAllElements, navigateNext, navigatePrevious]
90+
return [current, setNavigation, getCurrent]
9191
}

style/feed.less

Lines changed: 0 additions & 141 deletions
This file was deleted.

0 commit comments

Comments
 (0)