## 2018-11-02 File PUT Bug

- [X] DELETE files in index in SWX
- [X] toggle collapse navigation on click
- [ ] keep context of navigation more stable
- [X] sometimes... we load old content that only updates after first write and conflict resolution


### File PUT cache bug


Kill Service Worker, the do request... will it wait? 
```javascript

fetch("https://lively-kernel.org/lively4/lively4-jens/hello2.md", {
  method: "PUT",
  body: "hello131"
}).then(r => r.text())

// RESOLVED: Created new version: bb5b1ce3aaa2f9935e1553674a7a1e4716917fb1

// the service worker is not up and running...
var response = fetch("https://lively-kernel.org/lively4/lively4-jens/hello2.md", {
  method: "GET"
})
response.then(r => r.headers.get("fileversion"))// wrong version: RESOLVED: b36fd395865402f859d6032096604d9d58de3ac7
  
response.then(r => r.text()) // writh wrong content: RESOLVED: hello130
```

doing this while the service worker is running will produce the right result.
#Idea: this suggests, that our initial PUT request will not update the cache of the service worker

```javascript

fetch("https://lively-kernel.org/lively4/lively4-jens/hello2.md", {
  method: "PUT",
  body: "hello134"
}).then(r => r.text())

var response = fetch("https://lively-kernel.org/lively4/lively4-jens/hello2.md", {
  method: "GET"
})
response.then(r => r.text())  // right result: RESOLVED: hello134
```

The bug was in:

```javascript
    if (pending) {
      pending.resolve(doNetworkRequest());
    } else {
      event.respondWith(this._cache.fetch(event.request, doNetworkRequest));
    }
```

Pending request did not get through the Cache!


```javascript
    if (pending) {
      this._cache.fetch(event.request, doNetworkRequest, pending)
    } else {
      event.respondWith(this._cache.fetch(event.request, doNetworkRequest));
    }
```
