-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip(bookmark): 修复
Refactor
指令中的Move to new file
书签异常问题
- Loading branch information
Showing
2 changed files
with
69 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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 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,37 @@ | ||
import {types} from 'mobx-state-tree'; | ||
|
||
export const LockerItem = types.model('LockerItem', { | ||
bookmarks: types.array(types.string), | ||
fileId: types.string, | ||
}); | ||
|
||
export const Locker = types | ||
.model('locker', { | ||
didCreate: types.array(LockerItem), | ||
}) | ||
.actions(self => { | ||
return { | ||
updateDidCreate(fileId: string, bookmarks: string[]) { | ||
const existing = self.didCreate.find(it => it.fileId === fileId); | ||
if (!existing) { | ||
self.didCreate.push({ | ||
fileId, | ||
bookmarks, | ||
}); | ||
} else { | ||
bookmarks.forEach(it => { | ||
if (!existing.bookmarks.find(item => item === it)) { | ||
existing.bookmarks.push(it); | ||
} | ||
}); | ||
} | ||
}, | ||
removeDidCreateByFileId(fileId: string) { | ||
const existing = self.didCreate.find(it => it.fileId === fileId); | ||
if (!existing) { | ||
return; | ||
} | ||
self.didCreate.remove(existing); | ||
}, | ||
}; | ||
}); |