fix remove provider from backup and #7167

This commit is contained in:
Sebastian 2022-02-01 13:26:56 -03:00
parent 54d5cc02d1
commit bc1c33e1ce
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
4 changed files with 27 additions and 19 deletions

View File

@ -81,6 +81,7 @@ export function getPermissionsApi(): CrossBrowserPermissionsApi {
) {
return {
addPermissionsListener: () => {
console.log("not supported for firefox")
// Not supported yet.
},
contains: myBrowser.permissions.contains,

View File

@ -111,7 +111,7 @@ export function TransactionItem(props: { tx: Transaction }): VNode {
debitCreditIndicator={"debit"}
title={tx.targetPaytoUri}
timestamp={tx.timestamp}
iconPath={imageRefresh}
iconPath={imageBank}
pending={tx.pending}
/>
);

View File

@ -19,11 +19,11 @@ import * as wxApi from "../wxApi";
import { getPermissionsApi } from "../compat";
import { getReadRequestPermissions } from "../permissions";
export function useExtendedPermissions(): [boolean, () => void] {
export function useExtendedPermissions(): [boolean, () => Promise<void>] {
const [enabled, setEnabled] = useState(false);
const toggle = () => {
handleExtendedPerm(enabled, setEnabled)
const toggle = async () => {
return handleExtendedPerm(enabled, setEnabled)
};
useEffect(() => {
@ -36,22 +36,29 @@ export function useExtendedPermissions(): [boolean, () => void] {
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) {
// We set permissions here, since apparently FF wants this to be done
// as the result of an input event ...
return new Promise<void>((res) => {
getPermissionsApi().request(getReadRequestPermissions(), async (granted: boolean) => {
console.log("permissions granted:", granted);
if (chrome.runtime.lastError) {
console.error("error requesting permissions");
console.error(chrome.runtime.lastError);
onChange(false);
return;
}
console.log("permissions granted:", granted);
try {
const res = await wxApi.setExtendedPermissions(granted);
onChange(res.newValue);
});
} else {
wxApi.setExtendedPermissions(false).then(r => onChange(r.newValue));
} finally {
res()
}
});
})
}
await wxApi.setExtendedPermissions(false).then(r => onChange(r.newValue));
return
}

View File

@ -83,7 +83,7 @@ export function ProviderDetailPage({ pid: providerURL, onBack }: Props): VNode {
<ProviderView
info={state.response}
onSync={async () => wxApi.syncOneProvider(providerURL)}
onDelete={async () => wxApi.syncOneProvider(providerURL).then(onBack)}
onDelete={async () => wxApi.removeProvider(providerURL).then(onBack)}
onBack={onBack}
onExtend={() => {
null;