Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
883
Issues
883
List
Boards
Labels
Service Desk
Milestones
Merge Requests
49
Merge Requests
49
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Frontend
Commits
72c7b5f6
Commit
72c7b5f6
authored
18 hours ago
by
Ben Hayward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replacing old subscription
parent
13c1a2cd
fix/upload-cancel-2083
1 merge request
!587
[Sprint/PinkPanther](fix): Upload cancelling #2083
Pipeline
#88330105
canceled with stages
in 18 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
30 deletions
+30
-30
src/app/modules/newsfeed/poster/poster.component.ts
src/app/modules/newsfeed/poster/poster.component.ts
+0
-1
src/app/services/attachment.ts
src/app/services/attachment.ts
+30
-29
No files found.
src/app/modules/newsfeed/poster/poster.component.ts
View file @
72c7b5f6
...
...
@@ -236,7 +236,6 @@ export class PosterComponent {
removeAttachment
(
file
:
HTMLInputElement
)
{
if
(
this
.
inProgress
)
{
this
.
attachment
.
abort
();
this
.
attachment
.
progress
.
unsubscribe
();
this
.
canPost
=
true
;
this
.
inProgress
=
false
;
this
.
errorMessage
=
''
;
...
...
This diff is collapsed.
Click to expand it.
src/app/services/attachment.ts
View file @
72c7b5f6
...
...
@@ -6,7 +6,7 @@ import {
HttpEvent
,
HttpEventType
,
}
from
'
@angular/common/http
'
;
import
{
BehaviorSubject
}
from
'
rxjs
'
;
import
{
BehaviorSubject
,
of
}
from
'
rxjs
'
;
import
{
map
,
tap
,
last
}
from
'
rxjs/operators
'
;
import
{
Client
,
Upload
}
from
'
./api
'
;
...
...
@@ -19,13 +19,14 @@ export class AttachmentService {
public
progress
:
BehaviorSubject
<
number
>
=
new
BehaviorSubject
(
0
);
response
:
any
;
private
container
:
any
=
{};
private
accessId
:
any
=
2
;
private
previewTimeout
:
any
=
null
;
private
pendingDelete
:
boolean
=
false
;
uploadSubscription
:
any
;
private
xhr
:
XMLHttpRequest
=
null
;
static
_
(
session
:
Session
,
client
:
Client
,
upload
:
Upload
,
http
:
HttpClient
)
{
...
...
@@ -210,40 +211,40 @@ export class AttachmentService {
});
// Upload directly to S3
const
response
=
this
.
http
.
request
(
req
);
// Track upload progress && wait for completion
await
response
.
pipe
(
map
((
event
:
HttpEvent
<
any
>
,
file
)
=>
{
switch
(
event
.
type
)
{
case
HttpEventType
.
Sent
:
return
0
;
case
HttpEventType
.
UploadProgress
:
return
Math
.
round
((
100
*
event
.
loaded
)
/
event
.
total
);
case
HttpEventType
.
Response
:
return
100
;
default
:
return
-
1
;
}
}),
tap
(
pct
=>
{
if
(
pct
>=
0
)
this
.
progress
.
next
(
pct
);
}),
last
()
)
.
toPromise
();
// Complete the upload
await
this
.
clientService
.
put
(
`api/v2/media/upload/complete/
${
lease
.
media_type
}
/
${
lease
.
guid
}
`
const
upload$
=
this
.
http
.
request
(
req
);
// Track upload progress &&
const
uploadProgress$
=
upload$
.
pipe
(
map
((
event
:
HttpEvent
<
any
>
,
file
)
=>
{
switch
(
event
.
type
)
{
case
HttpEventType
.
Sent
:
return
0
;
case
HttpEventType
.
UploadProgress
:
return
Math
.
round
((
100
*
event
.
loaded
)
/
event
.
total
);
case
HttpEventType
.
Response
:
return
100
;
default
:
return
-
1
;
}
})
);
if
(
this
.
uploadSubscription
)
this
.
uploadSubscription
.
unsubscribe
();
this
.
uploadSubscription
=
uploadProgress$
.
subscribe
(
pct
=>
{
if
(
pct
>=
0
)
this
.
progress
.
next
(
pct
);
});
// wait for completion
await
uploadProgress$
.
pipe
(
last
()).
toPromise
();
return
lease
;
}
abort
()
{
if
(
this
.
xhr
)
{
this
.
progress
.
next
(
-
1
);
this
.
uploadSubscription
.
unsubscribe
();
this
.
xhr
.
abort
();
this
.
xhr
=
null
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment