mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 23:06:32 +03:00
fix: get_chat_msgs_ex(): Report local midnight in ChatItem::DayMarker
We were reporting the UTC midnight timestamp instead. For UTC-N timezones that means reporting "yesterday". Fixes https://github.com/deltachat/deltachat-desktop/issues/5215.
This commit is contained in:
@@ -1332,12 +1332,14 @@ dc_msg_t* dc_get_draft (dc_context_t* context, uint32_t ch
|
|||||||
* Optionally, some special markers added to the ID array may help to
|
* Optionally, some special markers added to the ID array may help to
|
||||||
* implement virtual lists.
|
* implement virtual lists.
|
||||||
*
|
*
|
||||||
|
* To get the concrete time of the message, use dc_array_get_timestamp().
|
||||||
|
*
|
||||||
* @memberof dc_context_t
|
* @memberof dc_context_t
|
||||||
* @param context The context object as returned from dc_context_new().
|
* @param context The context object as returned from dc_context_new().
|
||||||
* @param chat_id The chat ID of which the messages IDs should be queried.
|
* @param chat_id The chat ID of which the messages IDs should be queried.
|
||||||
* @param flags If set to DC_GCM_ADDDAYMARKER, the marker DC_MSG_ID_DAYMARKER will
|
* @param flags If set to DC_GCM_ADDDAYMARKER, the marker DC_MSG_ID_DAYMARKER will
|
||||||
* be added before each day (regarding the local timezone). Set this to 0 if you do not want this behaviour.
|
* be added before each day (regarding the local timezone). Set this to 0 if you do not want this behaviour.
|
||||||
* To get the concrete time of the marker, use dc_array_get_timestamp().
|
* The day marker timestamp is the midnight one for the corresponding (following) day in the local timezone.
|
||||||
* If set to DC_GCM_INFO_ONLY, only system messages will be returned, can be combined with DC_GCM_ADDDAYMARKER.
|
* If set to DC_GCM_INFO_ONLY, only system messages will be returned, can be combined with DC_GCM_ADDDAYMARKER.
|
||||||
* @param marker1before Deprecated, set this to 0.
|
* @param marker1before Deprecated, set this to 0.
|
||||||
* @return Array of message IDs, must be dc_array_unref()'d when no longer used.
|
* @return Array of message IDs, must be dc_array_unref()'d when no longer used.
|
||||||
|
|||||||
@@ -1227,8 +1227,10 @@ impl CommandApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns all messages of a particular chat.
|
/// Returns all messages of a particular chat.
|
||||||
/// If `add_daymarker` is `true`, it will return them as
|
///
|
||||||
/// `DC_MSG_ID_DAYMARKER`, e.g. [1234, 1237, 9, 1239].
|
/// * `add_daymarker` - If `true`, add day markers as `DC_MSG_ID_DAYMARKER` to the result,
|
||||||
|
/// e.g. [1234, 1237, 9, 1239]. The day marker timestamp is the midnight one for the
|
||||||
|
/// corresponding (following) day in the local timezone.
|
||||||
async fn get_message_ids(
|
async fn get_message_ids(
|
||||||
&self,
|
&self,
|
||||||
account_id: u32,
|
account_id: u32,
|
||||||
|
|||||||
@@ -3323,10 +3323,11 @@ pub async fn get_chat_msgs_ex(
|
|||||||
for (ts, curr_id) in sorted_rows {
|
for (ts, curr_id) in sorted_rows {
|
||||||
if add_daymarker {
|
if add_daymarker {
|
||||||
let curr_local_timestamp = ts + cnv_to_local;
|
let curr_local_timestamp = ts + cnv_to_local;
|
||||||
let curr_day = curr_local_timestamp / 86400;
|
let secs_in_day = 86400;
|
||||||
|
let curr_day = curr_local_timestamp / secs_in_day;
|
||||||
if curr_day != last_day {
|
if curr_day != last_day {
|
||||||
ret.push(ChatItem::DayMarker {
|
ret.push(ChatItem::DayMarker {
|
||||||
timestamp: curr_day * 86400, // Convert day back to Unix timestamp
|
timestamp: curr_day * secs_in_day - cnv_to_local,
|
||||||
});
|
});
|
||||||
last_day = curr_day;
|
last_day = curr_day;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user