This commit is contained in:
Nouman Tahir 2021-07-06 16:10:02 +05:00
parent 1cc4795ef3
commit e14c8459ce
8 changed files with 56 additions and 54 deletions

View File

@ -464,9 +464,7 @@ const MarkdownEditorView = ({
animationType="slide" animationType="slide"
style={styles.modalStyle} style={styles.modalStyle}
> >
<SnippetsModal <SnippetsModal handleOnSelect={_handleOnSnippetReceived} />
handleOnSelect={_handleOnSnippetReceived}
/>
</Modal> </Modal>
<UploadsGalleryModal <UploadsGalleryModal

View File

@ -274,7 +274,7 @@ class ProfileContainer extends Component {
const res = await getRelationship(currentAccount.name, username); const res = await getRelationship(currentAccount.name, username);
_isFollowing = res && res.follows; _isFollowing = res && res.follows;
_isMuted = res && res.ignores; _isMuted = res && res.ignores;
isFavorite = await checkFavorite(username) isFavorite = await checkFavorite(username);
} }
try { try {
@ -296,12 +296,14 @@ class ProfileContainer extends Component {
}); });
} }
} }
} } catch (error) {
catch(error){ console.warn('Failed to fetch complete profile data', error);
console.warn("Failed to fetch complete profile data", error); Alert.alert(
Alert.alert(intl.formatMessage({ intl.formatMessage({
id: 'alert.fail', id: 'alert.fail',
}), error.message || error.toString()) }),
error.message || error.toString(),
);
} }
}; };
@ -359,25 +361,26 @@ class ProfileContainer extends Component {
favoriteAction = addFavorite; favoriteAction = addFavorite;
} }
favoriteAction(username).then(() => { favoriteAction(username)
dispatch( .then(() => {
toastNotification( dispatch(
toastNotification(
intl.formatMessage({
id: isFavorite ? 'alert.success_unfavorite' : 'alert.success_favorite',
}),
),
);
this.setState({ isFavorite: !isFavorite, isProfileLoading: false });
})
.catch((error) => {
console.warn('Failed to perform favorite action');
Alert.alert(
intl.formatMessage({ intl.formatMessage({
id: isFavorite ? 'alert.success_unfavorite' : 'alert.success_favorite', id: 'alert.fail',
}), }),
), error.message || error.toString(),
); );
this.setState({ isFavorite: !isFavorite, isProfileLoading: false }); });
})
.catch((error)=>{
console.warn("Failed to perform favorite action")
Alert.alert(
intl.formatMessage({
id: 'alert.fail',
}),
error.message || error.toString()
)
});
}; };
_handleOnBackPress = () => { _handleOnBackPress = () => {

View File

@ -43,7 +43,11 @@ import {
} from '../../../realm/realm'; } from '../../../realm/realm';
import { getUser, getPost } from '../../../providers/hive/dhive'; import { getUser, getPost } from '../../../providers/hive/dhive';
import { migrateToMasterKeyWithAccessToken, switchAccount } from '../../../providers/hive/auth'; import { migrateToMasterKeyWithAccessToken, switchAccount } from '../../../providers/hive/auth';
import { setPushToken, markActivityAsRead, markNotifications } from '../../../providers/ecency/ecency'; import {
setPushToken,
markActivityAsRead,
markNotifications,
} from '../../../providers/ecency/ecency';
import { navigate } from '../../../navigation/service'; import { navigate } from '../../../navigation/service';
// Actions // Actions

View File

@ -101,7 +101,7 @@ const DraftsContainer = ({ currentAccount, intl, navigation, dispatch }) => {
_getSchedules(); _getSchedules();
}) })
.catch((error) => { .catch((error) => {
console.warn("Failed to move scheduled post to drafts") console.warn('Failed to move scheduled post to drafts');
dispatch(toastNotification(intl.formatMessage({ id: 'alert.fail' }))); dispatch(toastNotification(intl.formatMessage({ id: 'alert.fail' })));
}); });
}; };

View File

@ -945,7 +945,8 @@ class EditorContainer extends Component {
data.jsonMeta, data.jsonMeta,
options, options,
data.scheduleDate, data.scheduleDate,
) .then(() => { )
.then(() => {
this.setState({ this.setState({
isPostSending: false, isPostSending: false,
}); });
@ -973,7 +974,7 @@ class EditorContainer extends Component {
}, 3000); }, 3000);
}) })
.catch((error) => { .catch((error) => {
console.warn("Failed to schedule post", error); console.warn('Failed to schedule post', error);
this.setState({ this.setState({
isPostSending: false, isPostSending: false,
}); });

View File

@ -42,7 +42,7 @@ class NotificationContainer extends Component {
if (!endOfNotification || !loadMore) { if (!endOfNotification || !loadMore) {
this.setState({ isNotificationRefreshing: true }); this.setState({ isNotificationRefreshing: true });
getNotifications({ filter:type, since:since }) getNotifications({ filter: type, since: since })
.then((res) => { .then((res) => {
console.log(res); console.log(res);
const lastId = res.length > 0 ? [...res].pop().id : null; const lastId = res.length > 0 ? [...res].pop().id : null;
@ -73,7 +73,7 @@ class NotificationContainer extends Component {
let params; let params;
let key; let key;
markNotifications(data.id).then((result) => { markNotifications(data.id).then((result) => {
const {unread} = result; const { unread } = result;
dispatch(updateUnreadActivityCount(unread)); dispatch(updateUnreadActivityCount(unread));
}); });
@ -150,9 +150,7 @@ class NotificationContainer extends Component {
(nextProps.activeBottomTab === ROUTES.TABBAR.NOTIFICATION && nextProps.username) || (nextProps.activeBottomTab === ROUTES.TABBAR.NOTIFICATION && nextProps.username) ||
(nextProps.username !== username && nextProps.username) (nextProps.username !== username && nextProps.username)
) { ) {
this.setState({ endOfNotification: false }, () => this.setState({ endOfNotification: false }, () => this._getActivities(selectedFilter));
this._getActivities(selectedFilter),
);
} }
} }

View File

@ -49,19 +49,17 @@ const RegisterContainer = ({ children, navigation }) => {
}) })
.catch((err) => { .catch((err) => {
if (get(err, 'response.status') === 500) { if (get(err, 'response.status') === 500) {
Alert.alert(intl.formatMessage( Alert.alert(
{ id: 'alert.fail'}), intl.formatMessage({ id: 'alert.fail' }),
intl.formatMessage({ id: 'register.500_error' })); intl.formatMessage({ id: 'register.500_error' }),
} );
else if (get(err, 'response.data.message')) { } else if (get(err, 'response.data.message')) {
Alert.alert(intl.formatMessage( Alert.alert(intl.formatMessage({ id: 'alert.fail' }), err.response.data.message);
{ id: 'alert.fail'}), } else {
err.response.data.message); Alert.alert(
} intl.formatMessage({ id: 'alert.fail' }),
else { intl.formatMessage({ id: 'alert.unknow_error' }),
Alert.alert(intl.formatMessage( );
{ id: 'alert.fail'}),
intl.formatMessage({ id: 'alert.unknow_error' }));
} }
setIsLoading(false); setIsLoading(false);
}); });

View File

@ -100,12 +100,12 @@ const PostsResultsContainer = ({ children, navigation, searchValue }) => {
const _loadMore = (index, value) => { const _loadMore = (index, value) => {
if (scrollId && searchValue) { if (scrollId && searchValue) {
search({ q: `${searchValue} type:post`, sort, scroll_id: scrollId }) search({ q: `${searchValue} type:post`, sort, scroll_id: scrollId })
.then((res) => { .then((res) => {
setData([...data, ...res.results]); setData([...data, ...res.results]);
}) })
.catch(()=>{ .catch(() => {
console.warn("Search Failed"); console.warn('Search Failed');
}) });
} }
}; };