Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
4e09c599
Commit
4e09c599
authored
Aug 20, 2019
by
Kyle Keating
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Namespace the drafts module
parent
1e62dac0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
18 deletions
+12
-18
drafts.js
src/sidebar/store/modules/drafts.js
+12
-18
No files found.
src/sidebar/store/modules/drafts.js
View file @
4e09c599
...
...
@@ -9,9 +9,7 @@ const util = require('../util');
*/
function
init
()
{
return
{
drafts
:
[],
};
return
[];
}
/**
...
...
@@ -58,27 +56,21 @@ class Draft {
const
update
=
{
DISCARD_ALL_DRAFTS
:
function
()
{
return
{
drafts
:
[],
};
return
[];
},
REMOVE_DRAFT
:
function
(
state
,
action
)
{
const
drafts
=
state
.
drafts
.
filter
(
draft
=>
{
const
drafts
=
state
.
filter
(
draft
=>
{
return
!
draft
.
match
(
action
.
annotation
);
});
return
{
drafts
,
};
return
drafts
;
},
UPDATE_DRAFT
:
function
(
state
,
action
)
{
// removes a matching existing draft, then adds
const
drafts
=
state
.
drafts
.
filter
(
draft
=>
{
const
drafts
=
state
.
filter
(
draft
=>
{
return
!
draft
.
match
(
action
.
draft
.
annotation
);
});
drafts
.
push
(
action
.
draft
);
// push ok since its a copy
return
{
drafts
,
};
return
drafts
;
},
};
...
...
@@ -106,10 +98,10 @@ function createDraft(annotation, changes) {
function
deleteNewAndEmptyDrafts
()
{
const
annotations
=
require
(
'./annotations'
);
return
(
dispatch
,
getState
)
=>
{
const
newDrafts
=
getState
().
base
.
drafts
.
filter
(
draft
=>
{
const
newDrafts
=
getState
().
drafts
.
filter
(
draft
=>
{
return
(
metadata
.
isNew
(
draft
.
annotation
)
&&
!
getDraftIfNotEmpty
(
getState
()
.
base
,
draft
.
annotation
)
!
getDraftIfNotEmpty
(
getState
(),
draft
.
annotation
)
);
});
const
removedAnnotations
=
newDrafts
.
map
(
draft
=>
{
...
...
@@ -157,8 +149,9 @@ function countDrafts(state) {
* @return {Draft|null}
*/
function
getDraft
(
state
,
annotation
)
{
for
(
let
i
=
0
;
i
<
state
.
drafts
.
length
;
i
++
)
{
const
draft
=
state
.
drafts
[
i
];
const
drafts
=
state
.
drafts
;
for
(
let
i
=
0
;
i
<
drafts
.
length
;
i
++
)
{
const
draft
=
drafts
[
i
];
if
(
draft
.
match
(
annotation
))
{
return
draft
;
}
...
...
@@ -194,6 +187,7 @@ function unsavedAnnotations(state) {
module
.
exports
=
{
init
,
namespace
:
'drafts'
,
update
,
actions
:
{
createDraft
,
...
...
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