mirror of
https://github.com/irislib/iris-messenger.git
synced 2024-09-07 20:13:28 +00:00
lint
This commit is contained in:
parent
6418467887
commit
ac507a6f21
@ -1 +1 @@
|
||||
src/js/lib/*.js
|
||||
src/js/lib/**
|
@ -1,9 +1,11 @@
|
||||
import iris from 'iris-lib';
|
||||
import { debounce, throttle } from 'lodash';
|
||||
|
||||
import { Event, Filter, getEventHash, Relay, relayInit, signEvent } from './lib/nostr-tools';
|
||||
const bech32 = require('bech32-buffer');
|
||||
import localForage from 'localforage';
|
||||
|
||||
import SortedLimitedEventSet from './SortedLimitedEventSet';
|
||||
import localForage from "localforage";
|
||||
|
||||
function arrayToHex(array: any) {
|
||||
return Array.from(array, (byte: any) => {
|
||||
@ -33,7 +35,7 @@ const saveLocalStorageProfiles = throttle((profileMap: Map<string, any>) => {
|
||||
return;
|
||||
}
|
||||
// should we save profile events instead? application state would be only changed by events
|
||||
const profiles = Array.from(profileMap.keys()).map(pub => {
|
||||
const profiles = Array.from(profileMap.keys()).map((pub) => {
|
||||
const p = profileMap.get(pub);
|
||||
p && (p.pub = pub);
|
||||
return p;
|
||||
@ -115,11 +117,11 @@ export default {
|
||||
this.handleEvent(myFollowsEvent as Event);
|
||||
}
|
||||
if (Array.isArray(profiles)) {
|
||||
profiles.forEach(p => p && this.profiles.set(p.pub, p));
|
||||
profiles.forEach((p) => p && this.profiles.set(p.pub, p));
|
||||
}
|
||||
if (Array.isArray(latestMsgs)) {
|
||||
console.log('loaded latestmsgs');
|
||||
latestMsgs.forEach(msg => {
|
||||
latestMsgs.forEach((msg) => {
|
||||
this.handleEvent(msg); // TODO this does nothing because follows are not known yet
|
||||
});
|
||||
}
|
||||
@ -226,16 +228,17 @@ export default {
|
||||
if (_this.subscribedPosts.size === 0) return;
|
||||
console.log('subscribe to posts', Array.from(_this.subscribedPosts));
|
||||
for (const relay of _this.relays.values()) {
|
||||
const sub = relay.sub([{ ids: Array.from(_this.subscribedPosts) }], {});
|
||||
// TODO update relay lastSeen
|
||||
sub.on('event', (event) => _this.handleEvent(event));
|
||||
const sub = relay.sub([{ ids: Array.from(_this.subscribedPosts) }], {});
|
||||
// TODO update relay lastSeen
|
||||
sub.on('event', (event) => _this.handleEvent(event));
|
||||
}
|
||||
}, 1000),
|
||||
subscribe: function (filters: Filter[], cb: Function | undefined) {
|
||||
cb && this.subscriptions.set(subscriptionId++, {
|
||||
filters,
|
||||
callback: cb,
|
||||
});
|
||||
cb &&
|
||||
this.subscriptions.set(subscriptionId++, {
|
||||
filters,
|
||||
callback: cb,
|
||||
});
|
||||
|
||||
let hasNewAuthors = false;
|
||||
let hasNewIds = false;
|
||||
@ -320,7 +323,10 @@ export default {
|
||||
this.directRepliesByMessageId.get(replyingTo)?.add(event.id);
|
||||
|
||||
// are boost messages screwing this up?
|
||||
const repliedMsgs = event.tags.filter((tag) => tag[0] === 'e').map(tag => tag[1]).slice(0,2);
|
||||
const repliedMsgs = event.tags
|
||||
.filter((tag) => tag[0] === 'e')
|
||||
.map((tag) => tag[1])
|
||||
.slice(0, 2);
|
||||
for (const id of repliedMsgs) {
|
||||
if (!this.threadRepliesByMessageId.has(id)) {
|
||||
this.threadRepliesByMessageId.set(id, new Set<string>());
|
||||
@ -531,7 +537,12 @@ export default {
|
||||
|
||||
getRepliesAndLikes(id: string, cb: Function | undefined) {
|
||||
const callback = () => {
|
||||
cb && cb(this.directRepliesByMessageId.get(id), this.likesByMessageId.get(id), this.threadRepliesByMessageId.get(id)?.size ?? 0);
|
||||
cb &&
|
||||
cb(
|
||||
this.directRepliesByMessageId.get(id),
|
||||
this.likesByMessageId.get(id),
|
||||
this.threadRepliesByMessageId.get(id)?.size ?? 0,
|
||||
);
|
||||
};
|
||||
if (this.directRepliesByMessageId.has(id) || this.likesByMessageId.has(id)) {
|
||||
callback();
|
||||
@ -563,7 +574,8 @@ export default {
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
this.subscribe([{ ids: [id] }], () => { // TODO turn off subscription
|
||||
this.subscribe([{ ids: [id] }], () => {
|
||||
// TODO turn off subscription
|
||||
resolve(this.messagesById.get(id));
|
||||
});
|
||||
});
|
||||
|
@ -74,7 +74,8 @@ class PublicMessage extends Message {
|
||||
};
|
||||
};
|
||||
|
||||
if (Nostr.messagesById.has(nostrId)) { // for faster painting, return synchronously if we have the message
|
||||
if (Nostr.messagesById.has(nostrId)) {
|
||||
// for faster painting, return synchronously if we have the message
|
||||
return processNostrMessage(Nostr.messagesById.get(nostrId));
|
||||
}
|
||||
|
||||
@ -126,7 +127,9 @@ class PublicMessage extends Message {
|
||||
const nostrId = Nostr.toNostrHexAddress(this.props.hash);
|
||||
|
||||
const msg = r.signedData;
|
||||
msg.info = { from: nostrId ? Nostr.toNostrBech32Address(r.signerKeyHash, 'npub') : r.signerKeyHash };
|
||||
msg.info = {
|
||||
from: nostrId ? Nostr.toNostrBech32Address(r.signerKeyHash, 'npub') : r.signerKeyHash,
|
||||
};
|
||||
if (this.props.filter) {
|
||||
if (!this.props.filter(msg)) {
|
||||
return;
|
||||
@ -156,7 +159,11 @@ class PublicMessage extends Message {
|
||||
if (nostrId) {
|
||||
Nostr.getRepliesAndLikes(nostrId, (replies, likes, threadReplyCount) => {
|
||||
this.likedBy = new Set(likes);
|
||||
const sortedReplies = replies && Array.from(replies).sort((a, b) => Nostr.messagesById.get(a)?.time - Nostr.messagesById.get(b)?.time);
|
||||
const sortedReplies =
|
||||
replies &&
|
||||
Array.from(replies).sort(
|
||||
(a, b) => Nostr.messagesById.get(a)?.time - Nostr.messagesById.get(b)?.time,
|
||||
);
|
||||
this.setState({
|
||||
likes: this.likedBy.size,
|
||||
liked: this.likedBy.has(myPub),
|
||||
@ -266,16 +273,17 @@ class PublicMessage extends Message {
|
||||
render() {
|
||||
const isThumbnail = this.props.thumbnail ? 'thumbnail-item' : '';
|
||||
if (!this.state.msg) {
|
||||
return html`
|
||||
<div ref=${this.ref} key=${this.props.hash}
|
||||
return html` <div
|
||||
ref=${this.ref}
|
||||
key=${this.props.hash}
|
||||
class="msg ${isThumbnail} ${this.props.asReply ? 'reply' : ''} ${this.props.standalone
|
||||
? 'standalone'
|
||||
: ''}"
|
||||
>
|
||||
<div class="msg-content">
|
||||
${this.state.retrieving ? html`<div class="retrieving">Looking up message...</div>` : ''}
|
||||
</div>
|
||||
</div>`;
|
||||
>
|
||||
<div class="msg-content">
|
||||
${this.state.retrieving ? html`<div class="retrieving">Looking up message...</div>` : ''}
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
//if (++this.i > 1) console.log(this.i);
|
||||
let name = this.props.name || this.state.name || this.shortPubKey(this.state.msg.info.from);
|
||||
@ -405,7 +413,10 @@ class PublicMessage extends Message {
|
||||
${s.likes || ''}
|
||||
</span>
|
||||
<div class="time">
|
||||
<a href="/post/${encodeURIComponent(s.msg.noteId || this.props.hash)}" class="tooltip">
|
||||
<a
|
||||
href="/post/${encodeURIComponent(s.msg.noteId || this.props.hash)}"
|
||||
class="tooltip"
|
||||
>
|
||||
${Helpers.getRelativeTimeText(time)}
|
||||
<span class="tooltiptext"> ${dateStr} ${timeStr} </span>
|
||||
</a>
|
||||
|
@ -8,10 +8,10 @@ const SafeImg = (props: Props) => {
|
||||
if (props.src && props.src.indexOf('data:image') !== 0) {
|
||||
// free proxy with a 250 images per 10 min limit: https://images.weserv.nl/docs/
|
||||
if (props.width) {
|
||||
const width = props.width * 2;
|
||||
props.src = `https://proxy.irismessengers.wtf/insecure/rs:fill:${width}:${width}/plain/${props.src}`;
|
||||
const width = props.width * 2;
|
||||
props.src = `https://proxy.irismessengers.wtf/insecure/rs:fill:${width}:${width}/plain/${props.src}`;
|
||||
} else {
|
||||
props.src = `https://proxy.irismessengers.wtf/insecure/plain/${props.src}`;
|
||||
props.src = `https://proxy.irismessengers.wtf/insecure/plain/${props.src}`;
|
||||
}
|
||||
}
|
||||
return <img {...props} />;
|
||||
|
@ -74,11 +74,7 @@ class Feed extends View {
|
||||
${s.searchTerm
|
||||
? ''
|
||||
: html`
|
||||
<${FeedMessageForm}
|
||||
key="form${path}"
|
||||
class="hidden-xs"
|
||||
autofocus=${false}
|
||||
/>
|
||||
<${FeedMessageForm} key="form${path}" class="hidden-xs" autofocus=${false} />
|
||||
`}
|
||||
${s.searchTerm
|
||||
? html`<h2>Search results for "${s.searchTerm}"</h2>`
|
||||
|
Loading…
Reference in New Issue
Block a user