mirror of
https://github.com/irislib/iris-messenger.git
synced 2024-09-20 10:06:32 +00:00
fix fetching our own dms
This commit is contained in:
parent
2755deb256
commit
9d82f5d58b
@ -8,7 +8,7 @@ import { route } from 'preact-router';
|
||||
|
||||
import EventComponent from './components/events/EventComponent';
|
||||
import Name from './components/Name';
|
||||
import { isSafeOrigin } from './components/SafeImg';
|
||||
import { SafeImg, isSafeOrigin } from './components/SafeImg';
|
||||
import Torrent from './components/Torrent';
|
||||
import Key from './nostr/Key';
|
||||
import { language, translate as t } from './translations/Translation';
|
||||
@ -340,6 +340,21 @@ export default {
|
||||
});
|
||||
}
|
||||
|
||||
// find .jpg .jpeg .gif .png .webp urls in msg.text and create img tag
|
||||
if (settings.enableImages !== false) {
|
||||
const imgRegex = /https?:\/\/.*\.(?:jpg|jpeg|gif|png|webp)/gi;
|
||||
replacedText = reactStringReplace(replacedText, imgRegex, (match, i) => {
|
||||
let parsedUrl;
|
||||
try {
|
||||
parsedUrl = new URL(match);
|
||||
} catch (e) {
|
||||
console.log('invalid url', match);
|
||||
return;
|
||||
}
|
||||
return <SafeImg src={parsedUrl} key={parsedUrl + i} />;
|
||||
});
|
||||
}
|
||||
|
||||
replacedText = this.highlightText(replacedText, event, opts);
|
||||
|
||||
const lnRegex =
|
||||
|
@ -1,3 +1,4 @@
|
||||
//import "preact/debug";
|
||||
import { Helmet } from 'react-helmet';
|
||||
import { Router, RouterOnChangeArgs } from 'preact-router';
|
||||
|
||||
|
@ -43,14 +43,6 @@ const DEFAULT_SETTINGS = {
|
||||
timespan: 'all',
|
||||
};
|
||||
|
||||
const TIMESPANS = {
|
||||
all: 0,
|
||||
day: 24 * 60 * 60,
|
||||
week: 7 * 24 * 60 * 60,
|
||||
month: 30 * 24 * 60 * 60,
|
||||
year: 365 * 24 * 60 * 60,
|
||||
};
|
||||
|
||||
class Feed extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
@ -264,6 +256,9 @@ class Feed extends Component {
|
||||
}
|
||||
|
||||
getEvents(callback) {
|
||||
if (this.props.index === 'notifications') {
|
||||
|
||||
}
|
||||
if (this.props.nostrUser) {
|
||||
if (this.props.index === 'likes') {
|
||||
return PubSub.subscribe(
|
||||
|
@ -301,12 +301,6 @@ class Note extends Component {
|
||||
}
|
||||
if (parsedUrl.pathname.toLowerCase().match(/\.(jpg|jpeg|gif|png|webp)$/)) {
|
||||
meta.attachments.push({ type: 'image', data: `${parsedUrl.href}` });
|
||||
|
||||
// Remove URL from beginning or end of line or before newline
|
||||
const esc = escapeRegExp(url);
|
||||
text = text.replace(new RegExp(`^${esc}`), '');
|
||||
text = text.replace(new RegExp(`${esc}$`), '');
|
||||
text = text.replace(new RegExp(`${esc}\n`), ' ');
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -629,23 +623,6 @@ class Note extends Component {
|
||||
`;
|
||||
}
|
||||
|
||||
renderAttachments() {
|
||||
return this.props.meta.attachments.map((a, i) => {
|
||||
if (i > 0 && !this.props.standalone && !this.state.showMore) {
|
||||
return;
|
||||
}
|
||||
return html`<div class="img-container">
|
||||
<${SafeImg}
|
||||
width=${569}
|
||||
src=${a.data}
|
||||
onClick=${(e) => {
|
||||
this.imageClicked(e);
|
||||
}}
|
||||
/>
|
||||
</div>`;
|
||||
});
|
||||
}
|
||||
|
||||
isTooLong() {
|
||||
return (
|
||||
this.props.meta.attachments?.length > 1 ||
|
||||
@ -721,7 +698,6 @@ class Note extends Component {
|
||||
/>
|
||||
`
|
||||
: ''}
|
||||
${this.props.meta.attachments && this.renderAttachments()}
|
||||
${s.text?.length > 0
|
||||
? html`<div class="text ${s.emojiOnly && 'emoji-only'}">
|
||||
${(!this.state.showMore && this.state.shortContent) || this.state.content}
|
||||
|
@ -756,7 +756,7 @@ const Events = {
|
||||
};
|
||||
this.directMessagesByUser.has(address) && callback();
|
||||
const myPub = Key.getPubKey();
|
||||
return PubSub.subscribe([{ kinds: [4], '#p': [address, myPub] }], callback);
|
||||
return PubSub.subscribe([{ kinds: [4], '#p': [myPub], authors: [address] }, { kinds: [4], '#p': [address], authors: [myPub] }], callback);
|
||||
},
|
||||
getDirectMessages(cb) {
|
||||
const callback = () => {
|
||||
|
@ -32,6 +32,7 @@ let dev: any = {
|
||||
};
|
||||
const relayPool = new RelayPool(Relays.DEFAULT_RELAYS, {
|
||||
useEventCache: false,
|
||||
|
||||
externalGetEventById: (id) => Events.db.by('id', id),
|
||||
});
|
||||
localState.get('dev').on((d) => {
|
||||
|
Loading…
Reference in New Issue
Block a user