Skip to content

Commit

Permalink
- fixed #108
Browse files Browse the repository at this point in the history
  • Loading branch information
czy0729 committed Jun 23, 2023
1 parent 687103a commit bedd4fa
Show file tree
Hide file tree
Showing 22 changed files with 144 additions and 253 deletions.
9 changes: 3 additions & 6 deletions src/components/render-html/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,9 @@ export async function fetchMediaQueue(type?: string, id?: unknown) {
topicId: item.id
})
} else if (item.type === 'mono') {
await subjectStore.fetchMono(
{
monoId: item.id
},
true
)
await subjectStore.fetchMono({
monoId: item.id
})
}

await sleep()
Expand Down
1 change: 1 addition & 0 deletions src/screens/_/item/post/ds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const DEFAULT_PROPS = {
index: 0 as number,
styles: {} as ReturnType<typeof memoStyles>,
contentStyle: {} as Props['contentStyle'],
extraStyle: {} as Props['contentStyle'],
topicId: '' as TopicId,
authorId: '' as Props['authorId'],
avatar: '' as Props['avatar'],
Expand Down
5 changes: 3 additions & 2 deletions src/screens/_/item/post/icon-extra/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import React from 'react'
import { Flex, Iconfont } from '@components'
import { _, rakuenStore, uiStore } from '@stores'
import { info, confirm, getCommentPlainText, copy } from '@utils'
import { info, confirm, getCommentPlainText, copy, stl } from '@utils'
import { obc } from '@utils/decorators'
import { SHARE_MODE } from '@constants'
import { Popover } from '../../../base'
import { styles } from './styles'

function IconExtra(
{
style,
topicId,
id,
formhash,
Expand All @@ -41,7 +42,7 @@ function IconExtra(

return (
<Popover
style={styles.touch}
style={stl(styles.touch, style)}
data={data}
onSelect={title => {
if (title === '翻译') {
Expand Down
2 changes: 2 additions & 0 deletions src/screens/_/item/post/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const ItemPost = obc(
inViewY,
index,
contentStyle,
extraStyle,
avatar,
userId,
userName,
Expand Down Expand Up @@ -98,6 +99,7 @@ export const ItemPost = obc(
index={index}
styles={memoStyles()}
contentStyle={contentStyle}
extraStyle={extraStyle}
topicId={$?.topicId}
authorId={authorId}
avatar={avatar}
Expand Down
3 changes: 3 additions & 0 deletions src/screens/_/item/post/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const Item = memo(
index,
styles,
contentStyle,
extraStyle,
topicId,
authorId,
avatar,
Expand Down Expand Up @@ -110,6 +111,7 @@ const Item = memo(
</Name>
</Flex.Item>
<IconExtra
style={extraStyle}
topicId={topicId}
id={id}
formhash={formhash}
Expand Down Expand Up @@ -162,6 +164,7 @@ const Item = memo(
.map(item => (
<ItemSub
key={item.id}
extraStyle={extraStyle}
id={item.id}
message={item.message}
userId={item.userId}
Expand Down
3 changes: 2 additions & 1 deletion src/screens/_/item/post/sub/ds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2022-10-18 04:21:53
* @Last Modified by: czy0729
* @Last Modified time: 2023-04-01 11:52:49
* @Last Modified time: 2023-06-24 06:26:48
*/
import { _ } from '@stores'
import { EVENT } from '@constants'
Expand All @@ -13,6 +13,7 @@ import { memoStyles } from './styles'
export const DEFAULT_PROPS = {
navigation: {} as Navigation,
styles: {} as ReturnType<typeof memoStyles>,
extraStyle: {} as Props['extraStyle'],
topicId: '' as TopicId,
authorId: '' as Props['authorId'],
avatar: '' as Props['avatar'],
Expand Down
4 changes: 3 additions & 1 deletion src/screens/_/item/post/sub/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2020-12-21 16:03:04
* @Last Modified by: czy0729
* @Last Modified time: 2023-04-05 02:28:02
* @Last Modified time: 2023-06-24 06:25:49
*/
import React from 'react'
import { rakuenStore } from '@stores'
Expand All @@ -14,6 +14,7 @@ import { memoStyles } from './styles'
export default obc(
(
{
extraStyle,
authorId,
avatar,
erase,
Expand Down Expand Up @@ -47,6 +48,7 @@ export default obc(
<ItemSub
navigation={navigation}
styles={memoStyles()}
extraStyle={extraStyle}
topicId={$?.topicId}
authorId={authorId}
avatar={avatar}
Expand Down
4 changes: 3 additions & 1 deletion src/screens/_/item/post/sub/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2022-10-18 04:35:04
* @Last Modified by: czy0729
* @Last Modified time: 2023-05-17 17:29:34
* @Last Modified time: 2023-06-24 06:28:55
*/
import React from 'react'
import { View } from 'react-native'
Expand Down Expand Up @@ -31,6 +31,7 @@ export default memo(
({
navigation,
styles,
extraStyle,
topicId,
authorId,
avatar,
Expand Down Expand Up @@ -169,6 +170,7 @@ export default memo(
</Name>
</Flex.Item>
<IconExtra
style={extraStyle}
topicId={topicId}
id={id}
formhash={formhash}
Expand Down
3 changes: 3 additions & 0 deletions src/screens/_/item/post/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export type Props = {
/** 容器样式 */
contentStyle?: ViewStyle

/** 右侧菜单按钮样式 */
extraStyle?: ViewStyle

/** 头像地址 */
avatar?: string

Expand Down
3 changes: 2 additions & 1 deletion src/screens/home/mono/item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2022-03-15 02:19:41
* @Last Modified by: czy0729
* @Last Modified time: 2023-04-19 17:53:06
* @Last Modified time: 2023-06-24 06:24:00
*/
import React from 'react'
import { _ } from '@stores'
Expand All @@ -27,6 +27,7 @@ function Item({ item, index }, { navigation }: Ctx) {
<ItemPost
navigation={navigation}
contentStyle={styles.contentStyle}
extraStyle={styles.extraStyle}
index={index}
event={EVENT}
matchLink={false}
Expand Down
9 changes: 6 additions & 3 deletions src/screens/home/mono/item/styles.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/*
* @Author: czy0729
* @Date: 2022-08-25 17:24:38
* @Last Modified by: czy0729
* @Last Modified time: 2022-08-25 17:24:38
* @Last Modified by: czy0729
* @Last Modified time: 2023-06-24 06:27:35
*/
import { _ } from '@stores'

export const memoStyles = _.memoStyles(() => ({
contentStyle: {
paddingRight: _.wind - _.sm
paddingRight: _.wind - _.md
},
extraStyle: {
marginRight: -2
}
}))
10 changes: 5 additions & 5 deletions src/screens/home/mono/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
* @Last Modified time: 2022-09-25 04:17:23
*/
import React from 'react'
import { ListView } from '@components'
import { PaginationList2 } from '@_'
import { _ } from '@stores'
import { keyExtractor } from '@utils'
import { obc } from '@utils/decorators'
import { keyExtractor } from '@utils/app'
import Info from '../info'
import { Ctx } from '../types'

function List({ renderItem, onScroll }, { $ }: Ctx) {
return (
<ListView
<PaginationList2
contentContainerStyle={_.container.bottom}
keyExtractor={keyExtractor}
data={$.monoComments}
data={$.list}
scrollEventThrottle={16}
scrollToTop
limit={20}
ListHeaderComponent={<Info />}
progressViewOffset={_.ios(_.statusBarHeight, 0)}
removeClippedSubviews={$.list.length >= 100}
renderItem={renderItem}
onScroll={onScroll}
onHeaderRefresh={$.onHeaderRefresh}
onFooterRefresh={$.fetchMono}
/>
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/screens/home/mono/store/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class Action extends Fetch {
userStore.userInfo
)

return this.fetchMono(true, false)
return this.fetchMono()
}

/** 取消收藏人物 */
Expand All @@ -78,7 +78,7 @@ export default class Action extends Fetch {
feedback()
info('已取消收藏')

return this.fetchMono(true, false)
return this.fetchMono()
}

/** 开启 ICO */
Expand Down
27 changes: 6 additions & 21 deletions src/screens/home/mono/store/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,16 @@
* @Last Modified time: 2023-04-21 18:32:59
*/
import { subjectStore, tinygrailStore, systemStore } from '@stores'
import { getTimestamp, omit, opitimize } from '@utils'
import { getTimestamp, omit } from '@utils'
import { get, update } from '@utils/kv'
import Computed from './computed'

export default class Fetch extends Computed {
/**
* 人物信息和吐槽箱
* @opitimize 1h
* */
fetchMono = (refresh: boolean = false, isOpitimize = true) => {
if (
isOpitimize &&
refresh === true &&
opitimize(this.mono, 60 * 60) &&
this.monoComments.list.length
) {
return true
}

return subjectStore.fetchMono(
{
monoId: this.monoId
},
refresh
)
/** 人物信息和吐槽箱 */
fetchMono = () => {
return subjectStore.fetchMono({
monoId: this.monoId
})
}

/** 角色信息 */
Expand Down
6 changes: 3 additions & 3 deletions src/screens/home/mono/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ export default class ScreenMono extends Action {

// 设置开启小圣杯和是虚拟人物
if (this.tinygrail && this.monoId.includes('character/')) {
return Promise.all([this.fetchMono(true), this.fetchChara()])
return Promise.all([this.fetchMono(), this.fetchChara()])
}

return this.fetchMono(true)
return this.fetchMono()
}

/** 下拉刷新 */
onHeaderRefresh = () => {
return this.fetchMono(true)
return this.fetchMono()
}
}
2 changes: 1 addition & 1 deletion src/screens/home/v2/list/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const List = memo(
progressViewOffset={_.ios(styles.contentContainerStyle.paddingTop - _.sm, 0)}
keyExtractor={keyExtractor}
data={data.list}
limit={12}
limit={20}
scrollToTop={scrollToTop}
keyboardDismissMode='on-drag'
ListHeaderComponent={ListHeaderComponent}
Expand Down
1 change: 1 addition & 0 deletions src/screens/home/v2/store/ds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const STATE: State & ExcludeState = {
subject: {},
ep_status: ''
},
boot: 0,
...EXCLUDE_STATE,
_loaded: false
}
Expand Down
24 changes: 17 additions & 7 deletions src/screens/home/v2/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* @Author: czy0729
* @Date: 2023-02-27 20:26:27
* @Last Modified by: czy0729
* @Last Modified time: 2023-02-27 23:36:27
* @Last Modified time: 2023-06-23 18:13:21
*/
import * as Device from 'expo-device'
import { _, systemStore, userStore } from '@stores'
import { feedback, getTimestamp, info } from '@utils'
import { date, feedback, getTimestamp, info } from '@utils'
import { t } from '@utils/fetch'
import { update } from '@utils/kv'
import {
Expand Down Expand Up @@ -102,7 +102,6 @@ class ScreenHomeV2 extends Action {
initQueue = async () => {
const data = await Promise.all([userStore.fetchCollection()])
if (data?.[0]?.list?.length) return this.fetchSubjectsQueue(data[0].list)

return false
}

Expand All @@ -112,18 +111,29 @@ class ScreenHomeV2 extends Action {

setTimeout(() => {
if (!this.userId || !DEVICE_MODEL_NAME) return false

const boot = this.state.boot + 1
this.setState({
boot
})
this.save()

update(`u_${this.userId}`, {
b: Device.brand,
y: Device.deviceYearClass,
i: Device.modelId,
d: Device.modelName,
o: Device.osVersion,
m: Device.totalMemory,
m: `${Math.floor(Device.totalMemory / 1000 / 1000 / 1000)}G`,
v: VERSION_GITHUB_RELEASE,
s: _.statusBarHeight,
h: _.headerHeight,
t: _.tabBarHeight,
a: systemStore.advance,
n: boot,
l: {
s: _.statusBarHeight,
h: _.headerHeight,
t: _.tabBarHeight
},
t: date('Y-m-d H:i:s', getTimestamp()),
ipa: IOS_IPA
})
}, 8000)
Expand Down
2 changes: 2 additions & 0 deletions src/screens/home/v2/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export type State = {
ep_status: string | number
}

boot: number

/** 本地数据读取完成 */
_loaded: Loaded
}
Expand Down
Loading

0 comments on commit bedd4fa

Please sign in to comment.