Stars giveaways

This commit is contained in:
Ilya Laktyushin 2024-08-26 20:40:12 +04:00
parent 0f597d457e
commit 1867308531
3 changed files with 37 additions and 12 deletions

View File

@ -12837,3 +12837,10 @@ Sorry for the inconvenience.";
"Chat.Giveaway.Message.Stars.Stars_any" = "**%@** Stars";
"Chat.Giveaway.Message.Stars.Winners_1" = "to **%@** winner";
"Chat.Giveaway.Message.Stars.Winners_any" = "among **%@** winners";
"Chat.Giveaway.Info.Stars.Stars_1" = "**%@ Star**";
"Chat.Giveaway.Info.Stars.Stars_any" = "**%@ Stars**";
"Chat.Giveaway.Info.Stars.OngoingIntro" = "The giveaway is sponsored by the admins of **%1$@**, who acquired %2$@ for its followers.";
"Chat.Giveaway.Info.Stars.EndedIntro" = "The giveaway was sponsored by the admins of **%1$@**, who acquired %2$@ for its followers.";
"Chat.Giveaway.Info.Stars.Group.OngoingIntro" = "The giveaway is sponsored by the admins of **%1$@**, who acquired %2$@ for its members.";
"Chat.Giveaway.Info.Stars.Group.EndedIntro" = "The giveaway was sponsored by the admins of **%1$@**, who acquired %2$@ for its members.";

View File

@ -59,7 +59,6 @@ public func presentGiveawayInfoController(
stars = amount
}
}
let _ = stars
var prizeDescription: String?
if let giveaway {
@ -147,17 +146,36 @@ public func presentGiveawayInfoController(
title = presentationData.strings.Chat_Giveaway_Info_Title
let intro: String
if case .almostOver = status {
if isGroup {
intro = presentationData.strings.Chat_Giveaway_Info_Group_EndedIntro(peerName, presentationData.strings.Chat_Giveaway_Info_Subscriptions(quantity), presentationData.strings.Chat_Giveaway_Info_Months(months)).string
if stars > 0 {
let starsString = presentationData.strings.Chat_Giveaway_Info_Stars_Stars(Int32(stars))
if case .almostOver = status {
if isGroup {
intro = presentationData.strings.Chat_Giveaway_Info_Stars_Group_EndedIntro(peerName, starsString).string
} else {
intro = presentationData.strings.Chat_Giveaway_Info_Stars_EndedIntro(peerName, starsString).string
}
} else {
intro = presentationData.strings.Chat_Giveaway_Info_EndedIntro(peerName, presentationData.strings.Chat_Giveaway_Info_Subscriptions(quantity), presentationData.strings.Chat_Giveaway_Info_Months(months)).string
if isGroup {
intro = presentationData.strings.Chat_Giveaway_Info_Stars_Group_OngoingIntro(peerName, starsString).string
} else {
intro = presentationData.strings.Chat_Giveaway_Info_Stars_OngoingIntro(peerName, starsString).string
}
}
} else {
if isGroup {
intro = presentationData.strings.Chat_Giveaway_Info_Group_OngoingIntro(peerName, presentationData.strings.Chat_Giveaway_Info_Subscriptions(quantity), presentationData.strings.Chat_Giveaway_Info_Months(months)).string
let subscriptionsString = presentationData.strings.Chat_Giveaway_Info_Subscriptions(quantity)
let monthsString = presentationData.strings.Chat_Giveaway_Info_Months(months)
if case .almostOver = status {
if isGroup {
intro = presentationData.strings.Chat_Giveaway_Info_Group_EndedIntro(peerName, subscriptionsString, monthsString).string
} else {
intro = presentationData.strings.Chat_Giveaway_Info_EndedIntro(peerName, subscriptionsString, monthsString).string
}
} else {
intro = presentationData.strings.Chat_Giveaway_Info_OngoingIntro(peerName, presentationData.strings.Chat_Giveaway_Info_Subscriptions(quantity), presentationData.strings.Chat_Giveaway_Info_Months(months)).string
if isGroup {
intro = presentationData.strings.Chat_Giveaway_Info_Group_OngoingIntro(peerName, subscriptionsString, monthsString).string
} else {
intro = presentationData.strings.Chat_Giveaway_Info_OngoingIntro(peerName, subscriptionsString, monthsString).string
}
}
}

View File

@ -249,7 +249,7 @@ public func parseInternalUrl(sharedContext: SharedAccountContext, query: String)
return .share(url: url, text: text, to: to)
} else if peerName == "boost" {
for queryItem in queryItems {
if queryItem.name == "c", let value = queryItem.value, let channelId = Int64(value) {
if queryItem.name == "c", let value = queryItem.value, let channelId = Int64(value), channelId > 0 {
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
return .peer(.id(peerId), .boost)
}
@ -502,7 +502,7 @@ public func parseInternalUrl(sharedContext: SharedAccountContext, query: String)
} else if pathComponents[0] == "m" {
return .messageLink(slug: pathComponents[1])
} else if pathComponents.count == 3 && pathComponents[0] == "c" {
if let channelId = Int64(pathComponents[1]), let messageId = Int32(pathComponents[2]) {
if let channelId = Int64(pathComponents[1]), let messageId = Int32(pathComponents[2]), channelId > 0 {
var threadId: Int32?
var timecode: Double?
if let queryItems = components.queryItems {
@ -531,7 +531,7 @@ public func parseInternalUrl(sharedContext: SharedAccountContext, query: String)
return nil
}
} else if pathComponents.count == 4 && pathComponents[0] == "c" {
if let channelId = Int64(pathComponents[1]), let threadId = Int32(pathComponents[2]), let messageId = Int32(pathComponents[3]) {
if let channelId = Int64(pathComponents[1]), let threadId = Int32(pathComponents[2]), let messageId = Int32(pathComponents[3]), channelId > 0 {
var timecode: Double?
if let queryItems = components.queryItems {
for queryItem in queryItems {
@ -549,7 +549,7 @@ public func parseInternalUrl(sharedContext: SharedAccountContext, query: String)
return nil
}
} else if pathComponents.count == 2 && pathComponents[0] == "c" {
if let channelId = Int64(pathComponents[1]) {
if let channelId = Int64(pathComponents[1]), channelId > 0 {
var threadId: Int32?
var boost: Bool = false
if let queryItems = components.queryItems {