Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Swiftgram/SGSettingsUI/Sources/SGSettingsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private enum SGBoolSetting: String {
case foldersAtBottom
case startTelescopeWithRearCam
case hideStories
case hideAvatarStoryRing
case uploadSpeedBoost
case showProfileId
case warnOnStoriesOpen
Expand Down Expand Up @@ -206,6 +207,7 @@ private func SGControllerEntries(presentationData: PresentationData, callListSet

entries.append(.header(id: id.count, section: .stories, text: strings.AutoDownloadSettings_Stories.uppercased(), badge: nil))
entries.append(.toggle(id: id.count, section: .stories, settingName: .hideStories, value: SGSimpleSettings.shared.hideStories, text: i18n("Settings.Stories.Hide", lang), enabled: true))
entries.append(.toggle(id: id.count, section: .stories, settingName: .hideAvatarStoryRing, value: SGSimpleSettings.shared.hideAvatarStoryRing, text: i18n("Settings.Stories.HideAvatarStoryRing", lang), enabled: true))
entries.append(.toggle(id: id.count, section: .stories, settingName: .disableSwipeToRecordStory, value: SGSimpleSettings.shared.disableSwipeToRecordStory, text: i18n("Settings.Stories.DisableSwipeToRecord", lang), enabled: true))
entries.append(.toggle(id: id.count, section: .stories, settingName: .warnOnStoriesOpen, value: SGSimpleSettings.shared.warnOnStoriesOpen, text: i18n("Settings.Stories.WarnBeforeView", lang), enabled: true))
entries.append(.toggle(id: id.count, section: .stories, settingName: .showRepostToStory, value: SGSimpleSettings.shared.showRepostToStoryV2, text: strings.Share_RepostToStory.replacingOccurrences(of: "\n", with: " "), enabled: true))
Expand Down Expand Up @@ -400,6 +402,8 @@ public func sgSettingsController(context: AccountContext/*, focusOnItemTag: Int?
SGSimpleSettings.shared.startTelescopeWithRearCam = value
case .hideStories:
SGSimpleSettings.shared.hideStories = value
case .hideAvatarStoryRing:
SGSimpleSettings.shared.hideAvatarStoryRing = value
case .showProfileId:
SGSimpleSettings.shared.showProfileId = value
case .warnOnStoriesOpen:
Expand Down
5 changes: 5 additions & 0 deletions Swiftgram/SGSimpleSettings/Sources/SimpleSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public class SGSimpleSettings {
case wideTabBar
case tabBarSearchEnabled
case hideStories
case hideAvatarStoryRing
case warnOnStoriesOpen
case showProfileId
case sendWithReturnKey
Expand Down Expand Up @@ -326,6 +327,7 @@ public class SGSimpleSettings {
Keys.wideTabBar.rawValue: false,
Keys.tabBarSearchEnabled.rawValue: true,
Keys.hideStories.rawValue: false,
Keys.hideAvatarStoryRing.rawValue: false,
Keys.warnOnStoriesOpen.rawValue: false,
Keys.showProfileId.rawValue: true,
Keys.sendWithReturnKey.rawValue: false
Expand Down Expand Up @@ -383,6 +385,9 @@ public class SGSimpleSettings {
@UserDefault(key: Keys.hideStories.rawValue)
public var hideStories: Bool

@UserDefault(key: Keys.hideAvatarStoryRing.rawValue)
public var hideAvatarStoryRing: Bool

@UserDefault(key: Keys.warnOnStoriesOpen.rawValue)
public var warnOnStoriesOpen: Bool

Expand Down
1 change: 1 addition & 0 deletions Swiftgram/SGStrings/Strings/en.lproj/SGLocalizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"Settings.Profiles.Header" = "PROFILES";

"Settings.Stories.Hide" = "Hide Stories";
"Settings.Stories.HideAvatarStoryRing" = "Hide Avatar Story Ring";
"Settings.Stories.WarnBeforeView" = "Ask Before Viewing";
"Settings.Stories.DisableSwipeToRecord" = "Disable Swipe to Record";

Expand Down
7 changes: 6 additions & 1 deletion submodules/AvatarNode/BUILD
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

sgsrcs = [
"//Swiftgram/SGChatListSimpleSettingsSignal:SGChatListSimpleSettingsSignal",
]

swift_library(
name = "AvatarNode",
module_name = "AvatarNode",
srcs = glob([
"Sources/**/*.swift",
]),
]) + sgsrcs,
copts = [
"-warnings-as-errors",
],
Expand All @@ -24,6 +28,7 @@ swift_library(
"//submodules/ComponentFlow",
"//submodules/TelegramUI/Components/Stories/AvatarStoryIndicatorComponent",
"//submodules/DirectMediaImageCache",
"//Swiftgram/SGSimpleSettings:SGSimpleSettings",
],
visibility = [
"//visibility:public",
Expand Down
43 changes: 38 additions & 5 deletions submodules/AvatarNode/Sources/AvatarNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Accelerate
import ComponentFlow
import AvatarStoryIndicatorComponent
import DirectMediaImageCache
import SGSimpleSettings

private let deletedIcon = UIImage(bundleImageName: "Avatar/DeletedIcon")?.precomposed()
private let phoneIcon = generateTintedImage(image: UIImage(bundleImageName: "Avatar/PhoneIcon"), color: .white)
Expand Down Expand Up @@ -1183,6 +1184,10 @@ public final class AvatarNode: ASDisplayNode {
}

public private(set) var storyStats: StoryStats?
// MARK: Swiftgram
private var rawStoryStats: StoryStats?
private var hideAvatarStoryRingDisposable: MetaDisposable?
//

public var font: UIFont {
get {
Expand Down Expand Up @@ -1235,12 +1240,15 @@ public final class AvatarNode: ASDisplayNode {
}
self.updateStoryIndicator(transition: .immediate)
}

self.addSubnode(self.contentNode)
}

deinit {
self.cancelLoading()
// MARK: Swiftgram
self.hideAvatarStoryRingDisposable?.dispose()
//
}

override public var frame: CGRect {
Expand Down Expand Up @@ -1374,13 +1382,38 @@ public final class AvatarNode: ASDisplayNode {
}

public func setStoryStats(storyStats: StoryStats?, presentationParams: StoryPresentationParams, transition: ComponentTransition) {
if self.storyStats != storyStats || self.storyPresentationParams != presentationParams {
self.storyStats = storyStats
self.applyStoryStats(storyStats: storyStats, presentationParams: presentationParams, transition: transition)
}

// MARK: Swiftgram
private func applyStoryStats(storyStats: StoryStats?, presentationParams: StoryPresentationParams?, transition: ComponentTransition) {
self.rawStoryStats = storyStats
if storyStats != nil {
if self.hideAvatarStoryRingDisposable == nil {
let disposable = MetaDisposable()
self.hideAvatarStoryRingDisposable = disposable
disposable.set((sgSimpleSettingsBoolSignal(.hideAvatarStoryRing, defaultValue: false)
|> deliverOnMainQueue).startStrict(next: { [weak self] _ in
guard let self else {
return
}
self.applyStoryStats(storyStats: self.rawStoryStats, presentationParams: self.storyPresentationParams, transition: .immediate)
}))
}
} else {
self.hideAvatarStoryRingDisposable?.dispose()
self.hideAvatarStoryRingDisposable = nil
}

let filteredStoryStats = SGSimpleSettings.shared.hideAvatarStoryRing ? nil : storyStats
if self.storyStats != filteredStoryStats || self.storyPresentationParams != presentationParams {
self.storyStats = filteredStoryStats
self.storyPresentationParams = presentationParams

self.updateStoryIndicator(transition: transition)
}
}
//

public struct Colors: Equatable {
public var unseenColors: [UIColor]
Expand Down
4 changes: 3 additions & 1 deletion submodules/ChatListUI/Sources/Node/ChatListItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,9 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
lineWidth: 2.33,
inactiveLineWidth: 1.33
), transition: .immediate)
self.avatarNode.isUserInteractionEnabled = !item.useCommunityViewLayout && ((storyState != nil && !peerIsCommunity) || peerLinkedCommunityId != nil)
// MARK: Swiftgram
self.avatarNode.isUserInteractionEnabled = !item.useCommunityViewLayout && ((self.avatarNode.storyStats != nil && !peerIsCommunity) || peerLinkedCommunityId != nil)
//

if let stats = storyState?.stats, stats.hasLiveItems {
if self.avatarLiveBadge == nil {
Expand Down
4 changes: 3 additions & 1 deletion submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,9 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
strongSelf.avatarTapRecognizer = avatarTapRecognizer
strongSelf.avatarNode.view.addGestureRecognizer(avatarTapRecognizer)
}
strongSelf.avatarNode.isUserInteractionEnabled = item.storyStats != nil
// MARK: Swiftgram
strongSelf.avatarNode.isUserInteractionEnabled = strongSelf.avatarNode.storyStats != nil
//

let transition: ContainedViewLayoutTransition
if animated {
Expand Down