Skip to content

Commit 61eddf3

Browse files
authored
Notice user to use import local file instead of scanning local files (#591)
1 parent 2a224aa commit 61eddf3

File tree

4 files changed

+42
-15
lines changed

4 files changed

+42
-15
lines changed

_locales/en/messages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@
193193
"message": "Capture failed, please reload the page and try again.",
194194
"description": "Capture Failed"
195195
},
196+
"capture_local_file_failed": {
197+
"message": "Are you trying to scan QR code from a local file? Use Import QR Image Backup instead.",
198+
"description": "Import QR image backup instead of scan local image"
199+
},
196200
"based_on_time": {
197201
"message": "Time Based",
198202
"description": "Time Based"

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Import.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ import TextImport from "./Import/TextImport.vue";
4747
4848
export default Vue.extend({
4949
data: function () {
50+
const query = location.search ? location.search.substr(1) : "";
51+
const importType = ["FileImport", "QrImport", "TextImport"].includes(query)
52+
? query
53+
: "FileImport";
5054
return {
51-
importType: "FileImport",
55+
importType,
5256
shouldShowPassphrase: shouldShowPassphrase(this.$entries),
5357
};
5458
},

src/components/Popup/MainHeader.vue

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -172,20 +172,39 @@ export default Vue.extend({
172172
return;
173173
}
174174
175-
chrome.tabs.query({ active: true, lastFocusedWindow: true }, (tabs) => {
176-
const tab = tabs[0];
177-
if (!tab || !tab.id) {
178-
return;
179-
}
180-
chrome.runtime.sendMessage({ action: "updateContentTab", data: tab });
181-
chrome.tabs.sendMessage(tab.id, { action: "capture" }, (result) => {
182-
if (result !== "beginCapture") {
183-
this.$store.commit("notification/alert", this.i18n.capture_failed);
184-
} else {
185-
window.close();
175+
chrome.tabs.query(
176+
{ active: true, lastFocusedWindow: true },
177+
async (tabs) => {
178+
const tab = tabs[0];
179+
if (!tab || !tab.id) {
180+
return;
186181
}
187-
});
188-
});
182+
183+
if (tab.url?.startsWith("file:")) {
184+
if (
185+
await this.$store.dispatch(
186+
"notification/confirm",
187+
this.i18n.capture_local_file_failed
188+
)
189+
) {
190+
window.open("import.html?QrImport", "_blank");
191+
return;
192+
}
193+
}
194+
195+
chrome.runtime.sendMessage({ action: "updateContentTab", data: tab });
196+
chrome.tabs.sendMessage(tab.id, { action: "capture" }, (result) => {
197+
if (result !== "beginCapture") {
198+
this.$store.commit(
199+
"notification/alert",
200+
this.i18n.capture_failed
201+
);
202+
} else {
203+
window.close();
204+
}
205+
});
206+
}
207+
);
189208
return;
190209
},
191210
},

0 commit comments

Comments
 (0)