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...",
|
||||
"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": {
|
||||
"message": "Delete",
|
||||
"description": "Label for the button to delete a style"
|
||||
|
|
|
@ -21,6 +21,9 @@ chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
|
|||
case "styleChanged":
|
||||
cachedStyles = null;
|
||||
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>
|
||||
<script src="localization.js"></script>
|
||||
<script src="health.js"></script>
|
||||
<script src="storage.js"></script>
|
||||
<script src="messaging.js"></script>
|
||||
</head>
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
</style>
|
||||
|
||||
<script src="localization.js"></script>
|
||||
<script src="health.js"></script>
|
||||
<script src="storage.js"></script>
|
||||
<script src="messaging.js"></script>
|
||||
</head>
|
||||
|
|
|
@ -4,7 +4,12 @@ function getDatabase(ready, error) {
|
|||
ready(stylishDb);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
stylishDb = openDatabase('stylish', '', 'Stylish Styles', 5*1024*1024);
|
||||
} catch (ex) {
|
||||
error();
|
||||
throw ex;
|
||||
}
|
||||
if (stylishDb.version == "1.0" || stylishDb.version == "") {
|
||||
dbV11(stylishDb, error, ready);
|
||||
} else if (stylishDb.version == "1.1") {
|
||||
|
|
Loading…
Reference in New Issue
Block a user