mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
syncing contact profile
This commit is contained in:
parent
8140742dcf
commit
97cfaaa38a
@ -310,7 +310,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = 16;
|
||||
CURRENT_PROJECT_VERSION = 17;
|
||||
DEVELOPMENT_TEAM = 3P65PQ7SUR;
|
||||
ENABLE_BITCODE = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
@ -348,7 +348,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = 16;
|
||||
CURRENT_PROJECT_VERSION = 17;
|
||||
DEVELOPMENT_TEAM = 3P65PQ7SUR;
|
||||
INFOPLIST_FILE = Databag/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = Databag;
|
||||
|
@ -1,12 +1,7 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getContactProfile(server, guid, token) {
|
||||
let host = "";
|
||||
if (server) {
|
||||
host = `https://${server}`;
|
||||
}
|
||||
|
||||
let profile = await fetchWithTimeout(`${host}/profile/message?contact=${guid}.${token}`, { method: 'GET', });
|
||||
export async function getContactProfile(server, token) {
|
||||
let profile = await fetchWithTimeout(`https://${server}/profile/message?contact=${token}`, { method: 'GET', });
|
||||
checkResponse(profile);
|
||||
return await profile.json()
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setCardProfile(token, cardId, message) {
|
||||
let profile = await fetchWithTimeout(`/contact/cards/${cardId}/profile?agent=${token}`, { method: 'PUT', body: JSON.stringify(message) });
|
||||
export async function setCardProfile(server, token, cardId, message) {
|
||||
let profile = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}/profile?agent=${token}`, { method: 'PUT', body: JSON.stringify(message) });
|
||||
checkResponse(profile);
|
||||
return await profile.json()
|
||||
}
|
||||
|
@ -72,14 +72,12 @@ export function useAppContext() {
|
||||
},
|
||||
access: async (server, token) => {
|
||||
const access = await setAccountAccess(server, token);
|
||||
console.log("ACCESS", access);
|
||||
await store.actions.setSession({ ...access, server});
|
||||
await setSession({ ...access, server });
|
||||
},
|
||||
login: async (username, password) => {
|
||||
const acc = username.split('@');
|
||||
const access = await setLogin(acc[0], acc[1], password)
|
||||
console.log("ACCESS2", access);
|
||||
await store.actions.setSession({ ...access, server: acc[1]});
|
||||
await setSession({ ...access, server: acc[1] });
|
||||
},
|
||||
|
@ -3,8 +3,10 @@ import { StoreContext } from 'context/StoreContext';
|
||||
import { UploadContext } from 'context/UploadContext';
|
||||
import { getCards } from 'api/getCards';
|
||||
import { getCardProfile } from 'api/getCardProfile';
|
||||
import { setCardProfile } from 'api/setCardProfile';
|
||||
import { getCardDetail } from 'api/getCardDetail';
|
||||
|
||||
import { getContactProfile } from 'api/getContactProfile';
|
||||
import { getContactChannels } from 'api/getContactChannels';
|
||||
import { getContactChannelDetail } from 'api/getContactChannelDetail';
|
||||
import { getContactChannelSummary } from 'api/getContactChannelSummary';
|
||||
@ -80,7 +82,7 @@ export function useCardContext() {
|
||||
cards.current.set(cardId, card);
|
||||
}
|
||||
}
|
||||
const setCardProfile = (cardId, profile, revision) => {
|
||||
const setCardIdentity = (cardId, profile, revision) => {
|
||||
let card = cards.current.get(cardId);
|
||||
if (card) {
|
||||
card.profile = profile;
|
||||
@ -245,7 +247,7 @@ export function useCardContext() {
|
||||
if (view.profileRevision != profileRevision) {
|
||||
const profile = await getCardProfile(server, appToken, card.id);
|
||||
await store.actions.setCardItemProfile(guid, card.id, profileRevision, profile);
|
||||
setCardProfile(card.id, profile, profileRevision);
|
||||
setCardIdentity(card.id, profile, profileRevision);
|
||||
}
|
||||
await store.actions.setCardItemRevision(guid, card.id, card.revision);
|
||||
setCardRevision(card.id, card.revision);
|
||||
@ -271,8 +273,9 @@ export function useCardContext() {
|
||||
await store.actions.setCardItemNotifiedChannel(guid, card.id, notifiedChannel);
|
||||
}
|
||||
}
|
||||
if (status.notifiedProflile != notifiedProfile) {
|
||||
// TODO update contact profile if different
|
||||
if (status.notifiedProfile != notifiedProfile) {
|
||||
const message = await getContactProfile(cardServer, cardToken);
|
||||
await setCardProfile(server, appToken, card.id, message);
|
||||
await store.actions.setCardItemNotifiedProfile(guid, card.id, notifiedProfile);
|
||||
}
|
||||
if (status.offsync) {
|
||||
|
@ -2,7 +2,6 @@ import { KeyboardAvoidingView, FlatList, View, Text, TextInput, Modal, Image, Al
|
||||
import { TouchableOpacity } from 'react-native-gesture-handler';
|
||||
import { useTopicItem } from './useTopicItem.hook';
|
||||
import { styles } from './TopicItem.styled';
|
||||
import { Logo } from 'utils/Logo';
|
||||
import Colors from 'constants/Colors';
|
||||
import { VideoThumb } from './videoThumb/VideoThumb';
|
||||
import { AudioThumb } from './audioThumb/AudioThumb';
|
||||
@ -115,7 +114,7 @@ export function TopicItem({ item, focused, focus, hosting, remove, update, block
|
||||
{ !state.logo && (
|
||||
<Image source={avatar} style={{ width: 28, height: 28, borderRadius: 6 }} />
|
||||
)}
|
||||
<Text style={styles.name}>{ state.name }</Text>
|
||||
<Text style={{ ...styles.name, color: state.nameSet ? Colors.text : Colors.grey }}>{ state.name }</Text>
|
||||
<Text style={styles.timestamp}>{ state.timestamp }</Text>
|
||||
</View>
|
||||
{ state.status === 'confirmed' && (
|
||||
@ -139,7 +138,7 @@ export function TopicItem({ item, focused, focus, hosting, remove, update, block
|
||||
</View>
|
||||
)}
|
||||
{ state.message && (
|
||||
<Text style={{ ...styles.message, fontSize: state.fontSize }}>{ state.message }</Text>
|
||||
<Text style={{ ...styles.message, fontSize: state.fontSize, color: state.fontColor }}>{ state.message }</Text>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
@ -9,6 +9,7 @@ export function useTopicItem(item, hosting, remove) {
|
||||
|
||||
const [state, setState] = useState({
|
||||
name: null,
|
||||
nameSet: null,
|
||||
known: null,
|
||||
logo: null,
|
||||
timestamp: null,
|
||||
@ -40,7 +41,7 @@ export function useTopicItem(item, hosting, remove) {
|
||||
const { topicId, detail } = item;
|
||||
const { guid, data, status, transform } = detail;
|
||||
|
||||
let name, known, logo;
|
||||
let name, nameSet, known, logo;
|
||||
const identity = profile.state?.profile;
|
||||
if (guid === identity.guid) {
|
||||
known = true;
|
||||
@ -65,21 +66,24 @@ export function useTopicItem(item, hosting, remove) {
|
||||
logo = card.actions.getCardLogo(contact.cardId, contact.profileRevision);
|
||||
}
|
||||
else {
|
||||
logo = 'avatar';
|
||||
logo = null;
|
||||
}
|
||||
|
||||
known = true;
|
||||
if (contact.profile.name) {
|
||||
name = contact.profile.name;
|
||||
nameSet = true;
|
||||
}
|
||||
else {
|
||||
name = `${contact.handle}@${contact.node}`;
|
||||
name = `${contact.profile.handle}@${contact.profile.node}`;
|
||||
nameSet = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
name = "unknown";
|
||||
nameSet = false;
|
||||
known = false;
|
||||
logo = 'avatar';
|
||||
logo = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +128,7 @@ export function useTopicItem(item, hosting, remove) {
|
||||
const editable = detail.guid === identity.guid && parsed;
|
||||
const deletable = editable || hosting;
|
||||
|
||||
updateState({ logo, name, known, message, fontSize, fontColor, timestamp, transform, status, assets, deletable, editable, editData: parsed, editMessage: message });
|
||||
updateState({ logo, name, nameSet, known, message, fontSize, fontColor, timestamp, transform, status, assets, deletable, editable, editData: parsed, editMessage: message });
|
||||
}, [card, item]);
|
||||
|
||||
const actions = {
|
||||
|
Loading…
Reference in New Issue
Block a user