issue 102 Do something reasonable if the Stylish DB can't be read
This commit is contained in:
parent
b7aa8b4b81
commit
2064f56796
|
@ -72,6 +72,10 @@
|
||||||
"message": "Checking...",
|
"message": "Checking...",
|
||||||
"description": "Text to display when checking a style for an update"
|
"description": "Text to display when checking a style for an update"
|
||||||
},
|
},
|
||||||
|
"dbError": {
|
||||||
|
"message": "An error has occurred using the Stylish database. Would you like to visit a web page with possible solutions?",
|
||||||
|
"description": "Prompt when a DB error is encountered"
|
||||||
|
},
|
||||||
"deleteStyleLabel": {
|
"deleteStyleLabel": {
|
||||||
"message": "Delete",
|
"message": "Delete",
|
||||||
"description": "Label for the button to delete a style"
|
"description": "Label for the button to delete a style"
|
||||||
|
|
|
@ -21,6 +21,9 @@ chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
|
||||||
case "styleChanged":
|
case "styleChanged":
|
||||||
cachedStyles = null;
|
cachedStyles = null;
|
||||||
break;
|
break;
|
||||||
|
case "healthCheck":
|
||||||
|
getDatabase(function() { sendResponse(true); }, function() { sendResponse(false); });
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
7
health.js
Normal file
7
health.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
chrome.extension.sendMessage({method: "healthCheck"}, function(ok) {
|
||||||
|
if (!ok) {
|
||||||
|
if (confirm(t("dbError"))) {
|
||||||
|
window.open("http://userstyles.org/dberror");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -85,6 +85,7 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script src="localization.js"></script>
|
<script src="localization.js"></script>
|
||||||
|
<script src="health.js"></script>
|
||||||
<script src="storage.js"></script>
|
<script src="storage.js"></script>
|
||||||
<script src="messaging.js"></script>
|
<script src="messaging.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script src="localization.js"></script>
|
<script src="localization.js"></script>
|
||||||
|
<script src="health.js"></script>
|
||||||
<script src="storage.js"></script>
|
<script src="storage.js"></script>
|
||||||
<script src="messaging.js"></script>
|
<script src="messaging.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -4,7 +4,12 @@ function getDatabase(ready, error) {
|
||||||
ready(stylishDb);
|
ready(stylishDb);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stylishDb = openDatabase('stylish', '', 'Stylish Styles', 5*1024*1024);
|
try {
|
||||||
|
stylishDb = openDatabase('stylish', '', 'Stylish Styles', 5*1024*1024);
|
||||||
|
} catch (ex) {
|
||||||
|
error();
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
if (stylishDb.version == "1.0" || stylishDb.version == "") {
|
if (stylishDb.version == "1.0" || stylishDb.version == "") {
|
||||||
dbV11(stylishDb, error, ready);
|
dbV11(stylishDb, error, ready);
|
||||||
} else if (stylishDb.version == "1.1") {
|
} else if (stylishDb.version == "1.1") {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user