Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 1170089

Browse files
committed
fix(rxjs upgrade): some mismatch
1 parent 5f9aac2 commit 1170089

File tree

16 files changed

+151
-90
lines changed

16 files changed

+151
-90
lines changed

components/ThreadsCell/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import React from 'react'
88
import PropTypes from 'prop-types'
99
import R from 'ramda'
10-
import Icon from 'antd'
10+
import { Icon } from 'antd'
1111

1212
import { ICON_CMD } from '../../config'
1313

containers/CommunitiesBanner/ThreadsBanner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ThreadsBanner extends React.Component {
4646
</FilterTags>
4747
</OperationItem>
4848
<OperationDivider />
49-
<OperationItem onClick={logic.onAdd}>
49+
<OperationItem onClick={logic.onAdd.bind(this, 'threads')}>
5050
<OperationIconChart src={`${ICON_CMD}/plus.svg`} />
5151
添加
5252
</OperationItem>

containers/CommunitiesBanner/logic.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export const loadCategories = () =>
4848
sr71$.query(S.pagedCategories, { filter: {} })
4949

5050
export function onAdd(thread) {
51+
console.log('thread: ', thread)
5152
switch (thread) {
5253
case 'tags': {
5354
return dispatchEvent(EVENT.NAV_CREATE_TAG, {
@@ -59,9 +60,13 @@ export function onAdd(thread) {
5960
type: TYPE.PREVIEW_CREATE_CATEGORY,
6061
})
6162
}
63+
case 'threads': {
64+
return dispatchEvent(EVENT.NAV_CREATE_THREAD, {
65+
type: TYPE.PREVIEW_CREATE_THREAD,
66+
})
67+
}
6268
default: {
63-
debug('onAdd thread: ', thread)
64-
69+
debug('onAdd default: ', thread)
6570
return dispatchEvent(EVENT.NAV_CREATE_COMMUNITY, {
6671
type: TYPE.PREVIEW_CREATE_COMMUNITY,
6772
})

containers/CommunitiesContent/ThreadsContent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const columns = [
3434
{
3535
title: 'raw',
3636
width: 200,
37-
dataIndex: 'author',
37+
dataIndex: 'raw',
3838
align: 'center',
3939
},
4040
/*

containers/Doraemon/Pockect.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
import { Observable } from 'rxjs/Observable'
2-
import { Subject } from 'rxjs/Subject'
1+
import { Subject, of } from 'rxjs'
32
import PubSub from 'pubsub-js'
43

5-
// import 'rxjs/add/observable/of'
6-
import 'rxjs/add/operator/do'
7-
import 'rxjs/add/operator/catch'
8-
import 'rxjs/add/operator/switchMap'
9-
import 'rxjs/add/operator/debounceTime'
10-
import 'rxjs/add/operator/takeUntil'
11-
// import 'rxjs/add/operator/distinctUntilChanged'
12-
import 'rxjs/add/operator/map'
13-
import 'rxjs/add/operator/filter'
14-
import 'rxjs/add/operator/merge'
4+
import {
5+
catchError,
6+
switchMap,
7+
debounceTime,
8+
takeUntil,
9+
map,
10+
filter,
11+
merge,
12+
} from 'rxjs/operators'
1513

1614
import { makeDebugger, isEmptyValue, EVENT } from '../../utils'
1715
import {
@@ -37,24 +35,28 @@ export default class Pockect {
3735
this.stop$ = new Subject() // esc, pageClick ...
3836
// TODO: netfix search use throttle
3937
// see: https://www.youtube.com/watch?v=XRYN2xt11Ek
40-
this.cmdInput$ = this.input$.debounceTime(200) // .distinctUntilChanged()
38+
this.cmdInput$ = this.input$.pipe(debounceTime(200)) // .distinctUntilChanged()
4139

4240
PubSub.subscribe(EVENT.LOGIN_PANEL, () => {
4341
this.store.handleLogin()
4442
this.input$.next('/login/')
4543
})
4644

47-
this.cmdSuggestionCommon = this.cmdInput$
48-
.filter(startWithSlash)
49-
.switchMap(q => this.advisor.relateSuggestions$(q).takeUntil(this.stop$))
50-
.catch(() => Observable.of([]))
45+
this.cmdSuggestionCommon = this.cmdInput$.pipe(
46+
filter(startWithSlash),
47+
switchMap(q =>
48+
this.advisor.relateSuggestions$(q).pipe(takeUntil(this.stop$))
49+
),
50+
catchError(() => of([]))
51+
)
5152

52-
this.cmdSuggestionSpecial = this.cmdInput$
53-
.filter(startWithSpecialPrefix) // > < ?
54-
.map(this.advisor.specialSuggestions)
53+
this.cmdSuggestionSpecial = this.cmdInput$.pipe(
54+
filter(startWithSpecialPrefix),
55+
map(this.advisor.specialSuggestions)
56+
)
5557

56-
this.cmdSuggesttion$ = this.cmdSuggestionCommon.merge(
57-
this.cmdSuggestionSpecial
58+
this.cmdSuggesttion$ = this.cmdSuggestionCommon.pipe(
59+
merge(this.cmdSuggestionSpecial)
5860
)
5961
}
6062

@@ -75,6 +77,6 @@ export default class Pockect {
7577
}
7678

7779
emptyInput() {
78-
return this.input$.filter(isEmptyValue)
80+
return this.input$.pipe(filter(isEmptyValue))
7981
}
8082
}

containers/Preview/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ const Viewer = ({
101101
case TYPE.PREVIEW_SET_CATEGORY: {
102102
return <CategorySetter editData={editCommunityData} />
103103
}
104+
case TYPE.PREVIEW_CREATE_THREAD: {
105+
return <h3>PREVIEW_CREATE_THREAD</h3>
106+
}
104107
case TYPE.PREVIEW_SET_THREAD: {
105108
return <ThreadSetter editData={editCommunityData} />
106109
}

containers/Preview/logic.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const sr71$ = new SR71({
2828
EVENT.NAV_SET_CATEGORY,
2929
EVENT.NAV_UPDATE_CATEGORY,
3030
// threahd
31+
EVENT.NAV_CREATE_THREAD,
3132
EVENT.NAV_SET_THREAD,
3233
// permission
3334
EVENT.NAV_UPDATE_PERMISSION,
@@ -173,6 +174,16 @@ const DataResolver = [
173174
holdPage()
174175
},
175176
},
177+
{
178+
match: asyncRes(EVENT.NAV_CREATE_THREAD),
179+
action: res => {
180+
const event = res[EVENT.NAV_CREATE_THREAD]
181+
182+
store.markState({ editCommunity: event.data })
183+
store.open(event.type)
184+
holdPage()
185+
},
186+
},
176187
{
177188
match: asyncRes(EVENT.NAV_SET_THREAD),
178189
action: res => {

stores/PreviewStore/index.js renamed to containers/Preview/store.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { types as t, getParent } from 'mobx-state-tree'
77

88
// import { CMS_THREADS } from '../../config'
99

10-
import { Community, Category, Tag, Post, User } from '../SharedModel'
10+
import { Community, Category, Tag, Post, User } from '../../stores/SharedModel'
1111
import { markStates, TYPE, unholdPage, stripMobx } from '../../utils'
1212

1313
// const debug = makeDebugger('S:PreviewStore')
@@ -44,6 +44,7 @@ const PreviewStore = t
4444
TYPE.PREVIEW_SET_CATEGORY,
4545
TYPE.PREVIEW_UPDATE_CATEGORY,
4646
// thread
47+
TYPE.PREVIEW_CREATE_THREAD,
4748
TYPE.PREVIEW_SET_THREAD,
4849
// permission
4950
TYPE.PREVIEW_CREATE_PERMISSION,

stores/PreviewStore/test/index.test.js renamed to containers/Preview/tests/store.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* PreviewStore store test
3-
*
4-
*/
2+
* PreviewStore store test
3+
*
4+
*/
55
// import PreviewStore from '../index'
66

77
it('1 + 1 = 2', () => {

containers/Sidebar/styles/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import styled from 'styled-components'
22

33
/* import { darken } from 'polished' */
4-
import { Img } from '../../../components'
4+
import Img from '../../../components/Img'
55
import { theme } from '../../../utils'
66

77
// 纯css,div隐藏滚动条,保留鼠标滚动效果。

0 commit comments

Comments
 (0)