using configured date/time format

This commit is contained in:
balzack 2023-10-03 18:09:01 -07:00
parent 4e0b47072a
commit bfca12a170
4 changed files with 27 additions and 8 deletions

View File

@ -12,6 +12,8 @@ export function useProfileContext() {
identity: {}, identity: {},
server: null, server: null,
imageUrl: null, imageUrl: null,
monthLast: false,
timeFull: false,
}); });
const store = useContext(StoreContext); const store = useContext(StoreContext);

View File

@ -225,7 +225,7 @@ export const styles = StyleSheet.create({
input: { input: {
backgroundColor: Colors.inputBase, backgroundColor: Colors.inputBase,
borderRadius: 8, borderRadius: 8,
minHeight: 48, minHeight: 40,
maxHeight: 128, maxHeight: 128,
paddingLeft: 8, paddingLeft: 8,
}, },

View File

@ -36,6 +36,8 @@ export function useTopicItem(item, hosting, remove, contentKey) {
deletable: false, deletable: false,
assets: [], assets: [],
sharing: false, sharing: false,
monthLast: false,
timeFull: false,
}); });
const conversation = useContext(ConversationContext); const conversation = useContext(ConversationContext);
@ -103,7 +105,7 @@ export function useTopicItem(item, hosting, remove, contentKey) {
const { guid, created, dataType, data, status, transform } = detail || {}; const { guid, created, dataType, data, status, transform } = detail || {};
let name, nameSet, known, logo; let name, nameSet, known, logo;
const identity = profile.state?.identity; const { identity, imageUrl, monthLast, timeFull } = profile.state || {};
if (guid === identity.guid) { if (guid === identity.guid) {
known = true; known = true;
if (identity.name) { if (identity.name) {
@ -114,7 +116,7 @@ export function useTopicItem(item, hosting, remove, contentKey) {
name = identity.node ? `${identity.handle}/${identity.node}` : identity.handle; name = identity.node ? `${identity.handle}/${identity.node}` : identity.handle;
nameSet = false; nameSet = false;
} }
const img = profile.state.imageUrl; const img = imageUrl;
if (img) { if (img) {
logo = img; logo = img;
} }
@ -224,20 +226,35 @@ export function useTopicItem(item, hosting, remove, contentKey) {
const now = new Date(); const now = new Date();
const offset = now.getTime() - date.getTime(); const offset = now.getTime() - date.getTime();
if(offset < 86400000) { if(offset < 86400000) {
if (timeFull) {
timestamp = moment(date).format('H:mm');
}
else {
timestamp = moment(date).format('h:mma'); timestamp = moment(date).format('h:mma');
} }
}
else if (offset < 31449600000) { else if (offset < 31449600000) {
if (monthLast) {
timestamp = moment(date).format('DD/M');
}
else {
timestamp = moment(date).format('M/DD'); timestamp = moment(date).format('M/DD');
} }
}
else {
if (monthLast) {
timestamp = moment(date).format('DD/M/YYYY');
}
else { else {
timestamp = moment(date).format('M/DD/YYYY'); timestamp = moment(date).format('M/DD/YYYY');
} }
}
const editable = guid === identity?.guid && parsed; const editable = guid === identity?.guid && parsed;
const deletable = editable || hosting; const deletable = editable || hosting;
updateState({ logo, name, nameSet, known, sealed, message, clickable, fontSize, fontColor, timestamp, transform, status, assets, deletable, editable, editData: parsed, editMessage: message, editType: dataType }); updateState({ logo, name, nameSet, known, sealed, message, clickable, fontSize, fontColor, timestamp, transform, status, assets, deletable, editable, editData: parsed, editMessage: message, editType: dataType });
}, [conversation.state, card.state, account.state, item, contentKey]); }, [conversation.state, card.state, account.state, profile.state, item, contentKey]);
const unsealTopic = async (topicId, revision, topicDetail) => { const unsealTopic = async (topicId, revision, topicDetail) => {
try { try {

View File

@ -332,7 +332,7 @@ export const styles = StyleSheet.create({
input: { input: {
backgroundColor: Colors.inputBase, backgroundColor: Colors.inputBase,
borderRadius: 8, borderRadius: 8,
minHeight: 48, minHeight: 40,
maxHeight: 128, maxHeight: 128,
paddingLeft: 8, paddingLeft: 8,
}, },