Merge pull request #26 from kallisti5/fixes

A crash fix, as well as fixes for the latest matrix_client
This commit is contained in:
Jaidyn Ann 2023-12-30 02:28:16 +00:00 committed by GitHub
commit 4284a8bb23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 59 additions and 19 deletions

View File

@ -16,3 +16,18 @@ resource app_flags B_SINGLE_LAUNCH;
resource file_types message; resource file_types message;
resource vector_icon {
$"6E636966040500020106033D835C3C19B2BA8B0B3C20794769624A510E00FFFF"
$"FFB4FFE405FFFFA405020106023D835C3C19B2BA8B0B3C20794769624A510E00"
$"FFE405FFFFA405020106033D429E3C5148BB5ADA3C5C1B4A23AA46EC1800FFFF"
$"FFB47FE583FF04B10C0902093F404644383C273F2E3A244122482245224D2755"
$"245126572256245725582A5828592C5A315C2F5B345D3C5E385E425E4957475C"
$"4D4E02043F4044433D3FBC95BE953B3D333D3D493844424E4A5148534A4A0403"
$"3B2F4E2F4E2D4E2A4D2F532D522F530003334F334F364F345337533755325636"
$"59325602085645C8FEC3AFCA30C0E55E3A5E405EBA4D52B58359B71B4AB38537"
$"B51D3EB31FBA16B69933353130363E4A4641444D475346C657C27B554BCB01C6"
$"35584F5A4F080239BA0539BA6B0802BD1CBC1DBD2FBCA908023E37423904032E"
$"4535473C4739473F4540070A000100123FFFFE2FDACEAFDACE3FFFFE3AB6A5B8"
$"4CC101178400040A010100000A020101000A000202031001178210040A000104"
$"1001178400040A030104000A000407050608100117821004"
};

View File

@ -23,6 +23,8 @@
#include <ScrollView.h> #include <ScrollView.h>
#include <TranslationUtils.h> #include <TranslationUtils.h>
#include <stdio.h>
#include "AccountDialog.h" #include "AccountDialog.h"
#include "AccountsWindow.h" #include "AccountsWindow.h"
#include "AppMessages.h" #include "AppMessages.h"
@ -683,7 +685,12 @@ ConversationItem*
MainWindow::_EnsureConversationItem(BMessage* msg) MainWindow::_EnsureConversationItem(BMessage* msg)
{ {
BString chat_id = msg->FindString("chat_id"); BString chat_id = msg->FindString("chat_id");
Conversation* chat = Server::Get()->ConversationById(chat_id, msg->FindInt64("instance")); int64 conversation_id = msg->FindInt64("instance");
Conversation* chat = Server::Get()->ConversationById(chat_id, conversation_id);
if (chat == NULL) {
printf("error: Conversation %" B_PRId64 " in '%s' not found!\n", conversation_id, chat_id);
return NULL;
}
_EnsureConversationView(chat); _EnsureConversationView(chat);

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -1,19 +1,16 @@
resource vector_icon array { resource vector_icon array {
$"6E6369660E05000200060237E670B8880E39469D39AE144A52234B0D2500C6D7" $"6E636966040500020106033D835C3C19B2BA8B0B3C20794769624A510E00FFFF"
$"F5FF6B94DD03EC6666020006023B2B47BB18653D0FA53D225148297046CA1900" $"FFB4FFE405FFFFA405020106023D835C3C19B2BA8B0B3C20794769624A510E00"
$"FFEC4BFFF0A506020006023B3049396B0ABA90833C646E4A101543299500FFFF" $"FFE405FFFFA405020106033D429E3C5148BB5ADA3C5C1B4A23AA46EC1800FFFF"
$"FFFFFFF289020006023C71E33A0C78BA15E43C7D2149055549455700E3EDFFFF" $"FFB47FE583FF04B10C0902093F404644383C273F2E3A244122482245224D2755"
$"9EC2FF03FFACAC020006023A1DA6393F04BBB5BC3C6B074AEA3648091100F99B" $"245126572256245725582A5828592C5A315C2F5B345D3C5E385E425E4957475C"
$"05FFFCB23D03003CB00200060230B31E3A09B9BB024238A12F4BAB534AFF0B00" $"4D4E02043F4044433D3FBC95BE953B3D333D3D493844424E4A5148534A4A0403"
$"A3043CFFFFDCE603CD4D4D030D296402000602BD498B3E1159BF219BBE7D2F4B" $"3B2F4E2F4E2D4E2A4D2F532D522F530003334F334F364F345337533755325636"
$"E71F4AB31300C13E3EFFE27A7A0401740D0A06322E323E42464C3C4C2C3D260A" $"59325602085645C8FEC3AFCA30C0E55E3A5E405EBA4D52B58359B71B4AB38537"
$"04322E323E424642350A04322E42354C2C3D260A04423542464C3C4C2C0A0338" $"B51D3EB31FBA16B69933353130363E4A4641444D475346C657C27B554BCB01C6"
$"423C4D3C440A08335C395C41544F5C555C6051594D3E510A0422422252325A32" $"35584F5A4F080239BA0539BA6B0802BD1CBC1DBD2FBCA908023E37423904032E"
$"490A04224232493C402D3A0A043249325A3C503C400A043E42C35DC27AC751BE" $"4535473C4739473F4540070A000100123FFFFE2FDACEAFDACE3FFFFE3AB6A5B8"
$"F3493A0A04C35DC27A4E495840C751BEF30A05424BC08BC7B74E5A4E49C35DC2" $"4CC101178400040A010100000A020101000A000202031001178210040A000104"
$"7A0A053E423E52C08BC7B7424BC35DC27A100A0D0105000A0001003010340117" $"1001178400040A030104000A000407050608100117821004"
$"8400040A0101012010340A0801032010340A0B01042020210A010107000A0001"
$"00302C3401178400040A02010B000A0A010C000A090103202C340A06010A000A"
$"0C0109000A0001001001178400040A030101000A040102000A07010300"
}; };

View File

@ -65,7 +65,7 @@ RSRCS =
# - if your library does not follow the standard library naming scheme, # - if your library does not follow the standard library naming scheme,
# you need to specify the path to the library and it's name. # you need to specify the path to the library and it's name.
# (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") # (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a")
LIBS = be bnetapi localestub interface matrix_client network $(STDCPPLIBS) LIBS = be bnetapi localestub interface matrix_client spdlog network $(STDCPPLIBS)
# Specify additional paths to directories following the standard libXXX.so # Specify additional paths to directories following the standard libXXX.so
@ -116,7 +116,7 @@ SYMBOLS :=
DEBUGGER := DEBUGGER :=
# Specify any additional compiler flags to be used. # Specify any additional compiler flags to be used.
COMPILER_FLAGS = -std=c++17 COMPILER_FLAGS = -std=c++20 `pkg-config --cflags spdlog`
# Specify any additional linker flags to be used. # Specify any additional linker flags to be used.
LINKER_FLAGS = LINKER_FLAGS =

View File

@ -153,6 +153,12 @@ MatrixApp::StartLoop()
status.AddInt32("status", (int32)STATUS_ONLINE); status.AddInt32("status", (int32)STATUS_ONLINE);
SendMessage(status); SendMessage(status);
BMessage syncStatus(IM_MESSAGE);
syncStatus.AddInt32("im_what", IM_MESSAGE_RECEIVED);
syncStatus.AddString("user_name", APP_NAME);
syncStatus.AddString("body", B_TRANSLATE("Synchronizing with Matrix server. Please wait..."));
SendMessage(syncStatus);
mtx::http::SyncOpts opts; mtx::http::SyncOpts opts;
opts.timeout = 0; opts.timeout = 0;
client->sync(opts, &initial_sync_handler); client->sync(opts, &initial_sync_handler);
@ -276,6 +282,20 @@ room_sync(mtx::responses::Rooms rooms)
app->fRoomList.Add(BString(chat_id)); app->fRoomList.Add(BString(chat_id));
} }
// Grab the latest room metadata
BMessage metadataMsg(IM_MESSAGE);
metadataMsg.AddInt32("im_what", IM_ROOM_METADATA);
metadataMsg.AddString("chat_id", chat_id);
for (const auto &e : room.state.events) {
auto ev = std::get_if<mtx::events::StateEvent<mtx::events::state::Name>>(&e);
if (ev != nullptr) {
metadataMsg.AddString("chat_name", ev->content.name.c_str());
break;
}
}
((MatrixApp*)be_app)->SendMessage(metadataMsg);
// Grab the room timeline and add it
for (mtx::events::collections::TimelineEvents &ev : room.timeline.events) for (mtx::events::collections::TimelineEvents &ev : room.timeline.events)
if (auto event = std::get_if<mtx::events::RoomEvent<mtx::events::msg::Text>>(&ev); if (auto event = std::get_if<mtx::events::RoomEvent<mtx::events::msg::Text>>(&ev);
event != nullptr) event != nullptr)
@ -283,6 +303,7 @@ room_sync(mtx::responses::Rooms rooms)
BMessage msg(IM_MESSAGE); BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_MESSAGE_RECEIVED); msg.AddInt32("im_what", IM_MESSAGE_RECEIVED);
msg.AddString("body", event->content.body.c_str()); msg.AddString("body", event->content.body.c_str());
msg.AddInt64("when", event->origin_server_ts / 1000);
msg.AddString("chat_id", chat_id); msg.AddString("chat_id", chat_id);
msg.AddString("user_id", event->sender.c_str()); msg.AddString("user_id", event->sender.c_str());
app->SendMessage(msg); app->SendMessage(msg);