ソースを参照

service-worker strategy changed to network first

master
Flo Smilari 4年前
コミット
4e3a9587c8

+ 1
- 1
Pages/CaritasServiceFundVeloFoundKeyDataPage.razor.cs ファイルの表示

if (addressDto == null) { if (addressDto == null) {
this.bicycleGeoPosition.Latitude = ReportDataProvider.GetFoundReport().GeographicInfo.Latitude; this.bicycleGeoPosition.Latitude = ReportDataProvider.GetFoundReport().GeographicInfo.Latitude;
this.bicycleGeoPosition.Longitude = ReportDataProvider.GetFoundReport().GeographicInfo.Longitude; this.bicycleGeoPosition.Longitude = ReportDataProvider.GetFoundReport().GeographicInfo.Longitude;
addressDto =await NominatimService.GetAddressForCoordinates(this.bicycleGeoPosition.Latitude, this.bicycleGeoPosition.Longitude);
addressDto = await NominatimService.GetAddressForCoordinates(this.bicycleGeoPosition.Latitude, this.bicycleGeoPosition.Longitude);
} }
return GetFormattedAddressZipAndTown(addressDto); return GetFormattedAddressZipAndTown(addressDto);
} }

+ 1
- 1
Shared/Services/BicycleRestService.cs ファイルの表示

return response; return response;
} }
} }
} }

+ 1
- 1
Shared/Services/IBicycleRestService.cs ファイルの表示

Task<ReportResponse> SendFoundReport(Report report); Task<ReportResponse> SendFoundReport(Report report);
Task<ReportResponse> SendFoundReport(FoundReportRepositoryItem reportRepositoryItem);
Task<ReportResponse> SendFoundReport(FoundReportRepositoryItem reportRepositoryItem);
Task<ReportResponse> SendMissingReport(Report report); Task<ReportResponse> SendMissingReport(Report report);

+ 26
- 34
wwwroot/service-worker.js ファイルの表示

'https://fonts.gstatic.com/s/roboto/v27/KFOlCnqEu92Fr1MmEU9fBBc4AMP6lQ.woff2', 'https://fonts.gstatic.com/s/roboto/v27/KFOlCnqEu92Fr1MmEU9fBBc4AMP6lQ.woff2',
'https://fonts.gstatic.com/s/roboto/v27/KFOmCnqEu92Fr1Mu4mxKKTU1Kg.woff2', 'https://fonts.gstatic.com/s/roboto/v27/KFOmCnqEu92Fr1Mu4mxKKTU1Kg.woff2',
'https://fonts.gstatic.com/s/materialicons/v85/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2', 'https://fonts.gstatic.com/s/materialicons/v85/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2',
'https://fonts.gstatic.com/s/ubuntu/v15/4iCv6KVjbNBYlgoCxCvjsGyNPYZvgw.woff2',
'appsettings.json', 'appsettings.json',
'manifest.json' 'manifest.json'
]; ];
console.log('caching app assets'); console.log('caching app assets');
cache.addAll(assets); cache.addAll(assets);
}) })
);
)
self.skipWaiting();
}); });
// activate event // activate event
console.log('Now ready to handle fetches!'); console.log('Now ready to handle fetches!');
}) })
); );
self.clients.claim();
}); });
// fetch events (appsettings are always first fetched from network)
self.addEventListener('fetch', event => {
if (event.request.url.endsWith(appsettings_url)) {
fetch(event.request).then(function (response) {
return caches.open(staticCacheName).then(function (cache) {
console.log('update cache');
cache.put(event.request, response.clone());
return response;
});
}).catch(function () {
return useFallback();
});
} else {
event.respondWith(
caches.match(event.request).then(cacheRes => {
return cacheRes || fetch(event.request);
})
);
}
// fetch events (Network first strategy, no cache update after install)
self.addEventListener('fetch', function (event) {
event.respondWith(fromNetwork(event.request, 6000).catch(function () {
return fromCache(event.request);
}));
}); });
function useFallback() {
return Promise.resolve(new Response(Appsettings_Fallback, {
headers: {
'Content-Type': 'application/json'
}
}));
function fromNetwork(request, timeout) {
return new Promise(function (fulfill, reject) {
var timeoutId = setTimeout(reject, timeout);
fetch(request).then(function (response) {
clearTimeout(timeoutId);
fulfill(response);
}, reject);
});
} }
var Appsettings_Fallback = {
"host_base_url": "https://integrate.dynalias.net:9443/Fundvelo/",
"subresource_url_colors": "api/{0}/{1}/fundvelo/colors",
"subresource_url_brands": "api/{0}/{1}/fundvelo/brands",
"subresource_url_types": "api/{0}/{1}/fundvelo/types",
"subresource_url_foundreport": "api/{0}/{1}/fundvelo/fundmeldung",
"subresource_url_missingreport": "api/{0}/{1}/fundvelo/suchauftrag"
}
function fromCache(request) {
return caches.open(staticCacheName).then(function (cache) {
return cache.match(request).then(function (matching) {
return matching || Promise.reject('no-match');
});
});
}

読み込み中…
キャンセル
保存