From d95a224c60e02f5c096b569dda7b414720cfc5d8 Mon Sep 17 00:00:00 2001 From: xuwenyang Date: Sat, 9 Nov 2019 14:46:48 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=AD=98=E8=8D=89=E7=A8=BF=E9=80=BB?= =?UTF-8?q?=E8=BE=91=20=E5=86=99=E6=97=A5=E8=AE=B0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=AF=8F=E9=9A=945=E7=A7=92=E4=BF=9D=E5=AD=98=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E7=BC=96=E8=BE=91=E5=86=85=E5=AE=B9=E4=BD=9C=E4=B8=BA?= =?UTF-8?q?=E8=8D=89=E7=A8=BF=20=E4=BF=9D=E5=AD=98=E6=97=A5=E8=AE=B0?= =?UTF-8?q?=E6=88=96=E5=8F=96=E6=B6=88=E4=BF=9D=E5=AD=98=EF=BC=8C=E9=80=80?= =?UTF-8?q?=E5=87=BA=E9=A1=B5=E9=9D=A2=E6=97=B6=E6=B8=85=E7=A9=BA=E8=8D=89?= =?UTF-8?q?=E7=A8=BF=20=E5=BC=82=E5=B8=B8=E9=80=80=E5=87=BA=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E8=8B=A5=E6=9C=89=E4=B9=8B=E5=89=8D=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E4=B8=8B=E6=9D=A5=E7=9A=84=E8=8D=89=E7=A8=BF=E5=88=99=E6=81=A2?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/component/notification/notification.js | 1 - .../notification/notificationList.js | 12 ++----- src/page/WritePage.js | 33 +++++++++++++++++-- src/util/token.js | 4 +-- 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/component/notification/notification.js b/src/component/notification/notification.js index 70d3898..a6970cd 100644 --- a/src/component/notification/notification.js +++ b/src/component/notification/notification.js @@ -28,7 +28,6 @@ export default class Notification extends Component { if(msg && msg.type) { if(msg.type == 1) { return this.renderComment(msg); - } else if(msg.type == 2) { return this.renderFollow(msg); } else if(msg.type == 3) { diff --git a/src/component/notification/notificationList.js b/src/component/notification/notificationList.js index 601e4ce..bec7903 100644 --- a/src/component/notification/notificationList.js +++ b/src/component/notification/notificationList.js @@ -34,6 +34,7 @@ export default class NotificationList extends Component { (async () => { try { let notifications = await this.getMessages(); + this.notificationsData = notifications; this.setNotifications(notifications); this.setState({error: false}); @@ -230,16 +231,7 @@ export default class NotificationList extends Component { } } -// NotificationList.propTypes = { -// isHistory: PropTypes.boolean, -// onRefresh: PropTypes.func, -// isSetRead: PropTypes.boolean -// }; -// -// NotificationList.defaultProps = { -// isHistory: true, -// isSetRead: false, -// }; + diff --git a/src/page/WritePage.js b/src/page/WritePage.js index 3c6f2af..305023e 100644 --- a/src/page/WritePage.js +++ b/src/page/WritePage.js @@ -24,7 +24,8 @@ import {Icon} from '../style/icon'; import Color from '../style/color'; import Api from '../util/api'; import Msg from '../util/msg'; -import Event from "../util/event"; +import Event from '../util/event'; +import Token from '../util/token'; import NotebookLine from '../component/notebook/notebookLine'; import ImageAction from '../component/image/imageAction' @@ -54,6 +55,8 @@ export default class WritePage extends Component { fadeAnimOpacity: new Animated.Value(0), fadeAnimHeight: new Animated.Value(0) } + + this.draftTimer = null; } static options(passProps) { @@ -102,6 +105,9 @@ export default class WritePage extends Component { } closePage() { + clearInterval(this.draftTimer); + Token.setDraft(''); + this.contentInput.blur(); if (this.diary || this.topic) { Navigation.pop(this.props.componentId); @@ -112,10 +118,20 @@ export default class WritePage extends Component { } componentDidMount() { + Token.getDraft().then(draft => { + if(draft) { + this.setState({ + content: draft, + }); + } + }); + + this.resetDraftTimer(); + this.loadNotebook().then(notebookCount => { if(notebookCount > 0) { InteractionManager.runAfterInteractions(() => { - this && this.contentInput && this.contentInput.focus(); + this.contentInput && this.contentInput.focus(); }); } else { Alert.alert('提示', '没有可用日记本,无法写日记',[ @@ -140,6 +156,19 @@ export default class WritePage extends Component { this.notebookListener.remove(); } + resetDraftTimer() { + if(this.draftTimer) { + clearInterval(this.draftTimer); + } + + this.draftTimer = setInterval(() => { + let content = this.state.content; + if(content) { + Token.setDraft(content); + } + }, 5000); + } + openModal() { this.contentInput.blur(); this.setState({modalVisible: true}); diff --git a/src/util/token.js b/src/util/token.js index 36fe08c..d0d1bb5 100644 --- a/src/util/token.js +++ b/src/util/token.js @@ -2,7 +2,7 @@ import AsyncStorage from '@react-native-community/async-storage'; var base64 = require('base-64'); -class TokenManager { +class Token { generateToken(username, password) { return 'Basic ' + base64.encode(username + ":" + password); @@ -101,4 +101,4 @@ class TokenManager { } -export default new TokenManager() +export default new Token() From 4bdedaf1703013cb0d742d65717c351c1c42812e Mon Sep 17 00:00:00 2001 From: xuwenyang Date: Sat, 9 Nov 2019 17:06:37 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=8F=90=E9=86=92=20=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E5=92=8Cok=E7=BB=B7=E5=B1=95=E7=A4=BA=E5=A4=B4=E5=83=8F=20?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E5=A4=B4=E5=83=8F=E8=BF=9B=E5=85=A5=E5=AF=B9?= =?UTF-8?q?=E6=96=B9=E7=94=A8=E6=88=B7=E8=AF=A6=E6=83=85=E9=A1=B5=20?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E5=85=B6=E4=BB=96=E5=8C=BA=E5=9F=9F=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E6=97=A5=E8=AE=B0=E8=AF=A6=E6=83=85=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/component/notification/notification.js | 66 +++++++++++++------ .../notification/notificationList.js | 38 +++++++++-- src/component/userIcon.js | 3 +- src/page/NotificationPage.js | 9 --- 4 files changed, 79 insertions(+), 37 deletions(-) diff --git a/src/component/notification/notification.js b/src/component/notification/notification.js index a6970cd..619bbde 100644 --- a/src/component/notification/notification.js +++ b/src/component/notification/notification.js @@ -2,21 +2,11 @@ import React, {Component} from 'react'; import {Image, StyleSheet, Text, View, TouchableOpacity} from 'react-native'; import Ionicons from 'react-native-vector-icons/Ionicons'; +import UserIcon from '../userIcon'; import Touchable from '../touchable'; import Color from '../../style/color'; -function unique(array) { - let n = []; - for(let i=0; i it.content.author.name)).join('、'); - const body = `${users} 回复了你`; + const max = 5; + const formatMsg = {}; + + let key = null; + for (let i=0; i this.props.onCommentPress(msg)}> - {body} + { + Object.keys(formatMsg).map((it, index) => { + if (index >= max) { + return null; + } + + return ( + this.props.onUserIconPress(formatMsg[it])} + /> + ); + }) + } + + {Object.keys(formatMsg).length > max ? '等' : ''}回复了你 + {this.renderDeleteButton(msg)} @@ -76,7 +95,11 @@ export default class Notification extends Component { } renderLike(msg) { - const body = `${msg.content.user.name} 给了你一个OK绷`; + const userData = { + userId: msg.content.user.id, + userIcon: msg.link_user_icon, + userName: msg.content.user.name, + } return ( this.props.onLikePress(msg)}> @@ -88,7 +111,12 @@ export default class Notification extends Component { } style={localStyle.icon2} /> - {body} + this.props.onUserIconPress(userData)} + /> + 给了你一个OK绷 {this.renderDeleteButton(msg)} @@ -108,17 +136,17 @@ const localStyle = StyleSheet.create({ icon: { marginRight: 10, marginTop: 1, - lineHeight: 20 + lineHeight: 28 }, text: { flex: 1, - lineHeight: 20 + lineHeight: 28 }, icon2: { width: 15, height: 15, marginRight: 10, - marginTop: 4, + marginTop: 7, }, delete: { lineHeight: 20, diff --git a/src/component/notification/notificationList.js b/src/component/notification/notificationList.js index bec7903..74cb574 100644 --- a/src/component/notification/notificationList.js +++ b/src/component/notification/notificationList.js @@ -107,6 +107,29 @@ export default class NotificationList extends Component { } } + _onUserIconPress(msg) { + Navigation.push(this.props.componentId, { + component: { + name: 'User', + options: { + bottomTabs: { + visible: false, + + // hide bottom tab for android + drawBehind: true, + animate: true + } + }, + passProps: { + user: { + id: msg.userId, + name: msg.userName, + } + } + } + }); + } + _onCommentPress(msg) { Navigation.push(this.props.componentId, { component: { @@ -160,7 +183,7 @@ export default class NotificationList extends Component { _onLikePress(msg) { Navigation.push(this.props.componentId, { component: { - name: 'User', + name: 'DiaryDetail', options: { bottomTabs: { visible: false, @@ -171,7 +194,7 @@ export default class NotificationList extends Component { } }, passProps: { - user: msg.content.user + diaryId: msg.content.dairy_id } } }); @@ -200,11 +223,12 @@ export default class NotificationList extends Component { renderItem={({item}) => { return ( ); }} diff --git a/src/component/userIcon.js b/src/component/userIcon.js index feb6a69..7753a9a 100644 --- a/src/component/userIcon.js +++ b/src/component/userIcon.js @@ -24,8 +24,7 @@ export default class UserIcon extends Component { render() { return ( - r1 !== r2 - // }); - // this.state = ({ - // messages: [], - // messagesDataSource: ds, - // refreshing: true, - // }); } navigationButtonPressed({buttonId}) { From 2e8c40d119a177fbc7e253ecec88a1ceefd73c45 Mon Sep 17 00:00:00 2001 From: xuwenyang Date: Sat, 9 Nov 2019 22:04:18 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=85=B3=E6=B3=A8=E6=8F=90=E9=86=92?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/component/notification/notification.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/component/notification/notification.js b/src/component/notification/notification.js index 619bbde..efb2657 100644 --- a/src/component/notification/notification.js +++ b/src/component/notification/notification.js @@ -81,13 +81,17 @@ export default class Notification extends Component { } renderFollow(msg) { - const body = `${msg.content.user.name} 关注了你`; + const userIcon = msg.link_user_icon; return ( this.props.onFollowPress(msg)}> - - {body} + + + 关注了你 {this.renderDeleteButton(msg)} @@ -145,7 +149,8 @@ const localStyle = StyleSheet.create({ icon2: { width: 15, height: 15, - marginRight: 10, + marginLeft: -1, + marginRight: 9, marginTop: 7, }, delete: { From 55a1003c90003892bc66e424e8e78fca0e8c6de1 Mon Sep 17 00:00:00 2001 From: xuwenyang Date: Sat, 4 Jan 2020 16:02:01 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=BF=9B=E5=85=A5=E8=87=AA=E5=B7=B1?= =?UTF-8?q?=E7=9A=84=E4=B8=BB=E9=A1=B5=E5=8F=B3=E4=B8=8A=E8=A7=92=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/page/UserPage.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/page/UserPage.js b/src/page/UserPage.js index 8d74bf4..2456fc2 100644 --- a/src/page/UserPage.js +++ b/src/page/UserPage.js @@ -132,21 +132,34 @@ export default class UserPage extends Component { componentDidMount() { if(this.userId) { - Api.getRelation(this.userId) - .then(re => { - this.followed = re; - if(this.followed) { + Api.getSelfInfoByStore() + .then(user => { + if(user && user.id == this.userId) { Navigation.mergeOptions(this.props.componentId, { topBar: { rightButtons: [{ - id: 'navButtonFollowSelected', - icon: Icon.navButtonFollowSelected + id: 'setting', + icon: Icon.navButtonSetting }] } }); + } else { + Api.getRelation(this.userId) + .then(re => { + this.followed = re; + if(this.followed) { + Navigation.mergeOptions(this.props.componentId, { + topBar: { + rightButtons: [{ + id: 'navButtonFollowSelected', + icon: Icon.navButtonFollowSelected + }] + } + }); + } + }); } }); - } this.notebookListener = DeviceEventEmitter.addListener(Event.updateNotebooks, (param) => {