mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-17 10:21:33 +03:00
fetching and maintaining muted users in currentAccount data
This commit is contained in:
parent
5fccccdaf2
commit
cfe0216df1
@ -18,7 +18,7 @@ import { toggleAccountsBottomSheet } from '../../../redux/actions/uiAction';
|
||||
|
||||
//Constants
|
||||
import AUTH_TYPE from '../../../constants/authType';
|
||||
import { getDigitPinCode } from '../../../providers/hive/dhive';
|
||||
import { getDigitPinCode, getMutes } from '../../../providers/hive/dhive';
|
||||
import { setFeedPosts, setInitPosts } from '../../../redux/actions/postsAction';
|
||||
import { Alert } from 'react-native';
|
||||
import { useIntl } from 'react-intl';
|
||||
@ -105,6 +105,7 @@ const AccountsBottomSheetContainer = ({ navigation }) => {
|
||||
_currentAccount.unread_activity_count = await getUnreadNotificationCount(
|
||||
decryptKey(encryptedAccessToken, getDigitPinCode(pinHash))
|
||||
);
|
||||
_currentAccount.mutes = await getMutes(_currentAccount.username);
|
||||
dispatch(updateCurrentAccount(_currentAccount));
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import Config from 'react-native-config';
|
||||
import get from 'lodash/get';
|
||||
|
||||
import { Alert } from 'react-native';
|
||||
import { getDigitPinCode, getUser } from './dhive';
|
||||
import { getDigitPinCode, getMutes, getUser } from './dhive';
|
||||
import {
|
||||
setUserData,
|
||||
setAuthStatus,
|
||||
@ -70,6 +70,7 @@ export const login = async (username, password, isPinCodeOpen) => {
|
||||
account.unread_activity_count = await getUnreadNotificationCount(
|
||||
scTokens ? scTokens.access_token : '',
|
||||
);
|
||||
account.mutes = await getMutes(account.username);
|
||||
|
||||
let jsonMetadata;
|
||||
try {
|
||||
@ -135,6 +136,7 @@ export const loginWithSC2 = async (code, isPinCodeOpen) => {
|
||||
account.unread_activity_count = await getUnreadNotificationCount(
|
||||
scTokens ? scTokens.access_token : '',
|
||||
);
|
||||
account.mutes = await getMutes(account.username);
|
||||
|
||||
let jsonMetadata;
|
||||
try {
|
||||
|
@ -36,6 +36,7 @@ import AUTH_TYPE from '../../constants/authType';
|
||||
import { SERVER_LIST } from '../../constants/options/api';
|
||||
import { b64uEnc } from '../../utils/b64';
|
||||
import bugsnagInstance from '../../config/bugsnag';
|
||||
import bugsnapInstance from '../../config/bugsnag';
|
||||
|
||||
global.Buffer = global.Buffer || require('buffer').Buffer;
|
||||
|
||||
@ -410,6 +411,27 @@ export const getFollowing = (follower, startFollowing, followType = 'blog', limi
|
||||
export const getFollowers = (follower, startFollowing, followType = 'blog', limit = 100) =>
|
||||
client.database.call('get_followers', [follower, startFollowing, followType, limit]);
|
||||
|
||||
export const getMutes = async (currentUsername) => {
|
||||
try {
|
||||
const type = 'ignore';
|
||||
const limit = 1000;
|
||||
const response = await client.database.call('get_following', [
|
||||
currentUsername,
|
||||
'',
|
||||
type,
|
||||
limit,
|
||||
]);
|
||||
if (!response) {
|
||||
return [];
|
||||
}
|
||||
return response.map((item) => item.following);
|
||||
} catch (err) {
|
||||
console.warn('Failed to get muted accounts', err);
|
||||
bugsnapInstance.notify(err);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
export const getRelationship = (follower, following) =>
|
||||
new Promise((resolve, reject) => {
|
||||
if (follower) {
|
||||
|
@ -40,7 +40,7 @@ import {
|
||||
getLastUpdateCheck,
|
||||
setLastUpdateCheck,
|
||||
} from '../../../realm/realm';
|
||||
import { getUser, getPost, getDigitPinCode } from '../../../providers/hive/dhive';
|
||||
import { getUser, getPost, getDigitPinCode, getMutes } from '../../../providers/hive/dhive';
|
||||
import {
|
||||
migrateToMasterKeyWithAccessToken,
|
||||
refreshSCToken,
|
||||
@ -747,6 +747,7 @@ class ApplicationContainer extends Component {
|
||||
}
|
||||
|
||||
accountData.unread_activity_count = await getUnreadNotificationCount();
|
||||
accountData.mutes = await getMutes(realmObject.username);
|
||||
dispatch(updateCurrentAccount(accountData));
|
||||
|
||||
this._connectNotificationServer(accountData.name);
|
||||
@ -928,6 +929,7 @@ class ApplicationContainer extends Component {
|
||||
_currentAccount = await this._refreshAccessToken(_currentAccount);
|
||||
|
||||
_currentAccount.unread_activity_count = await getUnreadNotificationCount();
|
||||
_currentAccount.mutes = await getMutes(_currentAccount.username);
|
||||
dispatch(updateCurrentAccount(_currentAccount));
|
||||
};
|
||||
|
||||
|
@ -35,7 +35,7 @@ import {
|
||||
setPinCodeOpen,
|
||||
} from '../../../realm/realm';
|
||||
import { updateCurrentAccount, removeOtherAccount } from '../../../redux/actions/accountAction';
|
||||
import { getDigitPinCode, getUser } from '../../../providers/hive/dhive';
|
||||
import { getDigitPinCode, getMutes, getUser } from '../../../providers/hive/dhive';
|
||||
|
||||
// Utils
|
||||
import { encryptKey, decryptKey } from '../../../utils/crypto';
|
||||
@ -318,6 +318,7 @@ class PinCodeContainer extends Component {
|
||||
|
||||
//get unread notifications
|
||||
_currentAccount.unread_activity_count = await getUnreadNotificationCount();
|
||||
_currentAccount.mutes = await getMutes(_currentAccount.username);
|
||||
dispatch(updateCurrentAccount({ ..._currentAccount }));
|
||||
dispatch(closePinCodeModal());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user