Skip to content

Commit

Permalink
Release 1.9.0 (384)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis15yo committed Dec 2, 2024
1 parent fbf6ceb commit 96506ed
Show file tree
Hide file tree
Showing 147 changed files with 2,651 additions and 1,822 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.3.1
7.3.1:981f82a470bad1349322b6f51c9c6ffa0aa291dab1014fac411543c12e661dff
2 changes: 1 addition & 1 deletion .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
build:
runs-on: macos-14
runs-on: macos-15

steps:
- uses: webfactory/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
build:
runs-on: macos-14
runs-on: macos-15

steps:
- uses: webfactory/[email protected]
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
[submodule "third-party/webrtc/webrtc"]
path = third-party/webrtc/webrtc
url = https://github.com/nicegram/webrtc.git
[submodule "third-party/libx264/x264"]
path = third-party/libx264/x264
url = https://github.com/mirror/x264.git
[submodule "build-system/bazel-rules/rules_xcodeproj"]
path = build-system/bazel-rules/rules_xcodeproj
url = https://github.com/MobileNativeFoundation/rules_xcodeproj.git
Expand Down
20 changes: 10 additions & 10 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Nicegram/NGData/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ swift_library(
"//Nicegram/NGRequests:NGRequests",
"//Nicegram/NGLogging:NGLogging",
"//Nicegram/NGEnv:NGEnv",
"//Nicegram/NGAppCache:NGAppCache"
"//Nicegram/NGAppCache:NGAppCache",
"@swiftpkg_nicegram_assistant_ios//:NGCore",
],
visibility = [
"//visibility:public",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import Combine
import NGCore

class NicegramSettingsRepositoryImpl {

private let repo = UDRepository<NicegramSettings, NicegramSettingsDto>(
key: "nicegramSettings",
defaultValue: NicegramSettings(
disableAnimationsInChatList: false,
grayscaleAll: false,
grayscaleInChat: false,
grayscaleInChatList: false,
trackDigitalFootprint: false
),
toDomain: \.toDomain,
toDto: \.toDto
)
}

extension NicegramSettingsRepositoryImpl: NicegramSettingsRepository {
func settings() -> NicegramSettings {
repo.get()
}

func settingsPublisher() -> AnyPublisher<NicegramSettings, Never> {
repo.publisher()
}

func update(_ block: (NicegramSettings) -> (NicegramSettings)) async {
await repo.update(block)
}
}

private struct NicegramSettingsDto: Codable {
let disableAnimationsInChatList: Bool
let grayscaleAll: Bool
let grayscaleInChat: Bool
let grayscaleInChatList: Bool
let trackDigitalFootprint: Bool

var toDomain: NicegramSettings {
NicegramSettings(disableAnimationsInChatList: disableAnimationsInChatList, grayscaleAll: grayscaleAll, grayscaleInChat: grayscaleInChat, grayscaleInChatList: grayscaleInChatList, trackDigitalFootprint: trackDigitalFootprint)
}
}

private extension NicegramSettings {
var toDto: NicegramSettingsDto {
NicegramSettingsDto(disableAnimationsInChatList: disableAnimationsInChatList, grayscaleAll: grayscaleAll, grayscaleInChat: grayscaleInChat, grayscaleInChatList: grayscaleInChatList, trackDigitalFootprint: trackDigitalFootprint)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Combine

public class GetGrayscaleSettingsUseCase {

// MARK: - Dependencies

private let nicegramSettingsRepository: NicegramSettingsRepository

// MARK: - Lifecycle

init(nicegramSettingsRepository: NicegramSettingsRepository) {
self.nicegramSettingsRepository = nicegramSettingsRepository
}
}

public extension GetGrayscaleSettingsUseCase {
func grayscaleAllPublisher() -> AnyPublisher<Bool, Never> {
adjustedSetting(\.grayscaleAll)
}

func grayscaleInChatPublisher() -> AnyPublisher<Bool, Never> {
adjustedSetting(\.grayscaleInChat)
}

func grayscaleInChatListPublisher() -> AnyPublisher<Bool, Never> {
adjustedSetting(\.grayscaleInChatList)
}
}

private extension GetGrayscaleSettingsUseCase {
func adjustedSetting<T>(_ setting: @escaping (NicegramSettings) -> T) -> AnyPublisher<T, Never> {
nicegramSettingsRepository
.settingsPublisher()
.map { settings in
var result = settings
if result.grayscaleAll {
result.grayscaleInChat = false
result.grayscaleInChatList = false
}
return result
}
.map(setting)
.eraseToAnyPublisher()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Combine
import NGCore

public struct NicegramSettings: Withable {
public var disableAnimationsInChatList: Bool
public var grayscaleAll: Bool
public var grayscaleInChat: Bool
public var grayscaleInChatList: Bool
public var trackDigitalFootprint: Bool
}

public protocol NicegramSettingsRepository {
func settings() -> NicegramSettings
func settingsPublisher() -> AnyPublisher<NicegramSettings, Never>
func update(_: (NicegramSettings) -> (NicegramSettings)) async
}
24 changes: 24 additions & 0 deletions Nicegram/NGData/Sources/Modern/NicegramSettingsModule.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Factory

public final class NicegramSettingsModule: SharedContainer {
public static var shared = NicegramSettingsModule()
public var manager = ContainerManager()
}

extension NicegramSettingsModule {
public var getGrayscaleSettingsUseCase: Factory<GetGrayscaleSettingsUseCase> {
self { [self] in
GetGrayscaleSettingsUseCase(
nicegramSettingsRepository: nicegramSettingsRepository()
)
}
}
}

extension NicegramSettingsModule {
public var nicegramSettingsRepository: Factory<NicegramSettingsRepository> {
self {
NicegramSettingsRepositoryImpl()
}.cached
}
}
32 changes: 32 additions & 0 deletions Nicegram/NGData/Sources/Modern/Presentation/GrayscaleLayer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Combine
import UIKit

public class GrayscaleLayer: CALayer {
private var cancellables = Set<AnyCancellable>()

public init(
enablePublisher: AnyPublisher<Bool, Never>
) {
super.init()

self.isHidden = true
self.backgroundColor = UIColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 1.0).cgColor
self.compositingFilter = "colorBlendMode"

enablePublisher
.removeDuplicates()
.receive(on: DispatchQueue.main)
.sink { [weak self] enable in
self?.isHidden = !enable
}
.store(in: &cancellables)
}

public override init(layer: Any) {
super.init(layer: layer)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
private let nicegramSettingsRepository = NicegramSettingsModule.shared.nicegramSettingsRepository()

public func getNicegramSettings() -> NicegramSettings {
nicegramSettingsRepository.settings()
}

public func updateNicegramSettings(_ modifier: @escaping (inout NicegramSettings) -> Void) {
Task {
await nicegramSettingsRepository.update {
var result = $0
modifier(&result)
return result
}
}
}
9 changes: 9 additions & 0 deletions Nicegram/NGData/Sources/NGSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ public struct NGSettings {

@NGStorage(key: "feedPeer", defaultValue: [:])
public static var feedPeer: [Int64: PeerId]

@NGStorage(key: "hideBadgeCounters", defaultValue: false)
public static var hideBadgeCounters: Bool

@NGStorage(key: "hideUnreadCounters", defaultValue: false)
public static var hideUnreadCounters: Bool

@NGStorage(key: "hideMentionNotification", defaultValue: false)
public static var hideMentionNotification: Bool
}

public struct NGWebSettings {
Expand Down
Loading

0 comments on commit 96506ed

Please sign in to comment.