Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Refactor code after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdulbaqi-Alshareef committed Jun 18, 2020
1 parent b18e3b3 commit f1f9bd8
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/toggl_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -986,8 +986,7 @@ extern "C" {
const char_t *tags,
const bool_t prevent_on_app,
const uint64_t started,
const uint64_t ended,
const bool_t stop_current_running);
const uint64_t ended);

// Create an Empty Time Entry without stopping the running TE
TOGGL_EXPORT char_t *toggl_create_empty_time_entry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void UndoDeletion()
if (CanUndo)
{
var te = undoStack.Pop();
Toggl.Start(te.Description, te.Duration, te.TID, te.PID, "", te.Tags, true, te.Started, te.Ended, false);
Toggl.StartWithCurrentRunning(te.Description, te.Duration, te.TID, te.PID, "", te.Tags, true, te.Started, te.Ended, false);
if (te.Billable)
Toggl.SetTimeEntryBillable(te.GUID, te.Billable);
}
Expand Down
39 changes: 31 additions & 8 deletions src/ui/windows/TogglDesktop/TogglDesktop/Toggl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,17 +516,41 @@ public static bool SetLoggedInUser(string json) {
return testing_set_logged_in_user(ctx, json);
}

public static string Start(
public static string StartWithCurrentRunning(
string description,
string duration,
UInt64 task_id,
UInt64 project_id,
string project_guid,
string tags,
bool preventOnApp,
ulong started,
ulong ended,
bool stop_current_running)
{
OnUserTimeEntryStart();

return toggl_start_with_current_running(ctx,
description,
duration,
task_id,
project_id,
project_guid,
tags,
preventOnApp,
started,
ended,
stop_current_running);
}

public static string Start(
string description,
string duration,
UInt64 task_id,
UInt64 project_id,
string project_guid,
string tags,
bool preventOnApp = false,
ulong started = 0,
ulong ended = 0,
bool stop_current_running = true)
bool preventOnApp = false)
{
OnUserTimeEntryStart();

Expand All @@ -538,9 +562,8 @@ public static string Start(
project_guid,
tags,
preventOnApp,
started,
ended,
stop_current_running);
0,
0);
}

public static string AddProject(
Expand Down
21 changes: 20 additions & 1 deletion src/ui/windows/TogglDesktop/TogglDesktop/TogglApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,7 @@ private static extern bool toggl_clear_cache(

// returns GUID of the started time entry. you must free() the result
[DllImport(dll, CharSet = charset, CallingConvention = convention)]
private static extern string toggl_start(
private static extern string toggl_start_with_current_running(
IntPtr context,
[MarshalAs(UnmanagedType.LPWStr)]
string description,
Expand All @@ -1496,6 +1496,25 @@ private static extern string toggl_start(
UInt64 ended,
bool stop_current_running);

// returns GUID of the started time entry. you must free() the result
[DllImport(dll, CharSet = charset, CallingConvention = convention)]
private static extern string toggl_start(
IntPtr context,
[MarshalAs(UnmanagedType.LPWStr)]
string description,
[MarshalAs(UnmanagedType.LPWStr)]
string duration,
UInt64 task_id,
UInt64 project_id,
[MarshalAs(UnmanagedType.LPWStr)]
string project_guid,
[MarshalAs(UnmanagedType.LPWStr)]
string tags,
[MarshalAs(UnmanagedType.I1)]
bool prevent_on_app,
UInt64 started,
UInt64 ended);

// Create an Empty Time Entry without stopping the running TE
[DllImport(dll, CharSet = charset, CallingConvention = convention)]
private static extern string toggl_create_empty_time_entry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public TimeEntryListViewModel()
.Select(x => !x)
.ToPropertyEx(this, x => x.IsViewEnabled);

UndoCommand = ReactiveCommand.Create(()=>OnUndo());
UndoCommand = ReactiveCommand.Create(OnUndo);
}

public void OnUndo() =>
Expand Down

0 comments on commit f1f9bd8

Please sign in to comment.