StaleWhileRevalidate, bgsync, email privkey to yourself

This commit is contained in:
Martti Malmi 2021-08-06 10:38:21 +03:00
parent 8041583292
commit 88b931d364
14 changed files with 49 additions and 1546 deletions

2
dist/200.html vendored

File diff suppressed because one or more lines are too long

1529
dist/bundle.68229.esm.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/index.html vendored

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"/":{"bundle.61bf3.css":{"type":"style","weight":1},"bundle.68229.esm.js":{"type":"script","weight":1}}} {"/":{"bundle.61bf3.css":{"type":"style","weight":1},"bundle.a5476.esm.js":{"type":"script","weight":1}}}

2
dist/sw-esm.js vendored

File diff suppressed because one or more lines are too long

2
dist/sw-esm.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -121,6 +121,9 @@ export default {
feed_top: 'Newest', feed_top: 'Newest',
feed_down: 'Older', feed_down: 'Older',
feed_bottom: 'Oldest', feed_bottom: 'Oldest',
email_privkey_to_yourself: 'Email the private key to yourself',
email: "Email",
retype_email: "Retype email",
email_optional: "Email (optional)", email_optional: "Email (optional)",
delivery: "Delivery", delivery: "Delivery",
address: "Address", address: "Address",

View File

@ -40,7 +40,6 @@ class MessageFeed extends Component {
} }
componentDidMount() { componentDidMount() {
console.log(this.props);
let first = true; let first = true;
State.local.get('scrollUp').on(() => { State.local.get('scrollUp').on(() => {
!first && Helpers.animateScrollTop('.main-view'); !first && Helpers.animateScrollTop('.main-view');

View File

@ -1,4 +1,4 @@
import { Component } from 'preact'; import { Component, createRef } from 'preact';
import Helpers, {html} from '../Helpers.js'; import Helpers, {html} from '../Helpers.js';
import Session from "../Session.js"; import Session from "../Session.js";
import { translate as tr } from '../Translation.js'; import { translate as tr } from '../Translation.js';
@ -12,10 +12,8 @@ const isAudio = f => isOfType(f, ['.mp3', '.wav', '.m4a']);
const isImage = f => isOfType(f, ['.jpg', 'jpeg', '.gif', '.png']); const isImage = f => isOfType(f, ['.jpg', 'jpeg', '.gif', '.png']);
class Torrent extends Component { class Torrent extends Component {
constructor() { eventListeners = {};
super(); coverRef = createRef();
this.eventListeners = {};
}
componentDidMount() { componentDidMount() {
State.local.get('player').on((player,a,b,e) => { State.local.get('player').on((player,a,b,e) => {
@ -142,13 +140,14 @@ class Torrent extends Component {
} }
onTorrent(torrent, clicked) { onTorrent(torrent, clicked) {
if (!this.coverRef.current) { return; }
this.torrent = torrent; this.torrent = torrent;
const video = torrent.files.find(f => isVideo(f)); const video = torrent.files.find(f => isVideo(f));
const audio = torrent.files.find(f => isAudio(f)); const audio = torrent.files.find(f => isAudio(f));
const img = torrent.files.find(f => isImage(f)); const img = torrent.files.find(f => isImage(f));
let poster = torrent.files.find(f => isImage(f) && (f.name.indexOf('cover') > -1 || f.name.indexOf('poster') > -1)); let poster = torrent.files.find(f => isImage(f) && (f.name.indexOf('cover') > -1 || f.name.indexOf('poster') > -1));
poster = poster || img; poster = poster || img;
poster && poster.appendTo($(this.base).find('.cover').get(0)); poster && poster.appendTo(this.coverRef.current);
const file = this.getActiveFile(torrent) || video || audio || img || torrent.files[0]; const file = this.getActiveFile(torrent) || video || audio || img || torrent.files[0];
this.setState({torrent, cover: img}); this.setState({torrent, cover: img});
@ -184,7 +183,7 @@ class Torrent extends Component {
<a href="" onClick=${e => this.openTorrentClicked(e)}>Show attachment</a> <a href="" onClick=${e => this.openTorrentClicked(e)}>Show attachment</a>
`:''} `:''}
${s.torrenting && !s.torrent ? html`<p>Loading attachment...</p>`:''} ${s.torrenting && !s.torrent ? html`<p>Loading attachment...</p>`:''}
<div class="cover" style=${s.isAudioOpen ? '' : 'display:none'}></div> <div class="cover" ref=${this.coverRef} style=${s.isAudioOpen ? '' : 'display:none'}></div>
<div class="info"> <div class="info">
${s.splitPath ? s.splitPath.map( ${s.splitPath ? s.splitPath.map(
(str, i) => { (str, i) => {

View File

@ -29,6 +29,13 @@ class Settings extends View {
State.public.user().get('profile').get('photo').put(src); State.public.user().get('profile').get('photo').put(src);
} }
mailtoSubmit(e) {
e.preventDefault();
if (this.state.email && this.state.email === this.state.retypeEmail) {
window.location.href = `mailto:${this.state.email}?&subject=Iris%20private%20key&body=${JSON.stringify(Session.getKey())}`;
}
}
renderView() { renderView() {
const blockedUsers = _.filter(Object.keys(this.state.blockedUsers), user => this.state.blockedUsers[user]); const blockedUsers = _.filter(Object.keys(this.state.blockedUsers), user => this.state.blockedUsers[user]);
return html` return html`
@ -54,6 +61,16 @@ class Settings extends View {
<button onClick=${e => togglePrivateKeyQR(e)}>${t('show_privkey_qr')}</button> <button onClick=${e => togglePrivateKeyQR(e)}>${t('show_privkey_qr')}</button>
</p> </p>
<div id="private-key-qr" class="qr-container"></div> <div id="private-key-qr" class="qr-container"></div>
<p>
${t('email_privkey_to_yourself')}:
</p>
<p>
<form onSubmit=${e => this.mailtoSubmit(e)}>
<input name="email" type="email" onChange=${e => this.setState({email:e.target.value.trim()})} placeholder=${t('email')}/>
<input name="verify_email" type="email" onChange=${e => this.setState({retypeEmail:e.target.value.trim()})} placeholder=${t('retype_email')}/>
<button type="submit">${t('go')}</button>
</form>
</p>
<p><small dangerouslySetInnerHTML=${{ __html: t('privkey_storage_recommendation')}}></small></p> <p><small dangerouslySetInnerHTML=${{ __html: t('privkey_storage_recommendation')}}></small></p>
<hr/> <hr/>
<h3>${t('language')}</h3> <h3>${t('language')}</h3>

View File

@ -1,7 +1,25 @@
import Gun from 'gun'; import Gun from 'gun';
import localforage from './js/lib/localforage.min.js'; import localforage from './js/lib/localforage.min.js';
import { getFiles, setupPrecaching, setupRouting } from 'preact-cli/sw'; import { getFiles, setupPrecaching, setupRouting } from 'preact-cli/sw';
import { registerRoute } from 'workbox-routing';
import {StaleWhileRevalidate, NetworkOnly} from 'workbox-strategies';
import { BackgroundSyncPlugin } from 'workbox-background-sync';
const bgSyncPlugin = new BackgroundSyncPlugin('apiRequests', {
maxRetentionTime: 14 * 24 * 60
});
registerRoute(
'https://iris-notifications.herokuapp.com/notify',
new NetworkOnly({
plugins: [bgSyncPlugin]
}),
'POST'
);
registerRoute(
() => true,
new StaleWhileRevalidate()
);
setupRouting(); setupRouting();
const urlsToCache = getFiles(); const urlsToCache = getFiles();