mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-24 22:45:19 +00:00
Update logging to only write to disk on macOS
- Add conditional compilation to LoggingService - macOS continues to write logs to Documents/Logs - iOS uses /dev/null to prevent disk writes - Remove room auto-join on mention (only join when sending to room)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 54;
|
||||
objectVersion = 63;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
@@ -39,7 +39,7 @@
|
||||
763E0DBA9492A654FC0CDCB9 /* AppInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppInfoView.swift; sourceTree = "<group>"; };
|
||||
7EEBDA723E1CFD88758DA4AC /* bitchat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
96CDF6D0AF0F2052A6C7E634 /* LoggingService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggingService.swift; sourceTree = "<group>"; };
|
||||
997D512074C64904D75DDD40 /* bitchat.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
997D512074C64904D75DDD40 /* bitchat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A08E03AA0C63E97C91749AEC /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
A2136C3E22D02D4A8DBE7EAB /* BinaryProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BinaryProtocol.swift; sourceTree = "<group>"; };
|
||||
D5C3D880FF8AE1673B20E1E3 /* BluetoothMeshService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BluetoothMeshService.swift; sourceTree = "<group>"; };
|
||||
@@ -183,7 +183,6 @@
|
||||
);
|
||||
mainGroup = 18198ED912AAF495D8AF7763;
|
||||
minimizedProjectReferenceProxies = 1;
|
||||
preferredProjectObjectVersion = 54;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
@@ -259,6 +258,7 @@
|
||||
CODE_SIGNING_REQUIRED = YES;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = bitchat/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
@@ -285,6 +285,7 @@
|
||||
CODE_SIGNING_REQUIRED = YES;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = bitchat/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
|
||||
@@ -22,6 +22,8 @@ class LoggingService {
|
||||
dateFormatter = DateFormatter()
|
||||
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
|
||||
|
||||
#if os(macOS)
|
||||
// Only create log files on macOS
|
||||
// Get documents directory
|
||||
let documentsPath = FileManager.default.urls(for: .documentDirectory,
|
||||
in: .userDomainMask).first!
|
||||
@@ -45,6 +47,10 @@ class LoggingService {
|
||||
|
||||
log("=== BitChat Started ===")
|
||||
log("Log file: \(fileURL.path)")
|
||||
#else
|
||||
// On iOS, just create a dummy URL since we won't write to disk
|
||||
fileURL = URL(fileURLWithPath: "/dev/null")
|
||||
#endif
|
||||
}
|
||||
|
||||
func log(_ message: String, category: String = "general") {
|
||||
|
||||
@@ -261,10 +261,10 @@ class ChatViewModel: ObservableObject {
|
||||
messages.append(message)
|
||||
}
|
||||
|
||||
// Auto-join any new rooms mentioned in the message
|
||||
for room in rooms {
|
||||
if !joinedRooms.contains(room) {
|
||||
joinRoom(room)
|
||||
// Only auto-join rooms if we're sending TO that room
|
||||
if let messageRoom = messageRoom {
|
||||
if !joinedRooms.contains(messageRoom) {
|
||||
joinRoom(messageRoom)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,6 +631,8 @@ class ChatViewModel: ObservableObject {
|
||||
|
||||
extension ChatViewModel: BitchatDelegate {
|
||||
func didReceiveMessage(_ message: BitchatMessage) {
|
||||
bitchatLog("Received message from \(message.sender), room: \(message.room ?? "nil"), senderPeerID: \(message.senderPeerID ?? "nil")", category: "message")
|
||||
|
||||
if message.isPrivate {
|
||||
// Handle private message
|
||||
|
||||
@@ -675,7 +677,7 @@ extension ChatViewModel: BitchatDelegate {
|
||||
roomMessages[room]?.append(message)
|
||||
roomMessages[room]?.sort { $0.timestamp < $1.timestamp }
|
||||
|
||||
// Track room members
|
||||
// Track room members - only track the sender as a member
|
||||
if roomMembers[room] == nil {
|
||||
roomMembers[room] = []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user