Skip to content

Commit b4e3ae9

Browse files
committed
fix: unread issue
1 parent bd1d034 commit b4e3ae9

File tree

10 files changed

+44
-55
lines changed

10 files changed

+44
-55
lines changed

crates/restsend-wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "restsend-wasm"
3-
version = "1.2.2"
3+
version = "1.2.3"
44
edition = "2021"
55
description = "Restsend Instant Messaging Javascript/Wasm SDK"
66
authors = ["Restsend Team <[email protected]>"]

crates/restsend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "restsend-sdk"
3-
version = "1.1.9"
3+
version = "1.1.11"
44
edition = "2021"
55

66
[lib]

crates/restsend/src/client/conversation.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,27 @@ impl Client {
305305
continue;
306306
}
307307
let start_seq = c.start_seq.max(c.last_read_seq);
308+
let unread_diff = c.last_seq - c.last_read_seq;
309+
if unread_diff <= 0 {
310+
continue;
311+
}
312+
313+
if unread_diff >= MAX_LOGS_LIMIT as i64 {
314+
if c.unread < MAX_LOGS_LIMIT as i64 {
315+
c.unread = unread_diff;
316+
let t = self.store.message_storage.table::<Conversation>().await;
317+
t.set("", &c.topic_id, Some(c)).await.ok();
318+
continue;
319+
}
320+
}
308321
let logs = match self
309322
.store
310-
.get_chat_logs(&c.topic_id, start_seq, None, MAX_LOGS_LIMIT)
323+
.get_chat_logs(
324+
&c.topic_id,
325+
start_seq,
326+
Some(c.last_seq),
327+
unread_diff.max(MAX_LOGS_LIMIT as i64) as u32,
328+
)
311329
.await
312330
{
313331
Ok((logs, _)) => logs,
@@ -412,6 +430,12 @@ impl Client {
412430
} else {
413431
ChatLogStatus::Received
414432
};
433+
c.is_countable =
434+
if let Some(cb) = self.store.countable_callback.read().unwrap().as_ref() {
435+
cb.is_countable(c.content.clone())
436+
} else {
437+
!c.content.unreadable
438+
};
415439
}
416440
self.store.save_chat_logs(&lr.items).await.ok();
417441

@@ -425,10 +449,6 @@ impl Client {
425449
None => continue,
426450
};
427451

428-
if self.store.countable_callback.read().unwrap().is_some() {
429-
conversation.unread = 0
430-
}
431-
432452
for c in lr.items.iter() {
433453
if c.is_countable && c.seq > conversation.last_read_seq {
434454
conversation.unread += 1;

js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"Restsend Team <[email protected]>"
66
],
77
"description": "Restsend Instant Messaging Javascript/Wasm SDK",
8-
"version": "1.2.2",
8+
"version": "1.2.3",
99
"files": [
1010
"restsend_wasm_bg.wasm",
1111
"restsend_wasm.js",

js/restsend_wasm.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,8 @@ export interface InitOutput {
852852
readonly __wbindgen_export_4: WebAssembly.Table;
853853
readonly __wbindgen_export_5: WebAssembly.Table;
854854
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
855-
readonly closure634_externref_shim: (a: number, b: number, c: any) => void;
856-
readonly _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf75a6e527d269343: (a: number, b: number) => void;
855+
readonly closure633_externref_shim: (a: number, b: number, c: any) => void;
856+
readonly _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hae1d08d0dc98b704: (a: number, b: number) => void;
857857
readonly closure843_externref_shim: (a: number, b: number, c: any) => void;
858858
readonly closure884_externref_shim: (a: number, b: number, c: any, d: any) => void;
859859
readonly __wbindgen_start: () => void;

js/restsend_wasm.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,11 @@ export function setLogging(level) {
287287
}
288288

289289
function __wbg_adapter_54(arg0, arg1, arg2) {
290-
wasm.closure634_externref_shim(arg0, arg1, arg2);
290+
wasm.closure633_externref_shim(arg0, arg1, arg2);
291291
}
292292

293-
function __wbg_adapter_57(arg0, arg1) {
294-
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf75a6e527d269343(arg0, arg1);
293+
function __wbg_adapter_59(arg0, arg1) {
294+
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hae1d08d0dc98b704(arg0, arg1);
295295
}
296296

297297
function __wbg_adapter_66(arg0, arg1, arg2) {
@@ -2344,7 +2344,7 @@ function __wbg_get_imports() {
23442344
imports.wbg.__wbg_setRequestHeader_51d371ad5196f6ef = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
23452345
arg0.setRequestHeader(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
23462346
}, arguments) };
2347-
imports.wbg.__wbg_setTimeout_36de58ba0b8e4a16 = function(arg0, arg1) {
2347+
imports.wbg.__wbg_setTimeout_6db046170d8973ed = function(arg0, arg1) {
23482348
setTimeout(arg0, arg1 >>> 0);
23492349
};
23502350
imports.wbg.__wbg_set_37837023f3d740e8 = function(arg0, arg1, arg2) {
@@ -2548,26 +2548,26 @@ function __wbg_get_imports() {
25482548
return ret;
25492549
};
25502550
imports.wbg.__wbindgen_closure_wrapper1442 = function(arg0, arg1, arg2) {
2551-
const ret = makeMutClosure(arg0, arg1, 632, __wbg_adapter_54);
2551+
const ret = makeMutClosure(arg0, arg1, 631, __wbg_adapter_54);
25522552
return ret;
25532553
};
25542554
imports.wbg.__wbindgen_closure_wrapper1443 = function(arg0, arg1, arg2) {
2555-
const ret = makeMutClosure(arg0, arg1, 632, __wbg_adapter_57);
2555+
const ret = makeMutClosure(arg0, arg1, 631, __wbg_adapter_54);
25562556
return ret;
25572557
};
25582558
imports.wbg.__wbindgen_closure_wrapper1444 = function(arg0, arg1, arg2) {
2559-
const ret = makeMutClosure(arg0, arg1, 632, __wbg_adapter_54);
2559+
const ret = makeMutClosure(arg0, arg1, 631, __wbg_adapter_59);
25602560
return ret;
25612561
};
2562-
imports.wbg.__wbindgen_closure_wrapper1447 = function(arg0, arg1, arg2) {
2563-
const ret = makeMutClosure(arg0, arg1, 632, __wbg_adapter_54);
2562+
imports.wbg.__wbindgen_closure_wrapper1448 = function(arg0, arg1, arg2) {
2563+
const ret = makeMutClosure(arg0, arg1, 631, __wbg_adapter_54);
25642564
return ret;
25652565
};
25662566
imports.wbg.__wbindgen_closure_wrapper1450 = function(arg0, arg1, arg2) {
2567-
const ret = makeMutClosure(arg0, arg1, 632, __wbg_adapter_54);
2567+
const ret = makeMutClosure(arg0, arg1, 631, __wbg_adapter_54);
25682568
return ret;
25692569
};
2570-
imports.wbg.__wbindgen_closure_wrapper2277 = function(arg0, arg1, arg2) {
2570+
imports.wbg.__wbindgen_closure_wrapper2276 = function(arg0, arg1, arg2) {
25712571
const ret = makeMutClosure(arg0, arg1, 844, __wbg_adapter_66);
25722572
return ret;
25732573
};

js/restsend_wasm_bg.wasm

1.03 KB
Binary file not shown.

js/restsend_wasm_bg.wasm.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ export const __externref_table_alloc: () => number;
103103
export const __wbindgen_export_4: WebAssembly.Table;
104104
export const __wbindgen_export_5: WebAssembly.Table;
105105
export const __wbindgen_free: (a: number, b: number, c: number) => void;
106-
export const closure634_externref_shim: (a: number, b: number, c: any) => void;
107-
export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf75a6e527d269343: (a: number, b: number) => void;
106+
export const closure633_externref_shim: (a: number, b: number, c: any) => void;
107+
export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hae1d08d0dc98b704: (a: number, b: number) => void;
108108
export const closure843_externref_shim: (a: number, b: number, c: any) => void;
109109
export const closure884_externref_shim: (a: number, b: number, c: any, d: any) => void;
110110
export const __wbindgen_start: () => void;

kotlin/uniffi/restsend_sdk/restsend_sdk.kt

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,8 +1176,6 @@ internal open class UniffiVTableCallbackInterfaceUploadCallback(
11761176

11771177

11781178

1179-
1180-
11811179

11821180

11831181

@@ -1354,8 +1352,6 @@ fun uniffi_restsend_sdk_checksum_method_client_sync_conversations(
13541352
): Short
13551353
fun uniffi_restsend_sdk_checksum_method_client_transfer_topic(
13561354
): Short
1357-
fun uniffi_restsend_sdk_checksum_method_client_try_sync_chat_logs(
1358-
): Short
13591355
fun uniffi_restsend_sdk_checksum_method_client_update_topic(
13601356
): Short
13611357
fun uniffi_restsend_sdk_checksum_method_client_update_topic_notice(
@@ -1622,8 +1618,6 @@ fun uniffi_restsend_sdk_fn_method_client_sync_conversations(`ptr`: Pointer,`upda
16221618
): Long
16231619
fun uniffi_restsend_sdk_fn_method_client_transfer_topic(`ptr`: Pointer,`topicId`: RustBuffer.ByValue,`userId`: RustBuffer.ByValue,
16241620
): Long
1625-
fun uniffi_restsend_sdk_fn_method_client_try_sync_chat_logs(`ptr`: Pointer,`conversation`: RustBuffer.ByValue,`limit`: RustBuffer.ByValue,
1626-
): Long
16271621
fun uniffi_restsend_sdk_fn_method_client_update_topic(`ptr`: Pointer,`topicId`: RustBuffer.ByValue,`name`: RustBuffer.ByValue,`icon`: RustBuffer.ByValue,
16281622
): Long
16291623
fun uniffi_restsend_sdk_fn_method_client_update_topic_notice(`ptr`: Pointer,`topicId`: RustBuffer.ByValue,`text`: RustBuffer.ByValue,
@@ -2021,9 +2015,6 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {
20212015
if (lib.uniffi_restsend_sdk_checksum_method_client_transfer_topic() != 22182.toShort()) {
20222016
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
20232017
}
2024-
if (lib.uniffi_restsend_sdk_checksum_method_client_try_sync_chat_logs() != 8690.toShort()) {
2025-
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
2026-
}
20272018
if (lib.uniffi_restsend_sdk_checksum_method_client_update_topic() != 54199.toShort()) {
20282019
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
20292020
}
@@ -2713,8 +2704,6 @@ public interface ClientInterface {
27132704

27142705
suspend fun `transferTopic`(`topicId`: kotlin.String, `userId`: kotlin.String)
27152706

2716-
suspend fun `trySyncChatLogs`(`conversation`: Conversation, `limit`: kotlin.UInt?): Conversation?
2717-
27182707
suspend fun `updateTopic`(`topicId`: kotlin.String, `name`: kotlin.String?, `icon`: kotlin.String?)
27192708

27202709
suspend fun `updateTopicNotice`(`topicId`: kotlin.String, `text`: kotlin.String)
@@ -4248,26 +4237,6 @@ open class Client: Disposable, AutoCloseable, ClientInterface
42484237
}
42494238

42504239

4251-
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
4252-
override suspend fun `trySyncChatLogs`(`conversation`: Conversation, `limit`: kotlin.UInt?) : Conversation? {
4253-
return uniffiRustCallAsync(
4254-
callWithPointer { thisPtr ->
4255-
UniffiLib.INSTANCE.uniffi_restsend_sdk_fn_method_client_try_sync_chat_logs(
4256-
thisPtr,
4257-
FfiConverterTypeConversation.lower(`conversation`),FfiConverterOptionalUInt.lower(`limit`),
4258-
)
4259-
},
4260-
{ future, callback, continuation -> UniffiLib.INSTANCE.ffi_restsend_sdk_rust_future_poll_rust_buffer(future, callback, continuation) },
4261-
{ future, continuation -> UniffiLib.INSTANCE.ffi_restsend_sdk_rust_future_complete_rust_buffer(future, continuation) },
4262-
{ future -> UniffiLib.INSTANCE.ffi_restsend_sdk_rust_future_free_rust_buffer(future) },
4263-
// lift function
4264-
{ FfiConverterOptionalTypeConversation.lift(it) },
4265-
// Error FFI converter
4266-
UniffiNullRustCallStatusErrorHandler,
4267-
)
4268-
}
4269-
4270-
42714240
@Throws(ClientException::class)
42724241
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
42734242
override suspend fun `updateTopic`(`topicId`: kotlin.String, `name`: kotlin.String?, `icon`: kotlin.String?) {

swift/RestsendSdk.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "RestsendSdk"
3-
s.version = "1.1.9"
3+
s.version = "1.1.11"
44
s.summary = "Restsend client sdk for iOS"
55
s.homepage = "https://github.com/restsend/restsend-rs"
66
s.license = { :type => "MIT" }

0 commit comments

Comments
 (0)