@@ -31,22 +31,24 @@ public struct MainTabFeature {
3131 var isLinkSheetPresented : Bool = false
3232 var isErrorSheetPresented : Bool = false
3333 var link : String ?
34-
34+
3535 var error : BaseError ?
36-
36+
3737 var path : StackState < MainTabPath . State > = . init( )
3838 var pokit : PokitRootFeature . State
3939 var remind : RemindFeature . State = . init( )
4040 @Presents var contentDetail : ContentDetailFeature . State ?
4141 @Shared ( . inMemory( " SelectCategory " ) ) var selectedPokit : BaseCategoryItem ?
42-
42+ @Shared ( . inMemory( " PushTapped " ) ) var isPushTapped : Bool = false
43+
4344 public init ( ) {
4445 self . pokit = . init( )
4546 }
4647 }
4748 /// - Action
4849 public enum Action : FeatureAction , BindableAction , ViewAction {
4950 case binding( BindingAction < State > )
51+ case pushAlertTapped( Bool )
5052 case view( View )
5153 case inner( InnerAction )
5254 case async ( AsyncAction )
@@ -93,6 +95,12 @@ public struct MainTabFeature {
9395 switch action {
9496 case . binding:
9597 return . none
98+ case let . pushAlertTapped( isTapped) :
99+ if isTapped {
100+ return . send( . delegate( . 알림함이동) )
101+ } else {
102+ return . none
103+ }
96104 /// - View
97105 case . view( let viewAction) :
98106 return handleViewAction ( viewAction, state: & state)
@@ -108,7 +116,7 @@ public struct MainTabFeature {
108116 /// - Delegate
109117 case . delegate( let delegateAction) :
110118 return handleDelegateAction ( delegateAction, state: & state)
111-
119+
112120 case . path:
113121 return . none
114122 case . pokit:
@@ -123,7 +131,7 @@ public struct MainTabFeature {
123131 public var body : some ReducerOf < Self > {
124132 Scope ( state: \. pokit, action: \. pokit) { PokitRootFeature ( ) }
125133 Scope ( state: \. remind, action: \. remind) { RemindFeature ( ) }
126-
134+
127135 BindingReducer ( )
128136 navigationReducer
129137 Reduce ( self . core)
@@ -140,42 +148,45 @@ private extension MainTabFeature {
140148 case . addButtonTapped:
141149 state. isBottomSheetPresented. toggle ( )
142150 return . none
143-
151+
144152 case . addSheetTypeSelected( let type) :
145153 state. isBottomSheetPresented = false
146154 switch type {
147155 case . 링크추가: return . send( . delegate( . 링크추가하기) )
148156 case . 포킷추가: return . send( . delegate( . 포킷추가하기) )
149157 }
150-
158+
151159 case . linkCopyButtonTapped:
152160 state. isLinkSheetPresented = false
153161 return . run { send in await send ( . delegate( . 링크추가하기) ) }
154162
155163 case . onAppear:
156- return . run { send in
157- let fromBanner = userDefaults. boolKey ( . fromBanner)
158- if fromBanner {
159- await userDefaults. removeBool ( . fromBanner)
160- await send ( . delegate( . 알림함이동) )
161- }
162-
163- for await _ in self . pasteBoard. changes ( ) {
164- let url = try await pasteBoard. probableWebURL ( )
165- await send ( . inner( . linkCopySuccess( url) ) , animation: . pokitSpring)
166- }
164+ if state. isPushTapped {
165+ return . send( . pushAlertTapped( true ) )
167166 }
167+ return . merge(
168+ . run { send in
169+ for await _ in self . pasteBoard. changes ( ) {
170+ let url = try await pasteBoard. probableWebURL ( )
171+ await send ( . inner( . linkCopySuccess( url) ) , animation: . pokitSpring)
172+ }
173+ } ,
174+ . publisher {
175+ state. $isPushTapped. publisher
176+ . map ( Action . pushAlertTapped)
177+ }
178+ )
168179 case . onOpenURL( url: let url) :
169180 guard let components = URLComponents ( url: url, resolvingAgainstBaseURL: false ) else {
170181 return . none
171182 }
172-
183+
173184 let queryItems = components. queryItems ?? [ ]
174185 guard let categoryIdString = queryItems. first ( where: { $0. name == " categoryId " } ) ? . value,
175186 let categoryId = Int ( categoryIdString) else {
176187 return . none
177188 }
178-
189+
179190 return . send( . async( . 공유받은_카테고리_조회( categoryId: categoryId) ) )
180191 case . 경고_확인버튼_클릭:
181192 state. error = nil
@@ -190,15 +201,15 @@ private extension MainTabFeature {
190201 state. isLinkSheetPresented = true
191202 state. link = url. absoluteString
192203 return . none
193-
204+
194205 case let . 경고_띄움( error) :
195206 state. error = error
196207 return . run { send in await send ( . inner( . errorSheetPresented( true ) ) ) }
197-
208+
198209 case let . errorSheetPresented( isPresented) :
199210 state. isErrorSheetPresented = isPresented
200211 return . none
201-
212+
202213 default : return . none
203214 }
204215 }
0 commit comments