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