@@ -27,43 +27,40 @@ internal static async ValueTask<Unit> RunAsync(
27
27
return await context . BotFlow . NextAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
28
28
}
29
29
30
- var chatFlow = await context . GetChatFlowAsync ( commandName , cancellationToken ) . ConfigureAwait ( false ) ;
30
+ var chatFlow = await InnerGetChatFlowAsync ( ) . ConfigureAwait ( false ) ;
31
31
if ( chatFlow is null )
32
32
{
33
33
return await context . BotFlow . NextAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
34
34
}
35
35
36
- var data = GetWebAppUpdateResponseJson ( context ) ;
37
-
38
- await chatFlow . RunFlow ( context , crmProjectApi , crmTimesheetApi , option , data ) . GetFlowStateAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
36
+ _ = await chatFlow . GetFlowStateAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
39
37
return await context . BotFlow . EndAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
40
- }
41
38
42
- private static async Task < ChatFlowStarter < TimesheetCreateFlowState > ? > GetChatFlowAsync (
43
- this IBotContext context , string commandName , CancellationToken cancellationToken )
44
- {
45
- var starter = context . GetChatFlowStarter < TimesheetCreateFlowState > ( "TimesheetCreate" ) ;
46
- if ( await starter . IsStartedAsync ( cancellationToken ) . ConfigureAwait ( false ) )
39
+ async Task < ChatFlow < TimesheetCreateFlowState > ? > InnerGetChatFlowAsync ( )
47
40
{
48
- return starter ;
49
- }
41
+ var starter = context . GetChatFlowStarter < TimesheetCreateFlowState > ( "TimesheetCreate" ) ;
42
+ if ( await starter . IsStartedAsync ( cancellationToken ) . ConfigureAwait ( false ) )
43
+ {
44
+ return starter . RunFlow ( context , crmProjectApi , crmTimesheetApi , option , default ) ;
45
+ }
50
46
51
- if ( context . TurnContext . RecognizeCommandOrAbsent ( commandName ) . IsPresent )
52
- {
53
- return starter ;
54
- }
47
+ if ( context . TurnContext . RecognizeCommandOrAbsent ( commandName ) . IsPresent )
48
+ {
49
+ return starter . RunFlow ( context , crmProjectApi , crmTimesheetApi , option , default ) ;
50
+ }
55
51
56
- var timesheet = GetWebAppUpdateResponseJson ( context ) ;
57
- if ( string . Equals ( timesheet ? . Command , "updatetimesheet" , StringComparison . InvariantCultureIgnoreCase ) )
58
- {
59
- await context . TurnContext . DeleteActivityAsync ( context . TurnContext . Activity . Id , cancellationToken ) . ConfigureAwait ( false ) ;
60
- return starter ;
61
- }
52
+ var timesheet = context . GetWebAppUpdateResponseJson ( ) ;
53
+ if ( string . Equals ( timesheet ? . Command , "updatetimesheet" , StringComparison . InvariantCultureIgnoreCase ) )
54
+ {
55
+ await context . TurnContext . DeleteActivityAsync ( context . TurnContext . Activity . Id , cancellationToken ) . ConfigureAwait ( false ) ;
56
+ return starter . RunFlow ( context , crmProjectApi , crmTimesheetApi , option , timesheet ) ;
57
+ }
62
58
63
- return null ;
59
+ return null ;
60
+ }
64
61
}
65
62
66
- private static WebAppDataTimesheetUpdateJson ? GetWebAppUpdateResponseJson ( IBotContext context )
63
+ private static WebAppDataTimesheetUpdateJson ? GetWebAppUpdateResponseJson ( this IBotContext context )
67
64
{
68
65
var dataWebApp = TelegramWebAppResponse . FromChannelData ( context . TurnContext . Activity . ChannelData ) ;
69
66
return JsonConvert . DeserializeObject < WebAppDataTimesheetUpdateJson > ( ( dataWebApp . Message ? . WebAppData ? . Data ) . OrEmpty ( ) ) ;
0 commit comments