summaryrefslogtreecommitdiff
path: root/Sora/Data/ColumnsDataCache.swift
blob: bec37fbc250fc8479a3f7d118cf7977aaa275cf2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
struct ColumnsDataCache: Equatable {
  let data: [[BooruPost]]
  let columnCount: Int
  let posts: [BooruPost]

  static func == (lhs: Self, rhs: Self) -> Bool {
    guard lhs.columnCount == rhs.columnCount else { return false }
    guard lhs.posts.count == rhs.posts.count else { return false }
    guard !lhs.posts.isEmpty, !rhs.posts.isEmpty else {
      return lhs.posts.isEmpty == rhs.posts.isEmpty
    }
    guard lhs.posts.first?.id == rhs.posts.first?.id else { return false }
    guard lhs.posts.last?.id == rhs.posts.last?.id else { return false }

    return true
  }
}