-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[Help Wanted] dev/lubl/file-enum #12601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
25a82c1
feat: Remove ListedItem
lukeblevins 3ac895e
feat: Introduce watcher contract
lukeblevins c62e261
feat: improve existing watcher for item types
lukeblevins 90309a1
feat: dialog service for display by view model type
lukeblevins 575b4d9
feat: Initial ShellItemProperties
lukeblevins 3b30b76
feat: Initial ItemViewModel replacement work
lukeblevins ad1e735
chore: More from ItemViewModel
lukeblevins 27fa64b
chore: Resolve conflicts with main
lukeblevins bfe4725
add additonal functions, implement shellitem query search
lukeblevins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) 2023 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using Files.Sdk.Storage; | ||
|
||
namespace Files.App.Storage | ||
{ | ||
public abstract class StorableViewModel : ObservableObject | ||
{ | ||
public IStorable Storable { get; } | ||
|
||
public StorableViewModel(IStorable storable) | ||
{ | ||
this.Storable = storable; | ||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/Files.App.Storage/WindowsStorage/Win32/Helpers/AsyncManualResetEvent.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) 2023 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Files.App.Storage.WindowsStorage.Win32.Helpers | ||
{ | ||
public class AsyncManualResetEvent | ||
{ | ||
private volatile TaskCompletionSource<bool> m_tcs = new TaskCompletionSource<bool>(); | ||
|
||
public async Task WaitAsync(CancellationToken cancellationToken = default) | ||
{ | ||
var tcs = m_tcs; | ||
var cancelTcs = new TaskCompletionSource<bool>(); | ||
|
||
cancellationToken.Register( | ||
s => ((TaskCompletionSource<bool>)s!).TrySetCanceled(), cancelTcs); | ||
|
||
await await Task.WhenAny(tcs.Task, cancelTcs.Task); | ||
} | ||
|
||
private async Task<bool> Delay(int milliseconds) | ||
{ | ||
await Task.Delay(milliseconds); | ||
return false; | ||
} | ||
|
||
public async Task<bool> WaitAsync(int milliseconds, CancellationToken cancellationToken = default) | ||
{ | ||
var tcs = m_tcs; | ||
var cancelTcs = new TaskCompletionSource<bool>(); | ||
|
||
cancellationToken.Register( | ||
s => ((TaskCompletionSource<bool>)s!).TrySetCanceled(), cancelTcs); | ||
|
||
return await await Task.WhenAny(tcs.Task, cancelTcs.Task, Delay(milliseconds)); | ||
} | ||
|
||
public void Set() | ||
{ | ||
var tcs = m_tcs; | ||
Task.Factory.StartNew(s => ((TaskCompletionSource<bool>)s!).TrySetResult(true), | ||
tcs, CancellationToken.None, TaskCreationOptions.PreferFairness, TaskScheduler.Default); | ||
tcs.Task.Wait(); | ||
} | ||
|
||
public void Reset() | ||
{ | ||
var newTcs = new TaskCompletionSource<bool>(); | ||
while (true) | ||
{ | ||
var tcs = m_tcs; | ||
if (!tcs.Task.IsCompleted || | ||
Interlocked.CompareExchange(ref m_tcs, newTcs, tcs) == tcs) | ||
return; | ||
} | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/Files.App.Storage/WindowsStorage/Win32/Helpers/IntervalSampler.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2023 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
using System; | ||
|
||
namespace Files.App.Storage.WindowsStorage.Win32.Helpers | ||
{ | ||
internal class IntervalSampler | ||
{ | ||
private DateTime recordPoint; | ||
private TimeSpan sampleInterval; | ||
|
||
public IntervalSampler(int millisecondsInterval) | ||
{ | ||
sampleInterval = TimeSpan.FromMilliseconds(millisecondsInterval); | ||
recordPoint = DateTime.Now; | ||
} | ||
|
||
public IntervalSampler(TimeSpan interval) | ||
{ | ||
sampleInterval = interval; | ||
recordPoint = DateTime.Now; | ||
} | ||
|
||
public void Reset() | ||
{ | ||
recordPoint = DateTime.Now; | ||
} | ||
|
||
public bool CheckNow() | ||
{ | ||
var now = DateTime.Now; | ||
if (now - sampleInterval >= recordPoint) | ||
{ | ||
recordPoint = now; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be an extension method?