mirror of
https://github.com/ThisIsBenny/iOS-Widgets.git
synced 2025-04-19 23:37:41 +00:00
use temp dir for cache
Signed-off-by: Benny Samir Hierl <bennysamir@posteo.de>
This commit is contained in:
parent
66346de898
commit
c1bbe6886d
1 changed files with 20 additions and 14 deletions
|
@ -19,7 +19,10 @@ async function loadScript(url) {
|
||||||
let content = await req.loadString()
|
let content = await req.loadString()
|
||||||
let filename = url.split('/').pop()
|
let filename = url.split('/').pop()
|
||||||
|
|
||||||
return {content, filename}
|
return {
|
||||||
|
content,
|
||||||
|
filename
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadWidget(widget) {
|
async function downloadWidget(widget) {
|
||||||
|
@ -29,7 +32,10 @@ async function downloadWidget(widget) {
|
||||||
downloadAlert.addCancelAction('No')
|
downloadAlert.addCancelAction('No')
|
||||||
|
|
||||||
if (await downloadAlert.presentAlert() === 0) {
|
if (await downloadAlert.presentAlert() === 0) {
|
||||||
let {content, filename} = await loadScript(widget.scriptURL)
|
let {
|
||||||
|
content,
|
||||||
|
filename
|
||||||
|
} = await loadScript(widget.scriptURL)
|
||||||
|
|
||||||
const scriptPath = fmCloud.joinPath(fmCloud.documentsDirectory(), filename)
|
const scriptPath = fmCloud.joinPath(fmCloud.documentsDirectory(), filename)
|
||||||
const scriptExists = fmCloud.fileExists(scriptPath)
|
const scriptExists = fmCloud.fileExists(scriptPath)
|
||||||
|
@ -60,7 +66,7 @@ async function fetchCatalog(url) {
|
||||||
return await req.loadJSON()
|
return await req.loadJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateWidgetTable(table, widgets){
|
function populateWidgetTable(table, widgets) {
|
||||||
for (let i = 0; i < widgets.length; i++) {
|
for (let i = 0; i < widgets.length; i++) {
|
||||||
let row = new UITableRow()
|
let row = new UITableRow()
|
||||||
row.dismissOnSelect = false
|
row.dismissOnSelect = false
|
||||||
|
@ -81,7 +87,7 @@ function populateWidgetTable(table, widgets){
|
||||||
let downloadButtonCell = row.addButton('↓')
|
let downloadButtonCell = row.addButton('↓')
|
||||||
downloadButtonCell.rightAligned()
|
downloadButtonCell.rightAligned()
|
||||||
downloadButtonCell.widthWeight = 10
|
downloadButtonCell.widthWeight = 10
|
||||||
downloadButtonCell.onTap = async function() {
|
downloadButtonCell.onTap = async function () {
|
||||||
await downloadWidget(widgets[i])
|
await downloadWidget(widgets[i])
|
||||||
}
|
}
|
||||||
table.addRow(row)
|
table.addRow(row)
|
||||||
|
@ -90,7 +96,7 @@ function populateWidgetTable(table, widgets){
|
||||||
|
|
||||||
module.exports.present = async () => {
|
module.exports.present = async () => {
|
||||||
// Set up cache .
|
// Set up cache .
|
||||||
const cachePath = fmLocal.joinPath(fmLocal.documentsDirectory(), "widget-catalog")
|
const cachePath = fmLocal.joinPath(fmLocal.temporaryDirectory(), "cache-widget-catalog")
|
||||||
const cacheExists = fmLocal.fileExists(cachePath)
|
const cacheExists = fmLocal.fileExists(cachePath)
|
||||||
const cacheDate = cacheExists ? fmLocal.modificationDate(cachePath) : 0
|
const cacheDate = cacheExists ? fmLocal.modificationDate(cachePath) : 0
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue