mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-21 12:21:31 +03:00
added show schedule and remove function as part 1
This commit is contained in:
parent
ca875a3dc1
commit
d56469919d
@ -57,7 +57,7 @@ class CommentsView extends PureComponent {
|
|||||||
handleOnUserPress={handleOnUserPress}
|
handleOnUserPress={handleOnUserPress}
|
||||||
isLoggedIn={isLoggedIn}
|
isLoggedIn={isLoggedIn}
|
||||||
isShowMoreButton={commentNumber === 1 && item.children > 0}
|
isShowMoreButton={commentNumber === 1 && item.children > 0}
|
||||||
voteCount={item.vote_count}
|
voteCount={item.net_votes}
|
||||||
isShowSubComments={isShowSubComments}
|
isShowSubComments={isShowSubComments}
|
||||||
key={item.permlink}
|
key={item.permlink}
|
||||||
marginLeft={marginLeft}
|
marginLeft={marginLeft}
|
||||||
|
@ -9,6 +9,7 @@ export default {
|
|||||||
'ko-KR': require('./ko-KR.json'),
|
'ko-KR': require('./ko-KR.json'),
|
||||||
'lt-LT': require('./lt-LT.json'),
|
'lt-LT': require('./lt-LT.json'),
|
||||||
'pt-PT': require('./pt-PT.json'),
|
'pt-PT': require('./pt-PT.json'),
|
||||||
|
'fa-IR': require('./fa-IR.json'),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const locales = [
|
export const locales = [
|
||||||
@ -22,4 +23,5 @@ export const locales = [
|
|||||||
{ id: 'ko-KR', name: 'Korean' },
|
{ id: 'ko-KR', name: 'Korean' },
|
||||||
{ id: 'lt-LT', name: 'Lithuanian' },
|
{ id: 'lt-LT', name: 'Lithuanian' },
|
||||||
{ id: 'pt-PT', name: 'Porteguese' },
|
{ id: 'pt-PT', name: 'Porteguese' },
|
||||||
|
{ id: 'fa-IR', name: 'Persian' },
|
||||||
];
|
];
|
||||||
|
@ -8,6 +8,7 @@ export default [
|
|||||||
'Porteguese',
|
'Porteguese',
|
||||||
'Russian',
|
'Russian',
|
||||||
'Turkish',
|
'Turkish',
|
||||||
|
'Persian',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const VALUE = [
|
export const VALUE = [
|
||||||
@ -20,4 +21,5 @@ export const VALUE = [
|
|||||||
'pt-PT',
|
'pt-PT',
|
||||||
'ru-RU',
|
'ru-RU',
|
||||||
'tr-TR',
|
'tr-TR',
|
||||||
|
'fa-IR',
|
||||||
];
|
];
|
||||||
|
@ -223,7 +223,7 @@ export const schedule = (
|
|||||||
upvote,
|
upvote,
|
||||||
scheduleDate,
|
scheduleDate,
|
||||||
) => api
|
) => api
|
||||||
.post('/api/schedules', {
|
.post('/schedules', {
|
||||||
username: user,
|
username: user,
|
||||||
category: tags[0],
|
category: tags[0],
|
||||||
title,
|
title,
|
||||||
@ -238,18 +238,18 @@ export const schedule = (
|
|||||||
})
|
})
|
||||||
.then(resp => resp.data);
|
.then(resp => resp.data);
|
||||||
|
|
||||||
export const getSchedules = user => api.get(`/api/schedules/${user}`).then(resp => resp.data);
|
export const getSchedules = user => api.get(`/schedules/${user}`).then(resp => resp.data);
|
||||||
|
|
||||||
export const removeSchedule = (id, user) => api.delete(`/api/schedules/${user}/${id}`);
|
export const removeSchedule = (user, id) => api.delete(`/schedules/${user}/${id}`);
|
||||||
|
|
||||||
export const moveSchedule = (id, user) => api.put(`/api/schedules/${user}/${id}`);
|
export const moveSchedule = (id, user) => api.put(`/schedules/${user}/${id}`);
|
||||||
|
|
||||||
// Old image service
|
// Old image service
|
||||||
// Images
|
// Images
|
||||||
|
|
||||||
export const getImages = user => api.get(`api/images/${user}`).then(resp => resp.data);
|
export const getImages = user => api.get(`api/images/${user}`).then(resp => resp.data);
|
||||||
|
|
||||||
export const addMyImage = (user, url) => api.post('/api/image', { username: user, image_url: url });
|
export const addMyImage = (user, url) => api.post('/image', { username: user, image_url: url });
|
||||||
|
|
||||||
export const uploadImage = (file) => {
|
export const uploadImage = (file) => {
|
||||||
const fData = new FormData();
|
const fData = new FormData();
|
||||||
|
@ -192,7 +192,7 @@ export const getFollowSearch = (user, targetUser) => new Promise((resolve, rejec
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getIsMuted = async (username, targetUsername) => {
|
export const getIsMuted = async (targetUsername, username) => {
|
||||||
let resp;
|
let resp;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import {
|
import { Platform, BackHandler, Alert, NetInfo } from 'react-native';
|
||||||
Platform, BackHandler, Alert, NetInfo,
|
|
||||||
} from 'react-native';
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { addLocaleData } from 'react-intl';
|
import { addLocaleData } from 'react-intl';
|
||||||
import Config from 'react-native-config';
|
import Config from 'react-native-config';
|
||||||
@ -20,6 +18,8 @@ import tr from 'react-intl/locale-data/tr';
|
|||||||
import ko from 'react-intl/locale-data/ko';
|
import ko from 'react-intl/locale-data/ko';
|
||||||
import lt from 'react-intl/locale-data/lt';
|
import lt from 'react-intl/locale-data/lt';
|
||||||
import pt from 'react-intl/locale-data/pt';
|
import pt from 'react-intl/locale-data/pt';
|
||||||
|
import fa from 'react-intl/locale-data/fa';
|
||||||
|
import he from 'react-intl/locale-data/he';
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
import AUTH_TYPE from '../../../constants/authType';
|
import AUTH_TYPE from '../../../constants/authType';
|
||||||
@ -71,7 +71,7 @@ import {
|
|||||||
import ApplicationScreen from '../screen/applicationScreen';
|
import ApplicationScreen from '../screen/applicationScreen';
|
||||||
import { Launch } from '../..';
|
import { Launch } from '../..';
|
||||||
|
|
||||||
addLocaleData([...en, ...ru, ...de, ...id, ...it, ...hu, ...tr, ...ko, ...pt, ...lt]);
|
addLocaleData([...en, ...ru, ...de, ...id, ...it, ...hu, ...tr, ...ko, ...pt, ...lt, ...fa]);
|
||||||
|
|
||||||
class ApplicationContainer extends Component {
|
class ApplicationContainer extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -87,7 +87,7 @@ class ApplicationContainer extends Component {
|
|||||||
const { isIos } = this.state;
|
const { isIos } = this.state;
|
||||||
let isConnected;
|
let isConnected;
|
||||||
|
|
||||||
await NetInfo.isConnected.fetch().then((_isConnected) => {
|
await NetInfo.isConnected.fetch().then(_isConnected => {
|
||||||
isConnected = _isConnected;
|
isConnected = _isConnected;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -104,9 +104,7 @@ class ApplicationContainer extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
const {
|
const { isDarkTheme: _isDarkTheme, selectedLanguage, isLogingOut, isConnected } = this.props;
|
||||||
isDarkTheme: _isDarkTheme, selectedLanguage, isLogingOut, isConnected,
|
|
||||||
} = this.props;
|
|
||||||
|
|
||||||
if (_isDarkTheme !== nextProps.isDarkTheme || selectedLanguage !== nextProps.selectedLanguage) {
|
if (_isDarkTheme !== nextProps.isDarkTheme || selectedLanguage !== nextProps.selectedLanguage) {
|
||||||
this.setState({ isRenderRequire: false }, () => this.setState({ isRenderRequire: true }));
|
this.setState({ isRenderRequire: false }, () => this.setState({ isRenderRequire: true }));
|
||||||
@ -136,7 +134,7 @@ class ApplicationContainer extends Component {
|
|||||||
await this._getUserData();
|
await this._getUserData();
|
||||||
};
|
};
|
||||||
|
|
||||||
_handleConntectionChange = (status) => {
|
_handleConntectionChange = status => {
|
||||||
const { dispatch, isConnected } = this.props;
|
const { dispatch, isConnected } = this.props;
|
||||||
|
|
||||||
if (isConnected !== status) {
|
if (isConnected !== status) {
|
||||||
@ -170,19 +168,19 @@ class ApplicationContainer extends Component {
|
|||||||
let realmData = [];
|
let realmData = [];
|
||||||
let currentUsername;
|
let currentUsername;
|
||||||
|
|
||||||
await getAuthStatus().then((res) => {
|
await getAuthStatus().then(res => {
|
||||||
({ currentUsername } = res);
|
({ currentUsername } = res);
|
||||||
if (res) {
|
if (res) {
|
||||||
getUserData().then(async (userData) => {
|
getUserData().then(async userData => {
|
||||||
if (userData.length > 0) {
|
if (userData.length > 0) {
|
||||||
realmData = userData;
|
realmData = userData;
|
||||||
userData.forEach((accountData, index) => {
|
userData.forEach((accountData, index) => {
|
||||||
if (
|
if (
|
||||||
!accountData.accessToken
|
!accountData.accessToken &&
|
||||||
&& !accountData.masterKey
|
!accountData.masterKey &&
|
||||||
&& !accountData.postingKey
|
!accountData.postingKey &&
|
||||||
&& !accountData.activeKey
|
!accountData.activeKey &&
|
||||||
&& !accountData.memoKey
|
!accountData.memoKey
|
||||||
) {
|
) {
|
||||||
realmData.splice(index, 1);
|
realmData.splice(index, 1);
|
||||||
if (realmData.length === 0) {
|
if (realmData.length === 0) {
|
||||||
@ -213,7 +211,7 @@ class ApplicationContainer extends Component {
|
|||||||
await switchAccount(realmObject[0].username);
|
await switchAccount(realmObject[0].username);
|
||||||
}
|
}
|
||||||
await getUser(realmObject[0].username)
|
await getUser(realmObject[0].username)
|
||||||
.then(async (accountData) => {
|
.then(async accountData => {
|
||||||
dispatch(login(true));
|
dispatch(login(true));
|
||||||
|
|
||||||
const isExistUser = await getExistUser();
|
const isExistUser = await getExistUser();
|
||||||
@ -227,7 +225,7 @@ class ApplicationContainer extends Component {
|
|||||||
}
|
}
|
||||||
this._connectNotificationServer(accountData.name);
|
this._connectNotificationServer(accountData.name);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch(err => {
|
||||||
Alert.alert(err);
|
Alert.alert(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -239,15 +237,18 @@ class ApplicationContainer extends Component {
|
|||||||
_getSettings = () => {
|
_getSettings = () => {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
|
|
||||||
getSettings().then((response) => {
|
getSettings().then(response => {
|
||||||
if (response) {
|
if (response) {
|
||||||
if (response.isDarkTheme !== '') dispatch(isDarkTheme(response.isDarkTheme));
|
if (response.isDarkTheme !== '') dispatch(isDarkTheme(response.isDarkTheme));
|
||||||
if (response.language !== '') dispatch(setLanguage(response.language));
|
if (response.language !== '') dispatch(setLanguage(response.language));
|
||||||
if (response.server !== '') dispatch(setApi(response.server));
|
if (response.server !== '') dispatch(setApi(response.server));
|
||||||
if (response.upvotePercent !== '') dispatch(setUpvotePercent(Number(response.upvotePercent)));
|
if (response.upvotePercent !== '')
|
||||||
|
dispatch(setUpvotePercent(Number(response.upvotePercent)));
|
||||||
if (response.isDefaultFooter !== '') dispatch(isDefaultFooter(response.isDefaultFooter));
|
if (response.isDefaultFooter !== '') dispatch(isDefaultFooter(response.isDefaultFooter));
|
||||||
if (response.notification !== '') {
|
if (response.notification !== '') {
|
||||||
dispatch(changeNotificationSettings({ type: 'notification', action: response.notification }));
|
dispatch(
|
||||||
|
changeNotificationSettings({ type: 'notification', action: response.notification }),
|
||||||
|
);
|
||||||
dispatch(changeAllNotificationSettings(response));
|
dispatch(changeAllNotificationSettings(response));
|
||||||
|
|
||||||
Push.setEnabled(response.notification);
|
Push.setEnabled(response.notification);
|
||||||
@ -261,7 +262,7 @@ class ApplicationContainer extends Component {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
_connectNotificationServer = (username) => {
|
_connectNotificationServer = username => {
|
||||||
const { dispatch, unreadActivityCount } = this.props;
|
const { dispatch, unreadActivityCount } = this.props;
|
||||||
const ws = new WebSocket(`${Config.ACTIVITY_WEBSOCKET_URL}?user=${username}`);
|
const ws = new WebSocket(`${Config.ACTIVITY_WEBSOCKET_URL}?user=${username}`);
|
||||||
|
|
||||||
@ -299,10 +300,10 @@ class ApplicationContainer extends Component {
|
|||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
};
|
};
|
||||||
|
|
||||||
_switchAccount = async (targetAccountUsername) => {
|
_switchAccount = async targetAccountUsername => {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
|
|
||||||
await switchAccount(targetAccountUsername).then((accountData) => {
|
await switchAccount(targetAccountUsername).then(accountData => {
|
||||||
const realmData = getUserDataWithUsername(targetAccountUsername);
|
const realmData = getUserDataWithUsername(targetAccountUsername);
|
||||||
const _currentAccount = accountData;
|
const _currentAccount = accountData;
|
||||||
_currentAccount.username = accountData.name;
|
_currentAccount.username = accountData.name;
|
||||||
|
@ -4,7 +4,9 @@ import { Alert } from 'react-native';
|
|||||||
import { injectIntl } from 'react-intl';
|
import { injectIntl } from 'react-intl';
|
||||||
|
|
||||||
// Services and Actions
|
// Services and Actions
|
||||||
import { getDrafts, removeDraft, getSchedules } from '../../../providers/esteem/esteem';
|
import {
|
||||||
|
getDrafts, removeDraft, getSchedules, removeSchedule,
|
||||||
|
} from '../../../providers/esteem/esteem';
|
||||||
|
|
||||||
// Middleware
|
// Middleware
|
||||||
|
|
||||||
@ -35,6 +37,7 @@ class DraftsContainer extends Component {
|
|||||||
// Component Life Cycle Functions
|
// Component Life Cycle Functions
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this._getDrafts();
|
this._getDrafts();
|
||||||
|
this._getSchedules();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Component Functions
|
// Component Functions
|
||||||
@ -82,6 +85,21 @@ class DraftsContainer extends Component {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_removeSchedule = (id) => {
|
||||||
|
const { currentAccount, intl } = this.props;
|
||||||
|
|
||||||
|
removeSchedule({ username: currentAccount.name, draftId: id })
|
||||||
|
.then(() => {
|
||||||
|
const { schedules } = this.state;
|
||||||
|
const newSchedules = [...schedules].filter(schedule => schedule._id !== id);
|
||||||
|
|
||||||
|
this.setState({ schedules: this._sortData(newSchedules) });
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
Alert.alert(intl.formatMessage({ id: 'alert.fail' }));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
_editDraft = (id) => {
|
_editDraft = (id) => {
|
||||||
const { navigation } = this.props;
|
const { navigation } = this.props;
|
||||||
const { drafts } = this.state;
|
const { drafts } = this.state;
|
||||||
@ -115,6 +133,7 @@ class DraftsContainer extends Component {
|
|||||||
drafts={drafts}
|
drafts={drafts}
|
||||||
schedules={schedules}
|
schedules={schedules}
|
||||||
removeDraft={this._removeDraft}
|
removeDraft={this._removeDraft}
|
||||||
|
removeSchedule={this._removeSchedule}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,10 @@ class DraftsScreen extends Component {
|
|||||||
|
|
||||||
// Component Functions
|
// Component Functions
|
||||||
|
|
||||||
_renderItem = (item) => {
|
_renderItem = (item, type) => {
|
||||||
const { currentAccount, removeDraft, editDraft } = this.props;
|
const {
|
||||||
|
currentAccount, removeDraft, editDraft, removeSchedule,
|
||||||
|
} = this.props;
|
||||||
const tags = item.tags ? item.tags.split(/[ ,]+/) : [];
|
const tags = item.tags ? item.tags.split(/[ ,]+/) : [];
|
||||||
const tag = tags[0] || '';
|
const tag = tags[0] || '';
|
||||||
const image = catchDraftImage(item.body);
|
const image = catchDraftImage(item.body);
|
||||||
@ -50,7 +52,7 @@ class DraftsScreen extends Component {
|
|||||||
username={currentAccount.name}
|
username={currentAccount.name}
|
||||||
reputation={currentAccount.reputation}
|
reputation={currentAccount.reputation}
|
||||||
handleOnPressItem={editDraft}
|
handleOnPressItem={editDraft}
|
||||||
handleOnRemoveItem={removeDraft}
|
handleOnRemoveItem={type === 'schedules' ? removeSchedule : removeDraft}
|
||||||
id={item._id}
|
id={item._id}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -80,7 +82,7 @@ class DraftsScreen extends Component {
|
|||||||
data={data}
|
data={data}
|
||||||
keyExtractor={item => item._id}
|
keyExtractor={item => item._id}
|
||||||
removeClippedSubviews={false}
|
removeClippedSubviews={false}
|
||||||
renderItem={({ item }) => this._renderItem(item)}
|
renderItem={({ item }) => this._renderItem(item, type)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
@ -76,7 +76,10 @@ class ProfileContainer extends Component {
|
|||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
const {
|
const {
|
||||||
navigation, currentAccount, activeBottomTab, isLoggedIn,
|
navigation,
|
||||||
|
currentAccount,
|
||||||
|
activeBottomTab,
|
||||||
|
isLoggedIn,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const currentUsername = currentAccount.name !== nextProps.currentAccount.name && nextProps.currentAccount.name;
|
const currentUsername = currentAccount.name !== nextProps.currentAccount.name && nextProps.currentAccount.name;
|
||||||
|
|
||||||
@ -115,34 +118,37 @@ class ProfileContainer extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_handleFollowUnfollowUser = async (isFollowAction) => {
|
_handleFollowUnfollowUser = async (isFollowAction) => {
|
||||||
const { username, isFollowing } = this.state;
|
const { isFollowing } = this.state;
|
||||||
const { currentAccount, pinCode } = this.props;
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
isProfileLoading: true,
|
isProfileLoading: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isFollowAction && !isFollowing) {
|
if (isFollowAction && !isFollowing) {
|
||||||
this._followUser(currentAccount, pinCode, currentAccount.name, username);
|
this._followUser();
|
||||||
} else {
|
} else {
|
||||||
this._unfollowUser(currentAccount, pinCode, currentAccount.name, username);
|
this._unfollowUser();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_handleMuteUnmuteUser = async (isMuteAction) => {
|
_handleMuteUnmuteUser = (isMuteAction) => {
|
||||||
const { username } = this.state;
|
|
||||||
const { currentAccount, pinCode } = this.props;
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
isProfileLoading: true,
|
isProfileLoading: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isMuteAction) {
|
if (isMuteAction) {
|
||||||
this._muteUser(currentAccount, pinCode, currentAccount.name, username);
|
this._muteUser();
|
||||||
|
} else {
|
||||||
|
this._unfollowUser();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_unfollowUser = (currentAccount, pinCode, follower, following) => {
|
_unfollowUser = () => {
|
||||||
|
const { username } = this.state;
|
||||||
|
const { currentAccount, pinCode } = this.props;
|
||||||
|
const follower = currentAccount.name;
|
||||||
|
const following = username;
|
||||||
|
|
||||||
unfollowUser(currentAccount, pinCode, {
|
unfollowUser(currentAccount, pinCode, {
|
||||||
follower,
|
follower,
|
||||||
following,
|
following,
|
||||||
@ -155,7 +161,12 @@ class ProfileContainer extends Component {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
_followUser = (currentAccount, pinCode, follower, following) => {
|
_followUser = () => {
|
||||||
|
const { username } = this.state;
|
||||||
|
const { currentAccount, pinCode } = this.props;
|
||||||
|
const follower = currentAccount.name;
|
||||||
|
const following = username;
|
||||||
|
|
||||||
followUser(currentAccount, pinCode, {
|
followUser(currentAccount, pinCode, {
|
||||||
follower,
|
follower,
|
||||||
following,
|
following,
|
||||||
@ -168,7 +179,12 @@ class ProfileContainer extends Component {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
_muteUser = async (currentAccount, pinCode, follower, following) => {
|
_muteUser = () => {
|
||||||
|
const { username } = this.state;
|
||||||
|
const { currentAccount, pinCode } = this.props;
|
||||||
|
const follower = currentAccount.name;
|
||||||
|
const following = username;
|
||||||
|
|
||||||
ignoreUser(currentAccount, pinCode, {
|
ignoreUser(currentAccount, pinCode, {
|
||||||
follower,
|
follower,
|
||||||
following,
|
following,
|
||||||
@ -184,32 +200,32 @@ class ProfileContainer extends Component {
|
|||||||
_profileActionDone = (error = null) => {
|
_profileActionDone = (error = null) => {
|
||||||
const { username } = this.state;
|
const { username } = this.state;
|
||||||
|
|
||||||
this.setState({
|
|
||||||
isProfileLoading: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
this.setState({
|
this.setState({
|
||||||
error,
|
error,
|
||||||
});
|
}, () => alert(error));
|
||||||
alert(error);
|
|
||||||
} else {
|
} else {
|
||||||
this._fetchProfile(username);
|
this._fetchProfile(username, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_fetchProfile = async (username = null) => {
|
|
||||||
|
_fetchProfile = async (username = null, isProfileAction = false) => {
|
||||||
|
const {
|
||||||
|
username: _username, isFollowing, isMuted,
|
||||||
|
} = this.state;
|
||||||
|
|
||||||
if (username) {
|
if (username) {
|
||||||
const { isLoggedIn, currentAccount } = this.props;
|
const { isLoggedIn, currentAccount } = this.props;
|
||||||
let isFollowing;
|
let _isFollowing;
|
||||||
let isMuted;
|
let _isMuted;
|
||||||
let isFavorite;
|
let isFavorite;
|
||||||
let follows;
|
let follows;
|
||||||
|
|
||||||
if (isLoggedIn && currentAccount.name !== username) {
|
if (isLoggedIn && currentAccount.name !== username) {
|
||||||
isFollowing = await getIsFollowing(username, currentAccount.name);
|
_isFollowing = await getIsFollowing(username, currentAccount.name);
|
||||||
|
|
||||||
isMuted = isFollowing ? false : await getIsMuted(username, currentAccount.name);
|
_isMuted = _isFollowing ? false : await getIsMuted(username, currentAccount.name);
|
||||||
|
|
||||||
getIsFavorite(username, currentAccount.name).then((isFav) => {
|
getIsFavorite(username, currentAccount.name).then((isFav) => {
|
||||||
isFavorite = isFav;
|
isFavorite = isFav;
|
||||||
@ -222,14 +238,23 @@ class ProfileContainer extends Component {
|
|||||||
follows = null;
|
follows = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This follow code totally a work arround
|
||||||
|
* Ceated for server response delay.
|
||||||
|
*/
|
||||||
|
if (isProfileAction && (isFollowing === _isFollowing && isMuted === _isMuted)) {
|
||||||
|
this._fetchProfile(_username, true);
|
||||||
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
follows,
|
follows,
|
||||||
isFollowing,
|
isFollowing: _isFollowing,
|
||||||
isMuted,
|
isMuted: _isMuted,
|
||||||
isFavorite,
|
isFavorite,
|
||||||
isReady: true,
|
isReady: true,
|
||||||
|
isProfileLoading: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_loadProfile = async (selectedUser = null) => {
|
_loadProfile = async (selectedUser = null) => {
|
||||||
@ -337,6 +362,7 @@ class ProfileContainer extends Component {
|
|||||||
return (
|
return (
|
||||||
<ProfileScreen
|
<ProfileScreen
|
||||||
about={user && user.about && user.about.profile}
|
about={user && user.about && user.about.profile}
|
||||||
|
activePage={activePage}
|
||||||
avatar={avatar}
|
avatar={avatar}
|
||||||
comments={comments}
|
comments={comments}
|
||||||
currency={currency}
|
currency={currency}
|
||||||
@ -359,7 +385,6 @@ class ProfileContainer extends Component {
|
|||||||
selectedQuickProfile={selectedQuickProfile}
|
selectedQuickProfile={selectedQuickProfile}
|
||||||
selectedUser={user}
|
selectedUser={user}
|
||||||
username={username}
|
username={username}
|
||||||
activePage={activePage}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ const imgTagRegex = /(<img[^>]*>)/g;
|
|||||||
const iframeRegex = /(?:<iframe[^>]*)(?:(?:\/>)|(?:>.*?<\/iframe>))/g;
|
const iframeRegex = /(?:<iframe[^>]*)(?:(?:\/>)|(?:>.*?<\/iframe>))/g;
|
||||||
const hTagRegex = /(<h([1-6])>([^<]*)<\/h([1-6])>)/g;
|
const hTagRegex = /(<h([1-6])>([^<]*)<\/h([1-6])>)/g;
|
||||||
|
|
||||||
export const markDown2Html = (input) => {
|
export const markDown2Html = input => {
|
||||||
if (!input) {
|
if (!input) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -95,13 +95,15 @@ export const markDown2Html = (input) => {
|
|||||||
return output;
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
const replaceAuthorNames = input => input.replace(authorNameRegex, (match, preceeding1, preceeding2, user) => {
|
const replaceAuthorNames = input =>
|
||||||
|
input.replace(authorNameRegex, (match, preceeding1, preceeding2, user) => {
|
||||||
const userLower = user.toLowerCase();
|
const userLower = user.toLowerCase();
|
||||||
const preceedings = (preceeding1 || '') + (preceeding2 || '');
|
const preceedings = (preceeding1 || '') + (preceeding2 || '');
|
||||||
return `${preceedings}<a class="markdown-author-link" href="${userLower}" data-author="${userLower}"> @${user}</a>`;
|
return `${preceedings}<a class="markdown-author-link" href="${userLower}" data-author="${userLower}"> @${user}</a>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const replaceTags = input => input.replace(tagsRegex, (tag) => {
|
const replaceTags = input =>
|
||||||
|
input.replace(tagsRegex, tag => {
|
||||||
if (/#[\d]+$/.test(tag)) return tag;
|
if (/#[\d]+$/.test(tag)) return tag;
|
||||||
const preceding = /^\s|>/.test(tag) ? tag[0] : '';
|
const preceding = /^\s|>/.test(tag) ? tag[0] : '';
|
||||||
tag = tag.replace('>', '');
|
tag = tag.replace('>', '');
|
||||||
@ -110,7 +112,8 @@ const replaceTags = input => input.replace(tagsRegex, (tag) => {
|
|||||||
return `${preceding}<a class="markdown-tag-link" href="${tagLower}" data-tag="${tagLower}">${tag.trim()}</a>`;
|
return `${preceding}<a class="markdown-tag-link" href="${tagLower}" data-tag="${tagLower}">${tag.trim()}</a>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleATag = input => input.replace(aTagRegex, (link) => {
|
const handleATag = input =>
|
||||||
|
input.replace(aTagRegex, link => {
|
||||||
if (dTubeRegex.test(link)) {
|
if (dTubeRegex.test(link)) {
|
||||||
const dTubeMatch = link.match(dTubeRegex)[0];
|
const dTubeMatch = link.match(dTubeRegex)[0];
|
||||||
const execLink = dTubeRegex.exec(dTubeMatch);
|
const execLink = dTubeRegex.exec(dTubeMatch);
|
||||||
@ -137,7 +140,8 @@ const handleATag = input => input.replace(aTagRegex, (link) => {
|
|||||||
|
|
||||||
const handleHTag = input => input.replace(hTagRegex, tag => `<div>${tag}</div>`);
|
const handleHTag = input => input.replace(hTagRegex, tag => `<div>${tag}</div>`);
|
||||||
|
|
||||||
const handleMarkdownLink = input => input.replace(copiedPostRegex, (link) => {
|
const handleMarkdownLink = input =>
|
||||||
|
input.replace(copiedPostRegex, link => {
|
||||||
const postMatch = link.match(copiedPostRegex);
|
const postMatch = link.match(copiedPostRegex);
|
||||||
|
|
||||||
if (postMatch) {
|
if (postMatch) {
|
||||||
@ -147,7 +151,8 @@ const handleMarkdownLink = input => input.replace(copiedPostRegex, (link) => {
|
|||||||
tag = 'busy';
|
tag = 'busy';
|
||||||
}
|
}
|
||||||
|
|
||||||
const _permlink = postMatch[3].indexOf(')') > 0 ? postMatch[3].replace(')', '') : postMatch[3];
|
const _permlink =
|
||||||
|
postMatch[3].indexOf(')') > 0 ? postMatch[3].replace(')', '') : postMatch[3];
|
||||||
|
|
||||||
return `<a class="markdown-post-link" href="${_permlink}" data_tag={${tag.trim()}} data_author="${postMatch[2].replace(
|
return `<a class="markdown-post-link" href="${_permlink}" data_tag={${tag.trim()}} data_author="${postMatch[2].replace(
|
||||||
'@',
|
'@',
|
||||||
@ -156,14 +161,15 @@ const handleMarkdownLink = input => input.replace(copiedPostRegex, (link) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleLinks = input => input.replace(linkRegex, (link) => {
|
const handleLinks = input =>
|
||||||
|
input.replace(linkRegex, link => {
|
||||||
if (link) {
|
if (link) {
|
||||||
if (
|
if (
|
||||||
link
|
link
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.trim()
|
.trim()
|
||||||
.indexOf('https://steemitimages.com/0x0/') === 0
|
.indexOf('https://steemitimages.com/0x0/') === 0 ||
|
||||||
|| imgRegex.test(link)
|
imgRegex.test(link)
|
||||||
) {
|
) {
|
||||||
const imageMatch = link.match(imgRegex);
|
const imageMatch = link.match(imgRegex);
|
||||||
|
|
||||||
@ -193,7 +199,8 @@ const handleLinks = input => input.replace(linkRegex, (link) => {
|
|||||||
return link;
|
return link;
|
||||||
});
|
});
|
||||||
|
|
||||||
const changeMarkdownImage = input => input.replace(markdownImageRegex, (link) => {
|
const changeMarkdownImage = input =>
|
||||||
|
input.replace(markdownImageRegex, link => {
|
||||||
const markdownMatch = link.match(markdownImageRegex);
|
const markdownMatch = link.match(markdownImageRegex);
|
||||||
if (markdownMatch[0]) {
|
if (markdownMatch[0]) {
|
||||||
const firstMarkdownMatch = markdownMatch[0];
|
const firstMarkdownMatch = markdownMatch[0];
|
||||||
@ -204,12 +211,14 @@ const changeMarkdownImage = input => input.replace(markdownImageRegex, (link) =>
|
|||||||
return link;
|
return link;
|
||||||
});
|
});
|
||||||
|
|
||||||
const centerStyling = input => input.replace(
|
const centerStyling = input =>
|
||||||
|
input.replace(
|
||||||
centerRegex,
|
centerRegex,
|
||||||
() => '<center style="text-align: center; align-items: center; justify-content: center;">',
|
() => '<center style="text-align: center; align-items: center; justify-content: center;">',
|
||||||
);
|
);
|
||||||
|
|
||||||
const steemitUrlHandle = input => input.replace(postRegex, (link) => {
|
const steemitUrlHandle = input =>
|
||||||
|
input.replace(postRegex, link => {
|
||||||
const postMatch = link.match(postRegex);
|
const postMatch = link.match(postRegex);
|
||||||
const tag = postMatch[2];
|
const tag = postMatch[2];
|
||||||
const author = postMatch[3].replace('@', '');
|
const author = postMatch[3].replace('@', '');
|
||||||
@ -218,7 +227,8 @@ const steemitUrlHandle = input => input.replace(postRegex, (link) => {
|
|||||||
return `<a class="markdown-post-link" href="${permlink}" data_tag={${tag}} data_author="${author}">/${permlink}</a>`;
|
return `<a class="markdown-post-link" href="${permlink}" data_tag={${tag}} data_author="${author}">/${permlink}</a>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleImageTag = input => input.replace(imgTagRegex, (imgTag) => {
|
const handleImageTag = input =>
|
||||||
|
input.replace(imgTagRegex, imgTag => {
|
||||||
const _imgTag = imgTag.trim();
|
const _imgTag = imgTag.trim();
|
||||||
const match = _imgTag.match(imgRegex);
|
const match = _imgTag.match(imgRegex);
|
||||||
|
|
||||||
@ -229,7 +239,12 @@ const handleImageTag = input => input.replace(imgTagRegex, (imgTag) => {
|
|||||||
return imgTag;
|
return imgTag;
|
||||||
});
|
});
|
||||||
|
|
||||||
const createYoutubeIframe = input => input.replace(youTubeRegex, (link) => {
|
const createYoutubeIframe = input =>
|
||||||
|
input.replace(youTubeRegex, link => {
|
||||||
|
if (link.indexOf(')') || link.indexOf('(')) {
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
const execVideo = youTubeRegex.exec(link);
|
const execVideo = youTubeRegex.exec(link);
|
||||||
const match = link.match(youTubeRegex);
|
const match = link.match(youTubeRegex);
|
||||||
|
|
||||||
@ -243,7 +258,8 @@ const createYoutubeIframe = input => input.replace(youTubeRegex, (link) => {
|
|||||||
return link;
|
return link;
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleIframe = input => input.replace(iframeRegex, (link) => {
|
const handleIframe = input =>
|
||||||
|
input.replace(iframeRegex, link => {
|
||||||
const match = link.match(linkRegex);
|
const match = link.match(linkRegex);
|
||||||
|
|
||||||
if (match && match[0]) {
|
if (match && match[0]) {
|
||||||
@ -253,7 +269,8 @@ const handleIframe = input => input.replace(iframeRegex, (link) => {
|
|||||||
return link;
|
return link;
|
||||||
});
|
});
|
||||||
|
|
||||||
const createVimeoIframe = input => input.replace(vimeoRegex, (link) => {
|
const createVimeoIframe = input =>
|
||||||
|
input.replace(vimeoRegex, link => {
|
||||||
const execLink = vimeoRegex.exec(link);
|
const execLink = vimeoRegex.exec(link);
|
||||||
|
|
||||||
const embedLink = `https://player.vimeo.com/video/${execLink[3]}`;
|
const embedLink = `https://player.vimeo.com/video/${execLink[3]}`;
|
||||||
@ -261,11 +278,11 @@ const createVimeoIframe = input => input.replace(vimeoRegex, (link) => {
|
|||||||
return iframeBody(embedLink);
|
return iframeBody(embedLink);
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleImageLink = input => input.replace(imgRegex, link => imageBody(link));
|
|
||||||
|
|
||||||
const iframeBody = link => `<iframe frameborder='0' allowfullscreen src='${link}'></iframe>`;
|
const iframeBody = link => `<iframe frameborder='0' allowfullscreen src='${link}'></iframe>`;
|
||||||
const imageBody = link => `<center style="text-align: center; align-items: center; justify-content: center;"><img src="${`https://steemitimages.com/600x0/${link}`}" /></center>`;
|
const imageBody = link =>
|
||||||
|
`<center style="text-align: center; align-items: center; justify-content: center;"><img src="${`https://steemitimages.com/600x0/${link}`}" /></center>`;
|
||||||
const gifBody = link => `<img src="${`https://steemitimages.com/0x0/${link}`}" />`;
|
const gifBody = link => `<img src="${`https://steemitimages.com/0x0/${link}`}" />`;
|
||||||
|
const handleImageLink = input => input.replace(imgRegex, link => imageBody(link));
|
||||||
|
|
||||||
// const handleCodeTag = input => input.replace(codeTagRegex, (tag) => {
|
// const handleCodeTag = input => input.replace(codeTagRegex, (tag) => {
|
||||||
// const stringsRegex = /(?<=>)(.*)(?=<)/g;
|
// const stringsRegex = /(?<=>)(.*)(?=<)/g;
|
||||||
|
Loading…
Reference in New Issue
Block a user