Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Commits on Source (2)
(refactor): moved selectedHashtag to ProChannelService
· aa261cfe
Marcelo Rivera
authored
Aug 07, 2019
(feat): send selectedHashtag to backend
aa261cfe
(fix): added scheme to typings
· 03f95182
Marcelo Rivera
authored
Aug 07, 2019
03f95182
Hide whitespace changes
Inline
Side-by-side
src/app/interfaces/entities.ts
View file @
03f95182
...
...
@@ -82,7 +82,7 @@ export interface MindsUser {
headline
:
string
,
footer_text
:
string
,
footer_links
:
{
href
:
string
,
title
:
string
}[],
scheme
:
string
,
styles
?:
{
[
key
:
string
]:
string
},
};
}
...
...
src/app/modules/pro/channel/channel.component.ts
View file @
03f95182
...
...
@@ -46,8 +46,6 @@ export class ProChannelComponent implements OnInit, OnDestroy {
query
:
string
;
selectedTag
:
Tag
=
null
;
constructor
(
protected
element
:
ElementRef
,
protected
session
:
Session
,
...
...
@@ -212,7 +210,7 @@ export class ProChannelComponent implements OnInit, OnDestroy {
}
selectTag
(
clickedTag
:
any
)
{
this
.
selectedTag
=
clickedTag
;
this
.
channelService
.
setSelectedHashtag
(
clickedTag
)
;
for
(
let
tag
of
this
.
channel
.
pro_settings
.
tag_list
)
{
tag
.
selected
=
tag
.
tag
==
clickedTag
.
tag
;
...
...
src/app/modules/pro/channel/channel.service.ts
View file @
03f95182
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
EventEmitter
,
Injectable
}
from
'
@angular/core
'
;
import
{
MindsChannelResponse
}
from
'
../../../interfaces/responses
'
;
import
{
MindsUser
}
from
'
../../../interfaces/entities
'
;
import
{
MindsUser
,
Tag
}
from
'
../../../interfaces/entities
'
;
import
{
Client
}
from
'
../../../services/api/client
'
;
@
Injectable
()
export
class
ProChannelService
{
currentChannel
:
MindsUser
;
selectedHashtag
:
Tag
;
selectedHashtagChange
:
EventEmitter
<
Tag
>
=
new
EventEmitter
<
Tag
>
();
setSelectedHashtag
(
value
:
Tag
)
{
this
.
selectedHashtag
=
value
;
this
.
selectedHashtagChange
.
emit
(
this
.
selectedHashtag
);
}
constructor
(
protected
client
:
Client
,
...
...
src/app/modules/pro/channel/list/list.component.ts
View file @
03f95182
...
...
@@ -7,6 +7,7 @@ import { first } from "rxjs/operators";
import
{
OverlayModalService
}
from
"
../../../../services/ux/overlay-modal
"
;
import
{
ProContentModalComponent
}
from
"
../content-modal/modal.component
"
;
import
{
ProChannelListModal
}
from
'
../list-modal/list-modal.component
'
;
import
{
Tag
}
from
"
../../../../interfaces/entities
"
;
@
Component
({
selector
:
'
m-pro--channel-list
'
,
...
...
@@ -30,6 +31,10 @@ export class ProChannelListComponent implements OnInit, OnDestroy {
displaySeeMoreTile
:
boolean
=
false
;
selectedHashtag
:
Tag
;
selectedHashtag$
:
Subscription
;
constructor
(
public
feedsService
:
FeedsService
,
protected
modalService
:
OverlayModalService
,
...
...
@@ -43,6 +48,12 @@ export class ProChannelListComponent implements OnInit, OnDestroy {
ngOnInit
()
{
this
.
listen
();
this
.
selectedHashtag$
=
this
.
channelService
.
selectedHashtagChange
.
subscribe
((
tag
)
=>
{
this
.
selectedHashtag
=
tag
;
this
.
load
(
true
);
})
}
private
listen
()
{
...
...
@@ -98,6 +109,9 @@ export class ProChannelListComponent implements OnInit, OnDestroy {
if
(
this
.
params$
)
{
this
.
params$
.
unsubscribe
();
}
if
(
this
.
selectedHashtag$
)
{
this
.
selectedHashtag$
.
unsubscribe
();
}
}
async
load
(
refresh
:
boolean
=
false
)
{
...
...
@@ -109,14 +123,25 @@ export class ProChannelListComponent implements OnInit, OnDestroy {
this
.
detectChanges
();
let
search
=
''
;
let
search
=
[];
if
(
this
.
selectedHashtag
)
{
search
.
push
(
`hashtags=
${
this
.
selectedHashtag
.
tag
}
`
);
}
if
(
this
.
query
&&
(
this
.
query
!==
''
))
{
search
=
`?hashtags=null&period=
${
this
.
period
}
&all=1&query=
${
this
.
query
}
&nsfw=&sync=1&limit=150&as_activities=1&from_timestamp=`
;
search
.
push
(
`&period=
${
this
.
period
}
&all=1&query=
${
this
.
query
}
&nsfw=&sync=1&limit=150&as_activities=1&from_timestamp=`
);
}
let
url
=
`api/v2/feeds/channel/
${
this
.
channelService
.
currentChannel
.
guid
}
/
${
this
.
type
}
/
${
this
.
algorithm
}
`
;
if
(
search
.
length
>
0
)
{
url
+=
'
?
'
+
search
.
join
(
'
&
'
);
}
try
{
this
.
feedsService
.
setEndpoint
(
`api/v2/feeds/channel/
${
this
.
channelService
.
currentChannel
.
guid
}
/
${
this
.
type
}
/
${
this
.
algorithm
}${
search
}
`
)
.
setEndpoint
(
url
)
.
setLimit
(
10
)
.
fetch
();
...
...
@@ -141,7 +166,7 @@ export class ProChannelListComponent implements OnInit, OnDestroy {
algorithm
:
'
latest
'
,
query
:
this
.
query
,
},
{
{
class
:
'
m-overlayModal--seeMore
'
},
this
.
injector
)
.
present
();
...
...