Skip to content

Commit

Permalink
Merge pull request #660 from squidowl/fix/misc-chathistory
Browse files Browse the repository at this point in the history
Miscellaneous Chat History Fixes
  • Loading branch information
andymandias authored Nov 26, 2024
2 parents 5813d89 + 7210b25 commit ac01ce1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
18 changes: 8 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,17 +767,16 @@ impl Halloy {
);
}
data::client::Event::JoinedChannel(channel, server_time) => {
if let Some(command) = dashboard
let command = dashboard
.load_metadata(
&self.clients,
server.clone(),
channel.clone(),
server_time,
)
.map(|command| command.map(Message::Dashboard))
{
commands.push(command);
}
.map(Message::Dashboard);

commands.push(command);
}
data::client::Event::ChatHistoryAcknowledged(server_time) => {
if let Some(command) = dashboard
Expand All @@ -795,17 +794,16 @@ impl Halloy {
target,
server_time,
) => {
if let Some(command) = dashboard
let command = dashboard
.load_metadata(
&self.clients,
server.clone(),
target.clone(),
server_time,
)
.map(|command| command.map(Message::Dashboard))
{
commands.push(command);
}
.map(Message::Dashboard);

commands.push(command);
}
data::client::Event::ChatHistoryTargetsReceived(
server_time,
Expand Down
35 changes: 20 additions & 15 deletions src/screen/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1488,14 +1488,21 @@ impl Dashboard {
&message_reference_types,
);

clients.send_chathistory_request(
server,
let subcommand = if matches!(first_can_reference, MessageReference::None) {
ChatHistorySubcommand::Latest(
target.clone(),
first_can_reference,
clients.get_server_chathistory_limit(server),
)
} else {
ChatHistorySubcommand::Before(
target.clone(),
first_can_reference,
clients.get_server_chathistory_limit(server),
),
);
)
};

clients.send_chathistory_request(server, subcommand);
}
}
}
Expand Down Expand Up @@ -1533,21 +1540,19 @@ impl Dashboard {
server: Server,
channel: String,
server_time: DateTime<Utc>,
) -> Option<Task<Message>> {
) -> Task<Message> {
let command = self
.history
.load_metadata(server.clone(), channel.clone())
.map(|task| Task::perform(task, Message::History));
.map_or(Task::none(), |task| Task::perform(task, Message::History));

command.map(|command| {
if clients.get_server_supports_chathistory(&server) {
command.chain(Task::done(Message::Client(
data::client::Message::RequestNewerChatHistory(server, channel, server_time),
)))
} else {
command
}
})
if clients.get_server_supports_chathistory(&server) {
command.chain(Task::done(Message::Client(
data::client::Message::RequestNewerChatHistory(server, channel, server_time),
)))
} else {
command
}
}

pub fn load_chathistory_targets_timestamp(
Expand Down

0 comments on commit ac01ce1

Please sign in to comment.