Support device name change sync message

This commit is contained in:
trevor-signal 2024-12-09 13:22:15 -05:00 committed by GitHub
parent 1c4e7bc85d
commit 96de2c2a38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 190 additions and 12 deletions

View file

@ -862,6 +862,19 @@ export type GetAccountForUsernameResultType = z.infer<
typeof getAccountForUsernameResultZod
>;
const getDevicesResultZod = z.object({
devices: z.array(
z.object({
id: z.number(),
name: z.string().nullish(), // primary devices may not have a name
lastSeen: z.number().nullish(),
created: z.number().nullish(),
})
),
});
export type GetDevicesResultType = z.infer<typeof getDevicesResultZod>;
export type GetIceServersResultType = Readonly<{
relays?: ReadonlyArray<IceServerGroupType>;
}>;
@ -874,15 +887,6 @@ export type IceServerGroupType = Readonly<{
hostname?: string;
}>;
export type GetDevicesResultType = ReadonlyArray<
Readonly<{
id: number;
name: string;
lastSeen: number;
created: number;
}>
>;
export type GetSenderCertificateResultType = Readonly<{ certificate: string }>;
export type MakeProxiedRequestResultType =
@ -1376,6 +1380,7 @@ export type WebAPIType = {
getAccountForUsername: (
options: GetAccountForUsernameOptionsType
) => Promise<GetAccountForUsernameResultType>;
getDevices: () => Promise<GetDevicesResultType>;
getProfileUnauth: (
serviceId: ServiceIdString,
options: ProfileFetchUnauthRequestOptions
@ -1847,6 +1852,7 @@ export function initialize({
getBackupUploadForm,
getBadgeImageFile,
getConfig,
getDevices,
getGroup,
getGroupAvatar,
getGroupCredentials,
@ -2935,6 +2941,15 @@ export function initialize({
});
}
async function getDevices() {
const result = await _ajax({
call: 'devices',
httpType: 'GET',
responseType: 'json',
});
return parseUnknown(getDevicesResultZod, result);
}
async function updateDeviceName(deviceName: string) {
await _ajax({
call: 'updateDeviceName',