syncing mobile cards

This commit is contained in:
balzack 2024-10-18 22:29:26 -07:00
parent b877336885
commit ed301300ee
4 changed files with 12 additions and 6 deletions

View File

@ -5,8 +5,6 @@ import { styles } from './Card.styled'
export function Card({ imageUrl, name, placeholder, handle, node, select, actions, containerStyle }: { containerStyle: any, imageUrl: string, name: string, placeholder: string, handle: string, node: string, select?: () => void, actions: ReactNode[] }) {
console.log(containerStyle);
return (
<View style={containerStyle}>
<View style={styles.card}>

View File

@ -2,12 +2,13 @@ import React from 'react';
import {Divider, Surface, IconButton, Button, Text, TextInput, useTheme} from 'react-native-paper';
import {SafeAreaView, FlatList, View} from 'react-native';
import {styles} from './Contacts.styled';
import { Colors } from '../constants/Colors';
import {useContacts} from './useContacts.hook';
import { Card } from '../card/Card';
export function Contacts() {
const { state, actions } = useContacts();
const { colors } = useTheme();
const theme = useTheme();
return (
<SafeAreaView style={styles.contacts}>
@ -36,9 +37,12 @@ export function Contacts() {
const params = { guid, handle, node, name, location, description, offsync, imageUrl, cardId, status };
openContact(params);
}
const status = item.offsync ? styles.offsync : styles[item.status];
const status = item.offsync ? 'offsync' : item.status;
console.log("USING :", item.offsync, item.status, status);
return (
<Card containerStyle={{ ...styles.card, borderColor: colors.outlineVariant }} imageUrl={item.imageUrl} name={item.name} handle={item.handle} node={item.node} placeholder={state.strings.name} select={select} actions={options} />
<View style={{ borderRightWidth: 2, borderColor: Colors[status] }}>
<Card containerStyle={{ ...styles.card, borderColor: theme.colors.outlineVariant }} imageUrl={item.imageUrl} name={item.name} handle={item.handle} node={item.node} placeholder={state.strings.name} select={select} actions={options} />
</View>
)
}}
keyExtractor={(card) => card.cardId}

View File

@ -170,7 +170,6 @@ export class ContactModule implements Contact {
for (const entry of entries) {
const { key, value } = entry;
if (value.item.resync) {
console.log("RESYNC ", key);
value.item.resync = false;
if (value.item.offsyncProfile) {
try {
@ -270,6 +269,7 @@ console.log("RESYNC ", key);
entry.item.profileRevision = data.notifiedProfile;
await this.store.setContactCardProfileRevision(guid, id, data.notifiedProfile);
} catch (err) {
console.log("OFFSYNC PROFILE: ", id);
this.log.warn(err);
entry.item.offsyncProfile = data.notifiedProfile;
await this.store.setContactCardOffsyncProfile(guid, id, data.notifiedProfile);
@ -290,6 +290,7 @@ console.log("RESYNC ", key);
await this.store.setContactCardArticleRevision(guid, id, data.notifiedArticle);
this.emitArticles(id);
} catch (err) {
console.log("OFFSYNC ARTICLE: ", id);
this.log.warn(err);
entry.item.offsyncArticle = data.notifiedArticle;
await this.store.setContactCardOffsyncArticle(guid, id, data.notifiedArticle);
@ -311,6 +312,7 @@ console.log("RESYNC ", key);
await this.store.setContactCardChannelRevision(guid, id, data.notifiedChannel);
this.emitChannels(id);
} catch (err) {
console.log("OFFSYNC CHANNEL: ", id);
this.log.warn(err);
entry.item.offsyncChannel = data.notifiedChannel;
await this.store.setContactCardOffsyncChannel(guid, id, data.notifiedChannel);

View File

@ -6,6 +6,8 @@ export async function getContactChannels(node: string, secure: boolean, guid: st
const param = revision ? `viewRevision=1&channelRevision=${revision}` : `viewRevision=1`;
const endpoint = `http${secure ? "s" : ""}://${node}/content/channels?contact=${guid}.${token}&${param}&${type}`;
const channels = await fetchWithTimeout(endpoint, { method: "GET" });
console.log("GETTING: ", endpoint);
checkResponse(channels.status);
consolellog("SUCCESS");
return await channels.json();
}