2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-15 16:19:11 +00:00

98_todoist.pm: bugfix title with space

git-svn-id: https://svn.fhem.de/fhem/trunk@27666 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
marvin78 2023-06-08 12:31:32 +00:00
parent 6c7885b065
commit 5d948d898b

View File

@ -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