fix remove provider from backup and #7167
This commit is contained in:
parent
54d5cc02d1
commit
bc1c33e1ce
@ -81,6 +81,7 @@ export function getPermissionsApi(): CrossBrowserPermissionsApi {
|
|||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
addPermissionsListener: () => {
|
addPermissionsListener: () => {
|
||||||
|
console.log("not supported for firefox")
|
||||||
// Not supported yet.
|
// Not supported yet.
|
||||||
},
|
},
|
||||||
contains: myBrowser.permissions.contains,
|
contains: myBrowser.permissions.contains,
|
||||||
|
@ -111,7 +111,7 @@ export function TransactionItem(props: { tx: Transaction }): VNode {
|
|||||||
debitCreditIndicator={"debit"}
|
debitCreditIndicator={"debit"}
|
||||||
title={tx.targetPaytoUri}
|
title={tx.targetPaytoUri}
|
||||||
timestamp={tx.timestamp}
|
timestamp={tx.timestamp}
|
||||||
iconPath={imageRefresh}
|
iconPath={imageBank}
|
||||||
pending={tx.pending}
|
pending={tx.pending}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -19,11 +19,11 @@ import * as wxApi from "../wxApi";
|
|||||||
import { getPermissionsApi } from "../compat";
|
import { getPermissionsApi } from "../compat";
|
||||||
import { getReadRequestPermissions } from "../permissions";
|
import { getReadRequestPermissions } from "../permissions";
|
||||||
|
|
||||||
export function useExtendedPermissions(): [boolean, () => void] {
|
export function useExtendedPermissions(): [boolean, () => Promise<void>] {
|
||||||
const [enabled, setEnabled] = useState(false);
|
const [enabled, setEnabled] = useState(false);
|
||||||
|
|
||||||
const toggle = () => {
|
const toggle = async () => {
|
||||||
handleExtendedPerm(enabled, setEnabled)
|
return handleExtendedPerm(enabled, setEnabled)
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -36,22 +36,29 @@ export function useExtendedPermissions(): [boolean, () => void] {
|
|||||||
return [enabled, toggle];
|
return [enabled, toggle];
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleExtendedPerm(isEnabled: boolean, onChange: (value: boolean) => void): void {
|
async function handleExtendedPerm(isEnabled: boolean, onChange: (value: boolean) => void): Promise<void> {
|
||||||
if (!isEnabled) {
|
if (!isEnabled) {
|
||||||
// We set permissions here, since apparently FF wants this to be done
|
// We set permissions here, since apparently FF wants this to be done
|
||||||
// as the result of an input event ...
|
// as the result of an input event ...
|
||||||
|
return new Promise<void>((res) => {
|
||||||
getPermissionsApi().request(getReadRequestPermissions(), async (granted: boolean) => {
|
getPermissionsApi().request(getReadRequestPermissions(), async (granted: boolean) => {
|
||||||
|
console.log("permissions granted:", granted);
|
||||||
if (chrome.runtime.lastError) {
|
if (chrome.runtime.lastError) {
|
||||||
console.error("error requesting permissions");
|
console.error("error requesting permissions");
|
||||||
console.error(chrome.runtime.lastError);
|
console.error(chrome.runtime.lastError);
|
||||||
onChange(false);
|
onChange(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("permissions granted:", granted);
|
try {
|
||||||
const res = await wxApi.setExtendedPermissions(granted);
|
const res = await wxApi.setExtendedPermissions(granted);
|
||||||
onChange(res.newValue);
|
onChange(res.newValue);
|
||||||
});
|
} finally {
|
||||||
} else {
|
res()
|
||||||
wxApi.setExtendedPermissions(false).then(r => onChange(r.newValue));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
await wxApi.setExtendedPermissions(false).then(r => onChange(r.newValue));
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ export function ProviderDetailPage({ pid: providerURL, onBack }: Props): VNode {
|
|||||||
<ProviderView
|
<ProviderView
|
||||||
info={state.response}
|
info={state.response}
|
||||||
onSync={async () => wxApi.syncOneProvider(providerURL)}
|
onSync={async () => wxApi.syncOneProvider(providerURL)}
|
||||||
onDelete={async () => wxApi.syncOneProvider(providerURL).then(onBack)}
|
onDelete={async () => wxApi.removeProvider(providerURL).then(onBack)}
|
||||||
onBack={onBack}
|
onBack={onBack}
|
||||||
onExtend={() => {
|
onExtend={() => {
|
||||||
null;
|
null;
|
||||||
|
Loading…
Reference in New Issue
Block a user