From 5d948d898ba70af5acfe832a9e99c36351d3e7ee Mon Sep 17 00:00:00 2001 From: marvin78 Date: Thu, 8 Jun 2023 12:31:32 +0000 Subject: [PATCH] 98_todoist.pm: bugfix title with space git-svn-id: https://svn.fhem.de/fhem/trunk@27666 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_todoist.pm | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/fhem/FHEM/98_todoist.pm b/fhem/FHEM/98_todoist.pm index 68b7d1386..ebcbeb60a 100644 --- a/fhem/FHEM/98_todoist.pm +++ b/fhem/FHEM/98_todoist.pm @@ -17,7 +17,13 @@ eval "use Date::Parse;1" or $missingModule .= "Date::Parse "; ####################### # Global variables +<<<<<<< .mine +my $version = "1.3.25"; +||||||| .r26953 +my $version = "1.3.15"; +======= my $version = "1.3.24"; +>>>>>>> .r27665 my $apiUrl = "https://api.todoist.com/sync/v9/"; my $srandUsed; @@ -386,7 +392,14 @@ sub todoist_UpdateTask($$$) { my $tid; ## get Task-ID +<<<<<<< .mine $tid = @$a[0]; + +||||||| .r26953 + my $tid = @$a[0]; +======= + $tid = @$a[0]; +>>>>>>> .r27665 ## check if ID is todoist ID (ID:.*) or title (TITLE:.*) my @temp=split(":",$tid); @@ -400,13 +413,28 @@ sub todoist_UpdateTask($$$) { ## use task content elsif (@temp && $temp[0] =~ /title/i) { $title = encode_utf8($temp[1]); +<<<<<<< .mine + my $nTitle = $title; + $nTitle =~ s/ /_/g; + $taskId = $hash->{helper}{"TITLES"}{$nTitle} if ($hash->{helper}{"TITLES"}); + } + elsif (defined($h->{"title"}) || defined($h->{"TITLE"}) || defined($h->{"Title"})) { + Log3 $name, 5, "todoist ($name): Debug: ".Dumper($h); + $title = $h->{"title"} if ($h->{"title"}); +||||||| .r26953 + $title = $h->{"title"} if ($h->{"title"}); +======= $taskId = $hash->{helper}{"TITLES"}{$title} if ($hash->{helper}{"TITLES"}); } elsif (defined($h->{"title"}) || defined($h->{"TITLE"}) || defined($h->{"Title"})) { $title = $h->{"title"} if ($h->{"title"}); +>>>>>>> .r27665 $title = $h->{"TITLE"} if ($h->{"TITLE"}); $title = $h->{"Title"} if ($h->{"Title"}); - $taskId = $hash->{helper}{"TITLES"}{$title} if ($hash->{helper}{"TITLES"}); + my $nTitle = $title; + $nTitle =~ s/ /_/g; + Log3 $name, 5, "todoist ($name): Debug: ".$nTitle; + $taskId = $hash->{helper}{"TITLES"}{$nTitle} if ($hash->{helper}{"TITLES"}); } ## use Task-Number else { @@ -1214,11 +1242,15 @@ sub todoist_GetTasksCallback($$$){ readingsBulkUpdate($hash, $prefix.$t,$title); readingsBulkUpdate($hash, $prefix.$t."_ID",$taskID) if (AttrVal($name,"hideId",0)!=1); + + # convert title + my $nTitle = $title; + $nTitle=~s/ /_/g; ## a few helper for ID and revision $hash->{helper}{"IDS"}{"Task_".$i}=$taskID; # todoist Task-ID $hash->{helper}{"TITLE"}{$taskID}=$title; # Task title (content) - $hash->{helper}{"TITLES"}{$title}=$taskID; # Task title (content) + $hash->{helper}{"TITLES"}{$nTitle}=$taskID; # Task title (content) $hash->{helper}{"WID"}{$taskID}=$i; # FHEM Task-ID $hash->{helper}{"parent_id"}{$taskID}=$task->{parent_id}; # parent_id of item $hash->{helper}{"section_id"}{$taskID}=$task->{section_id}; # section_id of item