mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
fix delay on loading message
This commit is contained in:
parent
90a63fbf5c
commit
1b3c606c5b
@ -87,7 +87,9 @@ export function ConversationBody() {
|
||||
<View style={styles.thread}>
|
||||
{ state.topics.length === 0 && (
|
||||
<View style={styles.empty}>
|
||||
<Text style={styles.emptyText}>No Messages</Text>
|
||||
{ state.init && (
|
||||
<Text style={styles.emptyText}>No Messages</Text>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
{ state.topics.length !== 0 && (
|
||||
@ -107,7 +109,7 @@ export function ConversationBody() {
|
||||
keyExtractor={item => item.topicId}
|
||||
/>
|
||||
)}
|
||||
{ !state.init && (
|
||||
{ !state.init && state.delayed && (
|
||||
<View style={styles.loading}>
|
||||
<ActivityIndicator size="large" color={Colors.primary} />
|
||||
</View>
|
||||
|
@ -19,12 +19,15 @@ export function useConversation() {
|
||||
editData: null,
|
||||
editMessage: null,
|
||||
init: false,
|
||||
delayed: false,
|
||||
error: false,
|
||||
keyboard: false,
|
||||
locked: false,
|
||||
sealKey: null,
|
||||
delayed: false,
|
||||
});
|
||||
|
||||
const init = useRef(true);
|
||||
const delay = useRef(null);
|
||||
const conversation = useContext(ConversationContext);
|
||||
const account = useContext(AccountContext);
|
||||
@ -33,15 +36,6 @@ export function useConversation() {
|
||||
setState((s) => ({ ...s, ...value }));
|
||||
}
|
||||
|
||||
const converPem = (str) => {
|
||||
var result = '';
|
||||
while (str.length > 0) {
|
||||
result += str.substring(0, 64) + '\n';
|
||||
str = str.substring(64);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let sealKey;
|
||||
const { locked, seals } = conversation.state;
|
||||
@ -59,6 +53,7 @@ const converPem = (str) => {
|
||||
|
||||
useEffect(() => {
|
||||
const { error, subject, logo, topics, host, init } = conversation.state;
|
||||
|
||||
const items = Array.from(topics.values());
|
||||
const sorted = items.sort((a, b) => {
|
||||
const aTimestamp = a?.detail?.created;
|
||||
@ -72,18 +67,17 @@ const converPem = (str) => {
|
||||
return -1;
|
||||
});
|
||||
const filtered = sorted.filter(item => !(item.blocked === 1));
|
||||
updateState({ subject, logo, host, error, topics: filtered });
|
||||
if (init) {
|
||||
clearTimeout(delay.current);
|
||||
updateState({ init: true });
|
||||
|
||||
if (!init) {
|
||||
setTimeout(() => {
|
||||
updateState({ delayed: true });
|
||||
}, 500);
|
||||
}
|
||||
else {
|
||||
if (!delay.current) {
|
||||
delay.current = setTimeout(() => {
|
||||
updateState({ init: false });
|
||||
}, 500);
|
||||
}
|
||||
updateState({ delayed: false });
|
||||
}
|
||||
|
||||
updateState({ init, subject, logo, host, error, topics: filtered });
|
||||
}, [conversation]);
|
||||
|
||||
const actions = {
|
||||
|
@ -157,10 +157,12 @@ export function ProfileBody({ navigation }) {
|
||||
</TouchableOpacity>
|
||||
<Switch style={styles.visibleSwitch} value={state.pushEnabled} onValueChange={setNotifications} trackColor={styles.switch}/>
|
||||
</View>
|
||||
<TouchableOpacity style={styles.link} onPress={actions.showSealEdit}>
|
||||
<Ionicons name="setting" size={14} color={Colors.primary} />
|
||||
<Text style={styles.linkText}>Sealed Topics</Text>
|
||||
</TouchableOpacity>
|
||||
{ state.sealable && (
|
||||
<TouchableOpacity style={styles.link} onPress={actions.showSealEdit}>
|
||||
<Ionicons name="setting" size={14} color={Colors.primary} />
|
||||
<Text style={styles.linkText}>Sealed Topics</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
<TouchableOpacity style={styles.link} onPress={actions.showLoginEdit}>
|
||||
<Ionicons name="lock" size={14} color={Colors.primary} />
|
||||
<Text style={styles.linkText}>Change Login</Text>
|
||||
|
@ -17,6 +17,7 @@ export function useProfileBody() {
|
||||
description: null,
|
||||
node: null,
|
||||
imageSource: null,
|
||||
sealable: false,
|
||||
searchable: null,
|
||||
notifications: null,
|
||||
showDetailEdit: false,
|
||||
@ -83,11 +84,11 @@ export function useProfileBody() {
|
||||
}, [profile]);
|
||||
|
||||
useEffect(() => {
|
||||
const { searchable, pushEnabled, seal } = account.state.status;
|
||||
const { searchable, pushEnabled, seal, sealable } = account.state.status;
|
||||
const sealKey = account.state.sealKey;
|
||||
const sealEnabled = seal?.publicKey != null;
|
||||
const sealUnlocked = seal?.publicKey === sealKey?.public && sealKey?.private && sealKey?.public;
|
||||
updateState({ searchable, pushEnabled, seal, sealKey, sealEnabled, sealUnlocked });
|
||||
updateState({ searchable, sealable, pushEnabled, seal, sealKey, sealEnabled, sealUnlocked });
|
||||
}, [account]);
|
||||
|
||||
useEffect(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user