Skip to content

Commit 75fe4e1

Browse files
committed
api!: remove deprecated get_next_media() APIs
1 parent 7c60ac8 commit 75fe4e1

File tree

6 files changed

+0
-237
lines changed

6 files changed

+0
-237
lines changed

deltachat-ffi/deltachat.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,30 +1547,6 @@ void dc_marknoticed_chat (dc_context_t* context, uint32_t ch
15471547
dc_array_t* dc_get_chat_media (dc_context_t* context, uint32_t chat_id, int msg_type, int msg_type2, int msg_type3);
15481548

15491549

1550-
/**
1551-
* Search next/previous message based on a given message and a list of types.
1552-
* Typically used to implement the "next" and "previous" buttons
1553-
* in a gallery or in a media player.
1554-
*
1555-
* @deprecated Deprecated 2023-10-03, use dc_get_chat_media() and navigate the returned array instead.
1556-
* @memberof dc_context_t
1557-
* @param context The context object as returned from dc_context_new().
1558-
* @param msg_id The ID of the current message from which the next or previous message should be searched.
1559-
* @param dir 1=get the next message, -1=get the previous one.
1560-
* @param msg_type The message type to search for.
1561-
* If 0, the message type from curr_msg_id is used.
1562-
* @param msg_type2 Alternative message type to search for. 0 to skip.
1563-
* @param msg_type3 Alternative message type to search for. 0 to skip.
1564-
* @return Returns the message ID that should be played next.
1565-
* The returned message is in the same chat as the given one
1566-
* and has one of the given types.
1567-
* Typically, this result is passed again to dc_get_next_media()
1568-
* later on the next swipe.
1569-
* If there is not next/previous message, the function returns 0.
1570-
*/
1571-
uint32_t dc_get_next_media (dc_context_t* context, uint32_t msg_id, int dir, int msg_type, int msg_type2, int msg_type3);
1572-
1573-
15741550
/**
15751551
* Set chat visibility to pinned, archived or normal.
15761552
*

deltachat-ffi/src/lib.rs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,48 +1443,6 @@ pub unsafe extern "C" fn dc_get_chat_media(
14431443
})
14441444
}
14451445

1446-
#[no_mangle]
1447-
#[allow(deprecated)]
1448-
pub unsafe extern "C" fn dc_get_next_media(
1449-
context: *mut dc_context_t,
1450-
msg_id: u32,
1451-
dir: libc::c_int,
1452-
msg_type: libc::c_int,
1453-
or_msg_type2: libc::c_int,
1454-
or_msg_type3: libc::c_int,
1455-
) -> u32 {
1456-
if context.is_null() {
1457-
eprintln!("ignoring careless call to dc_get_next_media()");
1458-
return 0;
1459-
}
1460-
let direction = if dir < 0 {
1461-
chat::Direction::Backward
1462-
} else {
1463-
chat::Direction::Forward
1464-
};
1465-
1466-
let ctx = &*context;
1467-
let msg_type = from_prim(msg_type).expect(&format!("invalid msg_type = {msg_type}"));
1468-
let or_msg_type2 =
1469-
from_prim(or_msg_type2).expect(&format!("incorrect or_msg_type2 = {or_msg_type2}"));
1470-
let or_msg_type3 =
1471-
from_prim(or_msg_type3).expect(&format!("incorrect or_msg_type3 = {or_msg_type3}"));
1472-
1473-
block_on(async move {
1474-
chat::get_next_media(
1475-
ctx,
1476-
MsgId::new(msg_id),
1477-
direction,
1478-
msg_type,
1479-
or_msg_type2,
1480-
or_msg_type3,
1481-
)
1482-
.await
1483-
.map(|msg_id| msg_id.map(|id| id.to_u32()).unwrap_or_default())
1484-
.unwrap_or(0)
1485-
})
1486-
}
1487-
14881446
#[no_mangle]
14891447
pub unsafe extern "C" fn dc_set_chat_visibility(
14901448
context: *mut dc_context_t,

deltachat-jsonrpc/src/api.rs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,55 +1552,6 @@ impl CommandApi {
15521552
Ok(media.iter().map(|msg_id| msg_id.to_u32()).collect())
15531553
}
15541554

1555-
/// Search next/previous message based on a given message and a list of types.
1556-
/// Typically used to implement the "next" and "previous" buttons
1557-
/// in a gallery or in a media player.
1558-
///
1559-
/// one combined call for getting chat::get_next_media for both directions
1560-
/// the manual chat::get_next_media in only one direction is not exposed by the jsonrpc yet
1561-
///
1562-
/// Deprecated 2023-10-03, use `get_chat_media` method
1563-
/// and navigate the returned array instead.
1564-
#[allow(deprecated)]
1565-
async fn get_neighboring_chat_media(
1566-
&self,
1567-
account_id: u32,
1568-
msg_id: u32,
1569-
message_type: MessageViewtype,
1570-
or_message_type2: Option<MessageViewtype>,
1571-
or_message_type3: Option<MessageViewtype>,
1572-
) -> Result<(Option<u32>, Option<u32>)> {
1573-
let ctx = self.get_context(account_id).await?;
1574-
1575-
let msg_type: Viewtype = message_type.into();
1576-
let msg_type2: Viewtype = or_message_type2.map(|v| v.into()).unwrap_or_default();
1577-
let msg_type3: Viewtype = or_message_type3.map(|v| v.into()).unwrap_or_default();
1578-
1579-
let prev = chat::get_next_media(
1580-
&ctx,
1581-
MsgId::new(msg_id),
1582-
chat::Direction::Backward,
1583-
msg_type,
1584-
msg_type2,
1585-
msg_type3,
1586-
)
1587-
.await?
1588-
.map(|id| id.to_u32());
1589-
1590-
let next = chat::get_next_media(
1591-
&ctx,
1592-
MsgId::new(msg_id),
1593-
chat::Direction::Forward,
1594-
msg_type,
1595-
msg_type2,
1596-
msg_type3,
1597-
)
1598-
.await?
1599-
.map(|id| id.to_u32());
1600-
1601-
Ok((prev, next))
1602-
}
1603-
16041555
// ---------------------------------------------
16051556
// backup
16061557
// ---------------------------------------------

node/lib/context.ts

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -475,47 +475,6 @@ export class Context extends EventEmitter {
475475
return binding.dcn_get_msg_html(this.dcn_context, Number(messageId))
476476
}
477477

478-
getNextMediaMessage(
479-
messageId: number,
480-
msgType1: number,
481-
msgType2: number,
482-
msgType3: number
483-
) {
484-
debug(
485-
`getNextMediaMessage ${messageId} ${msgType1} ${msgType2} ${msgType3}`
486-
)
487-
return this._getNextMedia(messageId, 1, msgType1, msgType2, msgType3)
488-
}
489-
490-
getPreviousMediaMessage(
491-
messageId: number,
492-
msgType1: number,
493-
msgType2: number,
494-
msgType3: number
495-
) {
496-
debug(
497-
`getPreviousMediaMessage ${messageId} ${msgType1} ${msgType2} ${msgType3}`
498-
)
499-
return this._getNextMedia(messageId, -1, msgType1, msgType2, msgType3)
500-
}
501-
502-
_getNextMedia(
503-
messageId: number,
504-
dir: number,
505-
msgType1: number,
506-
msgType2: number,
507-
msgType3: number
508-
): number {
509-
return binding.dcn_get_next_media(
510-
this.dcn_context,
511-
Number(messageId),
512-
dir,
513-
msgType1 || 0,
514-
msgType2 || 0,
515-
msgType3 || 0
516-
)
517-
}
518-
519478
getSecurejoinQrCode(chatId: number): string {
520479
debug(`getSecurejoinQrCode ${chatId}`)
521480
return binding.dcn_get_securejoin_qr(this.dcn_context, Number(chatId))

node/src/module.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,27 +1053,6 @@ NAPI_METHOD(dcn_get_msg_html) {
10531053
NAPI_RETURN_AND_UNREF_STRING(msg_html);
10541054
}
10551055

1056-
NAPI_METHOD(dcn_get_next_media) {
1057-
NAPI_ARGV(6);
1058-
NAPI_DCN_CONTEXT();
1059-
NAPI_ARGV_UINT32(msg_id, 1);
1060-
NAPI_ARGV_INT32(dir, 2);
1061-
NAPI_ARGV_INT32(msg_type1, 3);
1062-
NAPI_ARGV_INT32(msg_type2, 4);
1063-
NAPI_ARGV_INT32(msg_type3, 5);
1064-
1065-
//TRACE("calling..");
1066-
uint32_t next_id = dc_get_next_media(dcn_context->dc_context,
1067-
msg_id,
1068-
dir,
1069-
msg_type1,
1070-
msg_type2,
1071-
msg_type3);
1072-
//TRACE("result %d", next_id);
1073-
1074-
NAPI_RETURN_UINT32(next_id);
1075-
}
1076-
10771056
NAPI_METHOD(dcn_set_chat_visibility) {
10781057
NAPI_ARGV(3);
10791058
NAPI_DCN_CONTEXT();
@@ -3443,7 +3422,6 @@ NAPI_INIT() {
34433422
NAPI_EXPORT_FUNCTION(dcn_get_msg_cnt);
34443423
NAPI_EXPORT_FUNCTION(dcn_get_msg_info);
34453424
NAPI_EXPORT_FUNCTION(dcn_get_msg_html);
3446-
NAPI_EXPORT_FUNCTION(dcn_get_next_media);
34473425
NAPI_EXPORT_FUNCTION(dcn_set_chat_visibility);
34483426
NAPI_EXPORT_FUNCTION(dcn_get_securejoin_qr);
34493427
NAPI_EXPORT_FUNCTION(dcn_get_securejoin_qr_svg);

src/chat.rs

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -3416,65 +3416,6 @@ pub async fn get_chat_media(
34163416
Ok(list)
34173417
}
34183418

3419-
/// Indicates the direction over which to iterate.
3420-
#[derive(Debug, Clone, PartialEq, Eq)]
3421-
#[repr(i32)]
3422-
pub enum Direction {
3423-
/// Search forward.
3424-
Forward = 1,
3425-
3426-
/// Search backward.
3427-
Backward = -1,
3428-
}
3429-
3430-
/// Searches next/previous message based on the given message and list of types.
3431-
///
3432-
/// Deprecated since 2023-10-03.
3433-
#[deprecated(note = "use `get_chat_media` instead")]
3434-
pub async fn get_next_media(
3435-
context: &Context,
3436-
curr_msg_id: MsgId,
3437-
direction: Direction,
3438-
msg_type: Viewtype,
3439-
msg_type2: Viewtype,
3440-
msg_type3: Viewtype,
3441-
) -> Result<Option<MsgId>> {
3442-
let mut ret: Option<MsgId> = None;
3443-
3444-
if let Ok(msg) = Message::load_from_db(context, curr_msg_id).await {
3445-
let list: Vec<MsgId> = get_chat_media(
3446-
context,
3447-
Some(msg.chat_id),
3448-
if msg_type != Viewtype::Unknown {
3449-
msg_type
3450-
} else {
3451-
msg.viewtype
3452-
},
3453-
msg_type2,
3454-
msg_type3,
3455-
)
3456-
.await?;
3457-
for (i, msg_id) in list.iter().enumerate() {
3458-
if curr_msg_id == *msg_id {
3459-
match direction {
3460-
Direction::Forward => {
3461-
if i + 1 < list.len() {
3462-
ret = list.get(i + 1).copied();
3463-
}
3464-
}
3465-
Direction::Backward => {
3466-
if i >= 1 {
3467-
ret = list.get(i - 1).copied();
3468-
}
3469-
}
3470-
}
3471-
break;
3472-
}
3473-
}
3474-
}
3475-
Ok(ret)
3476-
}
3477-
34783419
/// Returns a vector of contact IDs for given chat ID.
34793420
pub async fn get_chat_contacts(context: &Context, chat_id: ChatId) -> Result<Vec<ContactId>> {
34803421
// Normal chats do not include SELF. Group chats do (as it may happen that one is deleted from a

0 commit comments

Comments
 (0)