Compare commits
No commits in common. "609ca4d3f5e1c6e20cd45f3c2fe4336b18dbb778" and "c3c36504ab837b87ef162539691fa0b4f45bc936" have entirely different histories.
609ca4d3f5
...
c3c36504ab
@ -48,12 +48,19 @@ var Types;
|
|||||||
Types[Types["REFRESH"] = 2] = "REFRESH";
|
Types[Types["REFRESH"] = 2] = "REFRESH";
|
||||||
})(Types || (Types = {}));
|
})(Types || (Types = {}));
|
||||||
|
|
||||||
let rules = [{
|
let rules = [
|
||||||
|
{
|
||||||
match: (url) => {
|
match: (url) => {
|
||||||
return url.indexOf("/api/") >= 0;
|
return url.indexOf("/api/") >= 0;
|
||||||
},
|
},
|
||||||
type: Types.NOCACHE
|
type: Types.NOCACHE
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
match: (url) => {
|
||||||
|
return url.indexOf("/version_hash") >= 0;
|
||||||
|
},
|
||||||
|
type: Types.NOCACHE
|
||||||
|
},
|
||||||
{
|
{
|
||||||
match: () => {
|
match: () => {
|
||||||
return true;
|
return true;
|
||||||
@ -72,7 +79,7 @@ self.addEventListener('fetch', (evt) => {
|
|||||||
return fromCache(evt.request);
|
return fromCache(evt.request);
|
||||||
case Types.REFRESH:
|
case Types.REFRESH:
|
||||||
return refresh(evt.request).then(r => {
|
return refresh(evt.request).then(r => {
|
||||||
evt.waitUntil(r.refresh.catch(_ => {}));
|
evt.waitUntil(r.refresh.catch(_ => { }));
|
||||||
return r.result;
|
return r.result;
|
||||||
});
|
});
|
||||||
case Types.NOCACHE:
|
case Types.NOCACHE:
|
||||||
@ -88,12 +95,7 @@ async function fromCache(request) {
|
|||||||
return matching
|
return matching
|
||||||
|
|
||||||
let res = await fetch(request.clone());
|
let res = await fetch(request.clone());
|
||||||
await cache.put(request, {
|
await cache.put(request, res);
|
||||||
match: (url) => {
|
|
||||||
return url.indexOf("/version_hash") >= 0;
|
|
||||||
},
|
|
||||||
type: Types.NOCACHE
|
|
||||||
}, res);
|
|
||||||
return await cache.match(request);
|
return await cache.match(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,14 +12,17 @@ import Modal from "../../modals/Modal";
|
|||||||
|
|
||||||
const minRows = 3;
|
const minRows = 3;
|
||||||
export default class EntryComponent extends Component<{ vault: Promise<IVault>, id: string | undefined, note: string | undefined }, { title: string, changed: boolean }> {
|
export default class EntryComponent extends Component<{ vault: Promise<IVault>, id: string | undefined, note: string | undefined }, { title: string, changed: boolean }> {
|
||||||
private text: string = "";
|
old_text: string;
|
||||||
private vault: IVault;
|
text: string = "";
|
||||||
// private lineHeight: number = 24;
|
vault: IVault;
|
||||||
private note: ViewNote;
|
lineHeight: number = 24;
|
||||||
|
note: ViewNote;
|
||||||
|
|
||||||
private rows: number = minRows;
|
rows: number = minRows;
|
||||||
|
|
||||||
private skip_save: boolean = false;
|
skip_save: boolean = false;
|
||||||
|
|
||||||
|
// loading?: LoadingModal;
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@ -27,16 +30,12 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private toVault() {
|
private toVault() {
|
||||||
|
// history.back()
|
||||||
history.back();
|
history.back();
|
||||||
|
// Navigation.setPage("/vault", { id: this.vault.id }, { entry: "false" }, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentWillMount() {
|
async componentWillMount() {
|
||||||
this.text = "";
|
|
||||||
this.vault = undefined;
|
|
||||||
this.note = undefined;
|
|
||||||
this.rows = minRows;
|
|
||||||
this.skip_save = false;
|
|
||||||
this.setState({ changed: false, title: "" });
|
|
||||||
try {
|
try {
|
||||||
this.skip_save = false;
|
this.skip_save = false;
|
||||||
// this.loading = new LoadingModal();
|
// this.loading = new LoadingModal();
|
||||||
@ -65,10 +64,6 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
if (rows !== this.rows) {
|
if (rows !== this.rows) {
|
||||||
this.rows = rows;
|
this.rows = rows;
|
||||||
}
|
}
|
||||||
// async onKeypress(event) {
|
|
||||||
// event = event || window.event;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
let [title] = this.text.split("\n", 1);
|
let [title] = this.text.split("\n", 1);
|
||||||
this.setState({ title, changed })
|
this.setState({ title, changed })
|
||||||
// if (this.loading)
|
// if (this.loading)
|
||||||
@ -91,6 +86,11 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// async onKeypress(event) {
|
||||||
|
// event = event || window.event;
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
if (!this.skip_save)
|
if (!this.skip_save)
|
||||||
this.save()
|
this.save()
|
||||||
@ -161,10 +161,6 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
const delete_handler = async () => {
|
const delete_handler = async () => {
|
||||||
await this.vault.deleteNote(this.props.id);
|
await this.vault.deleteNote(this.props.id);
|
||||||
this.toVault()
|
this.toVault()
|
||||||
// async onKeypress(event) {
|
|
||||||
// event = event || window.event;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return <div>
|
return <div>
|
||||||
@ -178,18 +174,13 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
</header>
|
</header>
|
||||||
<div class="uk-container">
|
<div class="uk-container">
|
||||||
<textarea
|
<textarea
|
||||||
// async onKeypress(event) {
|
|
||||||
// event = event || window.event;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
autofocus
|
autofocus
|
||||||
value={this.text}
|
value={this.text}
|
||||||
rows={this.rows}
|
rows={this.rows}
|
||||||
class="doc uk-textarea"
|
class="doc uk-textarea"
|
||||||
style="width:100%;"
|
style="width:100%;"
|
||||||
onInput={evt => this.textAreaChange(evt as KeyboardEvent)}
|
|
||||||
onKeyDown={evt => this.textAreaKeyPress(evt)}
|
onKeyDown={evt => this.textAreaKeyPress(evt)}
|
||||||
onChange={evt => this.textAreaChange(evt as KeyboardEvent)}
|
onKeyUp={evt => this.textAreaChange(evt)}
|
||||||
ref={elm => {
|
ref={elm => {
|
||||||
if (elm)
|
if (elm)
|
||||||
setTimeout(() => elm.focus(), 500)
|
setTimeout(() => elm.focus(), 500)
|
||||||
|
@ -167,7 +167,7 @@ class NotesProvider {
|
|||||||
public async start() {
|
public async start() {
|
||||||
const next = () => {
|
const next = () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.sync().then(next);
|
this.sync().then(() => next);
|
||||||
}, 30000)
|
}, 30000)
|
||||||
}
|
}
|
||||||
this.syncedObservableServer.send((await this.oplogDB.getAll()).length <= 0);
|
this.syncedObservableServer.send((await this.oplogDB.getAll()).length <= 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user