Improve context page display on mobile (#1359)

This commit is contained in:
toasted-nutbread 2021-02-08 17:53:22 -05:00 committed by GitHub
parent e386599872
commit 0d031ab785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,9 +88,39 @@ class DisplayController {
} }
async _setupEnvironment() { async _setupEnvironment() {
// Firefox mobile opens this page as a full webpage. const urlSearchParams = new URLSearchParams(location.search);
const {browser} = await api.getEnvironmentInfo(); let mode = urlSearchParams.get('mode');
document.documentElement.dataset.mode = (browser === 'firefox-mobile' ? 'full' : 'mini'); switch (mode) {
case 'full':
case 'mini':
break;
default:
{
let tab;
try {
tab = await this._getCurrentTab();
} catch (e) {
// NOP
}
mode = (tab ? 'full' : 'mini');
}
break;
}
document.documentElement.dataset.mode = mode;
}
_getCurrentTab() {
return new Promise((resolve, reject) => {
chrome.tabs.getCurrent((result) => {
const e = chrome.runtime.lastError;
if (e) {
reject(new Error(e.message));
} else {
resolve(result);
}
});
});
} }
_setupOptions({options}) { _setupOptions({options}) {