Skip to content

Commit

Permalink
Update MTKruto
Browse files Browse the repository at this point in the history
  • Loading branch information
rojvv committed Apr 7, 2024
1 parent 12287ba commit ce14dc7
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 34 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@twind/preset-tailwind": "https://esm.sh/@twind/preset-tailwind@1.1.4/",
"@twind/preset-autoprefix": "https://esm.sh/@twind/preset-autoprefix@1.0.7/",
"$std/": "https://deno.land/std@0.219.0/",
"mtkruto/": "https://deno.land/x/mtkruto@0.1.183/",
"mtkruto/": "https://deno.land/x/mtkruto@0.1.301/",
"grammy/": "https://deno.land/x/grammy@v1.21.1/",
"dexie": "https://esm.sh/dexie@3.2.6",
"dexie-react-hooks": "https://esm.sh/dexie-react-hooks@1.1.7?alias=react:preact/compat",
Expand Down
6 changes: 0 additions & 6 deletions islands/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ export function Alert(
This can be confirmed by monitoring the requests made while a
connectivity test is in progress.
</p>
<p class="font-bold text-lg">Why does it take so long?</p>
<p>
Exchanging encryption keys might take a little time. After the
keys are exchaged, they are stored locally in your browser, which
makes future tests take much less time.
</p>
</div>
<Button onClick={() => present.value = false}>Dismiss</Button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion islands/InlineMessageIdUnpacker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ComponentChildren } from "preact";
import { signal, useSignalEffect } from "@preact/signals";

import { base64DecodeUrlSafe } from "mtkruto/utilities/1_base64.ts";
import { TLReader } from "mtkruto/tl/3_tl_reader.ts";
import { TLReader } from "mtkruto/tl/4_tl_reader.ts";
import { id, types } from "mtkruto/2_tl.ts";

import { getHashSignal } from "../lib/hash.ts";
Expand Down
5 changes: 3 additions & 2 deletions islands/SessionStringGenerator.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { unreachable } from "$std/assert/unreachable.ts";

import { IS_BROWSER } from "$fresh/runtime.ts";
import { computed, Signal, signal } from "@preact/signals";

import { Client, StorageMemory, types } from "mtkruto/mod.ts";
import { UNREACHABLE } from "mtkruto/1_utilities.ts";
import { getDcIps } from "mtkruto/transport/2_transport_provider.ts";

import { isValidLibrary, ValidLibrary } from "../lib/misc.ts";
Expand Down Expand Up @@ -416,7 +417,7 @@ async function generateSessionString(library: ValidLibrary) { // TODO: report er
const dc = await client.storage.getDc();
const authKey = await client.storage.getAuthKey();
if (!dc || !authKey) {
UNREACHABLE();
unreachable();
}

const ip = getDcIps(dc, "ipv4")[0]; // TODO
Expand Down
16 changes: 8 additions & 8 deletions lib/file_id.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UNREACHABLE } from "mtkruto/utilities/0_control.ts";
import { unreachable } from "$std/assert/unreachable.ts";
import { rleDecode, rleEncode } from "mtkruto/utilities/0_rle.ts";
import {
base64DecodeUrlSafe,
Expand Down Expand Up @@ -217,7 +217,7 @@ function serializePhotoSource(photoSource: PhotoSource, writer: TLWriter) {
writer.writeInt32(photoSource.version);
break;
default:
UNREACHABLE();
unreachable();
}
}
function getPhotoSourceCompareType(source: PhotoSource) {
Expand All @@ -227,7 +227,7 @@ function getPhotoSourceCompareType(source: PhotoSource) {
case PhotoSourceType.Thumbnail: {
const type = source.thumbnailType;
if (!(0 <= type && type <= 127)) {
UNREACHABLE();
unreachable();
}
if (type == "a".charCodeAt(0)) {
return 0;
Expand All @@ -253,7 +253,7 @@ function getPhotoSourceCompareType(source: PhotoSource) {
default:
break;
}
UNREACHABLE();
unreachable();
}
function writePhotoSourceUniqueId(photoSource: PhotoSource, writer: TLWriter) {
const compareType = getPhotoSourceCompareType(photoSource);
Expand All @@ -270,14 +270,14 @@ function writePhotoSourceUniqueId(photoSource: PhotoSource, writer: TLWriter) {
? photoSource.volumeId
: "stickerSetId" in photoSource
? photoSource.stickerSetId
: UNREACHABLE(),
: unreachable(),
);
writer.writeInt32(
"localId" in photoSource
? photoSource.localId
: "version" in photoSource
? photoSource.version
: UNREACHABLE(),
: unreachable(),
);
}

Expand Down Expand Up @@ -325,7 +325,7 @@ function getFileTypeClass(fileType: FileType) {
case FileType.None:
case FileType.Size:
default:
UNREACHABLE();
unreachable();
}
}

Expand Down Expand Up @@ -423,7 +423,7 @@ export function toUniqueFileId(fileId: FileId): string {
switch (fileId.location.source.type) {
case PhotoSourceType.Legacy:
case PhotoSourceType.StickerSetThumbnail:
UNREACHABLE();
unreachable();
/* falls through */
case PhotoSourceType.FullLegacy:
case PhotoSourceType.ChatPhotoSmallLegacy:
Expand Down
Loading

0 comments on commit ce14dc7

Please sign in to comment.