Skip to content

Commit

Permalink
Fixed an issue where the blocked contacts screen might not show values
Browse files Browse the repository at this point in the history
  • Loading branch information
mpretty-cyro committed Aug 5, 2024
1 parent 2685737 commit 6a838a4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Session.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8109,7 +8109,7 @@
CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 467;
CURRENT_PROJECT_VERSION = 468;
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -8187,7 +8187,7 @@
CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 467;
CURRENT_PROJECT_VERSION = 468;
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down
15 changes: 9 additions & 6 deletions Session/Shared/Types/ObservableTableSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,17 @@ public enum ObservationBuilder {
return TableObservation { viewModel, dependencies in
subject
.withPrevious(([], StagedChangeset()))
.filter { prev, next in
/// Suppress events with no changes (these will be sent in order to clear out the `StagedChangeset` value as if we
/// don't do so then resubscribing will result in an attempt to apply an invalid changeset to the `tableView` resulting
/// in a crash)
!next.1.isEmpty
}
.handleEvents(
receiveCancel: {
/// When we unsubscribe we send through the existing data but clear out the `StagedChangeset` value
/// so that resubscribing doesn't result in the UI trying to reapply the same changeset (which would cause a
/// crash due to invalid table view changes)
subject.send((subject.value.0, StagedChangeset()))
}
)
.map { _, current -> ([T], StagedChangeset<[T]>) in current }
.setFailureType(to: Error.self)
.shareReplay(1)
.eraseToAnyPublisher()
}
}
Expand Down
5 changes: 5 additions & 0 deletions Session/Shared/Views/SessionCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ public class SessionCell: UITableViewCell {
botSeparatorLeftConstraint = botSeparator.pin(.left, to: .left, of: cellBackgroundView)
botSeparatorRightConstraint = botSeparator.pin(.right, to: .right, of: cellBackgroundView)
botSeparator.pin(.bottom, to: .bottom, of: cellBackgroundView)

// Explicitly call this to ensure we have initialised the constraints before we initially
// layout (if we don't do this then some constraints get created for the first time when
// updating the cell before the `isActive` value gets set, resulting in breaking constriants)
prepareForReuse()
}

public override func layoutSubviews() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ internal extension LibSession {
let joinedAt: TimeInterval = {
guard let value: Int64 = group.joinedAt else { return 0 }

if value > 9_000_000_000_000 { // Microseconds (after May 1973)
if value > 9_000_000_000_000 { // Microseconds
return (Double(value) / 1_000_000)
} else if value > 9_000_000_000 { // Milliseconds (after September 2001)
} else if value > 9_000_000_000 { // Milliseconds
return (Double(value) / 1000)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1084,10 +1084,7 @@ public enum PagedData {
// No need to do anything if there were no changes
guard !changeset.isEmpty else { return }

// Need to send an event with the changes and then a second event to clear out the `StagedChangeset`
// value otherwise resubscribing will result with the changes coming through a second time
valueSubject?.send((updatedData, changeset))
valueSubject?.send((updatedData, StagedChangeset()))
}

// No need to dispatch to the next run loop if we are already on the main thread
Expand Down

0 comments on commit 6a838a4

Please sign in to comment.