mirror of
https://github.com/irislib/iris-messenger.git
synced 2024-09-19 17:46:33 +00:00
default settings, settings for webtorrent and public peer discovery
This commit is contained in:
parent
9323b79a87
commit
3da5677adf
@ -92,6 +92,7 @@ function getRandomPeers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var askForPeers = _.once(pub => {
|
var askForPeers = _.once(pub => {
|
||||||
|
if (!Session.settings.local.enablePublicPeerDiscovery) { return; }
|
||||||
_.defer(() => {
|
_.defer(() => {
|
||||||
State.public.user(pub).get('peers').once().map().on(peer => {
|
State.public.user(pub).get('peers').once().map().on(peer => {
|
||||||
if (peer && peer.url) {
|
if (peer && peer.url) {
|
||||||
|
@ -13,6 +13,21 @@ let ourActivity;
|
|||||||
let hasFollowers;
|
let hasFollowers;
|
||||||
const follows = {};
|
const follows = {};
|
||||||
|
|
||||||
|
const DEFAULT_SETTINGS = {
|
||||||
|
electron: {
|
||||||
|
openAtLogin: true,
|
||||||
|
minimizeOnClose: true
|
||||||
|
},
|
||||||
|
local: {
|
||||||
|
enableWebtorrent: !iris.util.isMobile,
|
||||||
|
enablePublicPeerDiscovery: true,
|
||||||
|
autoplayWebtorrent: true,
|
||||||
|
maxConnectedPeers: iris.util.isElectron ? 2 : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const settings = DEFAULT_SETTINGS;
|
||||||
|
|
||||||
function getFollowsFn(callback, k, maxDepth = 2, currentDepth = 1) {
|
function getFollowsFn(callback, k, maxDepth = 2, currentDepth = 1) {
|
||||||
k = k || key.pub;
|
k = k || key.pub;
|
||||||
|
|
||||||
@ -133,6 +148,12 @@ function login(k) {
|
|||||||
if (shouldRefresh) {
|
if (shouldRefresh) {
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
State.electron && State.electron.get('settings').on(electron => {
|
||||||
|
settings.electron = electron;
|
||||||
|
});
|
||||||
|
State.local.get('settings').on(local => {
|
||||||
|
settings.local = local;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createChatLink() {
|
async function createChatLink() {
|
||||||
@ -206,4 +227,4 @@ function getFollows() {
|
|||||||
return follows;
|
return follows;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {init, getKey, getPubKey, getMyName, getMyProfilePhoto, getMyChatLink, createChatLink, removeChatLink, ourActivity, login, logOut, getFollows, loginAsNewUser };
|
export default {init, getKey, getPubKey, getMyName, getMyProfilePhoto, getMyChatLink, createChatLink, removeChatLink, ourActivity, login, logOut, getFollows, loginAsNewUser, DEFAULT_SETTINGS, settings };
|
||||||
|
@ -56,8 +56,8 @@ class PublicMessage extends Message {
|
|||||||
this.setState({replies: Object.keys(this.replies).length, sortedReplies });
|
this.setState({replies: Object.keys(this.replies).length, sortedReplies });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if (msg.torrentId) {
|
if (msg.torrentId && Session.settings.local.enableWebtorrent) {
|
||||||
!iris.util.isMobile && this.downloadWebtorrent(msg.torrentId);
|
this.downloadWebtorrent(msg.torrentId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -100,7 +100,8 @@ class PublicMessage extends Message {
|
|||||||
// Stream the file in the browser
|
// Stream the file in the browser
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const id = '#' + this.getWebtorrentElementId();
|
const id = '#' + this.getWebtorrentElementId();
|
||||||
file.appendTo(id, {autoplay: true, muted: true});
|
const autoplay = Session.settings.autoplayWebtorrent;
|
||||||
|
file.appendTo(id, {autoplay, muted: !autoplay});
|
||||||
$(id + ' video').attr('loop', true);
|
$(id + ' video').attr('loop', true);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ class Settings extends Component {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.eventListeners = [];
|
this.eventListeners = [];
|
||||||
this.state = { settings: {}, maxConnectedPeers: iris.util.isElectron ? 2 : 1};
|
this.state = Session.DEFAULT_SETTINGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
onProfilePhotoSet(src) {
|
onProfilePhotoSet(src) {
|
||||||
@ -72,16 +72,17 @@ class Settings extends Component {
|
|||||||
<small dangerouslySetInnerHTML=${{ __html:t('public_peer_info') }}></small>
|
<small dangerouslySetInnerHTML=${{ __html:t('public_peer_info') }}></small>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<p><input type="checkbox" checked=${this.state.local.enablePublicPeerDiscovery} onChange=${e => State.local.get('settings').get('enablePublicPeerDiscovery').put(!this.state.local.enablePublicPeerDiscovery)} id="enablePublicPeerDiscovery"/><label for="enablePublicPeerDiscovery">Enable public peer discovery</label></p>
|
||||||
<h4>${t('maximum_number_of_peer_connections')}</h4>
|
<h4>${t('maximum_number_of_peer_connections')}</h4>
|
||||||
<p>
|
<p>
|
||||||
<small>There's a bug that may cause high CPU and bandwidth usage when connecting to more than 1 peer. Working on it!</small>
|
<small>There's a bug that may cause high CPU and bandwidth usage when connecting to more than 1 peer. Working on it!</small>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<input type="number" value=${this.state.maxConnectedPeers} onChange=${e => State.local.get('settings').get('maxConnectedPeers').put(e.target.value || 0)}/>
|
<input type="number" value=${this.state.local.maxConnectedPeers} onChange=${e => State.local.get('settings').get('maxConnectedPeers').put(e.target.value || 0)}/>
|
||||||
</p>
|
</p>
|
||||||
${iris.util.isElectron ? html`
|
${iris.util.isElectron ? html`
|
||||||
<h4>${t('your_public_address')}</h4>
|
<h4>${t('your_public_address')}</h4>
|
||||||
<p>http://${this.state.settings.publicIp || '-'}:8767/gun</p>
|
<p>http://${this.state.electron.publicIp || '-'}:8767/gun</p>
|
||||||
`: ''}
|
`: ''}
|
||||||
<h4>Set up your own peer</h4>
|
<h4>Set up your own peer</h4>
|
||||||
<p>
|
<p>
|
||||||
@ -94,10 +95,14 @@ class Settings extends Component {
|
|||||||
${iris.util.isElectron ? html`
|
${iris.util.isElectron ? html`
|
||||||
<hr/>
|
<hr/>
|
||||||
<h3>Desktop</h3>
|
<h3>Desktop</h3>
|
||||||
<p><input type="checkbox" checked=${this.state.settings.openAtLogin} onChange=${e => State.electron.get('settings').get('openAtLogin').put(!this.state.settings.openAtLogin)} id="openAtLogin"/><label for="openAtLogin">Open at login</label></p>
|
<p><input type="checkbox" checked=${this.state.electron.openAtLogin} onChange=${e => State.electron.get('settings').get('openAtLogin').put(!this.state.electron.openAtLogin)} id="openAtLogin"/><label for="openAtLogin">Open at login</label></p>
|
||||||
<p><input type="checkbox" checked=${this.state.settings.minimizeOnClose} onChange=${e => State.electron.get('settings').get('minimizeOnClose').put(!this.state.settings.minimizeOnClose)} id="minimizeOnClose"/><label for="minimizeOnClose">Minimize on close</label></p>
|
<p><input type="checkbox" checked=${this.state.electron.minimizeOnClose} onChange=${e => State.electron.get('settings').get('minimizeOnClose').put(!this.state.electron.minimizeOnClose)} id="minimizeOnClose"/><label for="minimizeOnClose">Minimize on close</label></p>
|
||||||
`: ''}
|
`: ''}
|
||||||
<hr/>
|
<hr/>
|
||||||
|
<h3>${t('webtorrent')}</h3>
|
||||||
|
<p><input type="checkbox" checked=${this.state.local.enableWebtorrent} onChange=${e => State.local.get('settings').get('enableWebtorrent').put(!this.state.local.enableWebtorrent)} id="enableWebtorrent"/><label for="enableWebtorrent">Enable webtorrent videos</label></p>
|
||||||
|
<p><input type="checkbox" checked=${this.state.local.autoplayWebtorrent} onChange=${e => State.local.get('settings').get('autoplayWebtorrent').put(!this.state.local.autoplayWebtorrent)} id="autoplayWebtorrent"/><label for="autoplayWebtorrent">Autoplay webtorrent videos</label></p>
|
||||||
|
<hr/>
|
||||||
<h3>${t('webrtc_connection_options')}</h3>
|
<h3>${t('webrtc_connection_options')}</h3>
|
||||||
<p><small>${t('webrtc_info')}</small></p>
|
<p><small>${t('webrtc_info')}</small></p>
|
||||||
<p><textarea rows="4" id="rtc-config" placeholder="${t('webrtc_connection_options')}"></textarea></p>
|
<p><textarea rows="4" id="rtc-config" placeholder="${t('webrtc_connection_options')}"></textarea></p>
|
||||||
@ -126,8 +131,12 @@ class Settings extends Component {
|
|||||||
$('#rtc-config').val(JSON.stringify(getRTCConfig()));
|
$('#rtc-config').val(JSON.stringify(getRTCConfig()));
|
||||||
});
|
});
|
||||||
|
|
||||||
State.electron && State.electron.get('settings').on(settings => this.setState({settings}));
|
State.electron && State.electron.get('settings').on(electron => {
|
||||||
State.local.get('settings').get('maxConnectedPeers').on(maxConnectedPeers => this.setState({maxConnectedPeers}));
|
this.setState({electron});
|
||||||
|
});
|
||||||
|
State.local.get('settings').on(local => {
|
||||||
|
this.setState({local})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
Loading…
Reference in New Issue
Block a user