Refactor Signal app routing

This commit is contained in:
Jamie Kyle 2023-11-02 12:42:31 -07:00 committed by GitHub
parent 86e6c2499c
commit 3ef0d221d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 1347 additions and 1044 deletions

View file

@ -9,6 +9,8 @@ import * as log from './logging/log';
import { explodePromise } from './util/explodePromise';
import { ipcInvoke } from './sql/channels';
import { SECOND } from './util/durations';
import { isSignalRoute } from './util/signalRoutes';
import { strictAssert } from './util/assert';
type ResolveType = (data: unknown) => void;
@ -28,6 +30,7 @@ export type CIType = {
ignorePastEvents?: boolean;
}
) => unknown;
openSignalRoute(url: string): Promise<void>;
};
export function getCI(deviceName: string): CIType {
@ -133,6 +136,20 @@ export function getCI(deviceName: string): CIType {
return window.ConversationController.getConversationId(address);
}
async function openSignalRoute(url: string) {
strictAssert(
isSignalRoute(url),
`openSignalRoute: not a valid signal route ${url}`
);
const a = document.createElement('a');
a.href = url;
a.target = '_blank';
a.hidden = true;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
return {
deviceName,
getConversationId,
@ -141,5 +158,6 @@ export function getCI(deviceName: string): CIType {
setProvisioningURL,
solveChallenge,
waitForEvent,
openSignalRoute,
};
}