mirror of
https://github.com/haiwen/seahub.git
synced 2025-04-28 03:10:45 +00:00
Fix real lock (#7721)
* update * fix get dirRouter * Update lib-content-view.js * Update lib-content-view.js * Update lib-content-view.js * update name * Update lib-content-view.js --------- Co-authored-by: 孙永强 <11704063+s-yongqiang@user.noreply.gitee.com>
This commit is contained in:
parent
2e5b2797b3
commit
618f75ab13
@ -144,7 +144,7 @@ const FileTagsDialog = ({ record, onToggle, onSubmit }) => {
|
|||||||
<ModalBody>
|
<ModalBody>
|
||||||
{isLoading ?
|
{isLoading ?
|
||||||
<CenteredLoading />
|
<CenteredLoading />
|
||||||
:
|
:
|
||||||
<div>
|
<div>
|
||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
<div className='mb-1'>{gettext('Matching tags')}</div>
|
<div className='mb-1'>{gettext('Matching tags')}</div>
|
||||||
|
@ -162,36 +162,48 @@ class LibContentView extends React.Component {
|
|||||||
this.calculatePara(this.props);
|
this.calculatePara(this.props);
|
||||||
}
|
}
|
||||||
|
|
||||||
onMessageCallback = (data) => {
|
onMessageCallback = (noticeData) => {
|
||||||
if (data.type === 'file-lock-changed') {
|
/**
|
||||||
const currentUrl = window.location.href;
|
* noticeData structure:
|
||||||
const parsedUrl = new URL(currentUrl);
|
* {
|
||||||
const pathParts = parsedUrl.pathname.split('/').filter(part => part.length > 0);
|
* type: 'file-lock-changed', // opertaion type
|
||||||
const dirRouter = decodeURIComponent(pathParts.slice(3).join('/'));
|
* content: {}
|
||||||
let notiUrlIndex = '';
|
* }
|
||||||
if (data.content.path.includes('/')) {
|
*/
|
||||||
notiUrlIndex = data.content.path.lastIndexOf('/');
|
if (noticeData.type === 'file-lock-changed') {
|
||||||
}
|
const getFilePath = (noticeData) => {
|
||||||
const notifRouter = data.content.path.slice(0, notiUrlIndex);
|
if (!noticeData.content || !noticeData.content.path) {
|
||||||
if (dirRouter === notifRouter) {
|
return '';
|
||||||
const dirent = { name: data.content.path.split('/').pop() };
|
}
|
||||||
if (data.content.change_event === 'locked') {
|
const path = noticeData.content.path.replace(/^\/+/, '');
|
||||||
if (data.content.expire === -1) {
|
const lastSlashIndex = path.lastIndexOf('/');
|
||||||
this.updateDirent(dirent, 'is_freezed', true);
|
return lastSlashIndex === -1 ? '' : path.slice(0, lastSlashIndex);
|
||||||
|
};
|
||||||
|
|
||||||
|
let currentPath = this.state.path;
|
||||||
|
currentPath = currentPath.slice(1); // remove the leading '/'
|
||||||
|
const noticeFilePath = getFilePath(noticeData);
|
||||||
|
|
||||||
|
if (currentPath === noticeFilePath) {
|
||||||
|
// update file status
|
||||||
|
const fileNameObj = { name: noticeData.content.path.split('/').pop() };
|
||||||
|
if (noticeData.content.change_event === 'locked') {
|
||||||
|
if (noticeData.content.expire === -1) {
|
||||||
|
this.updateDirent(fileNameObj, 'is_freezed', true);
|
||||||
} else {
|
} else {
|
||||||
this.updateDirent(dirent, 'is_freezed', false);
|
this.updateDirent(fileNameObj, 'is_freezed', false);
|
||||||
}
|
}
|
||||||
this.updateDirent(dirent, 'is_locked', true);
|
this.updateDirent(fileNameObj, 'is_locked', true);
|
||||||
this.updateDirent(dirent, 'locked_by_me', true);
|
this.updateDirent(fileNameObj, 'locked_by_me', true);
|
||||||
let lockName = data.content.lock_user.split('@');
|
let lockOwnerName = noticeData.content.lock_user.split('@')[0];
|
||||||
this.updateDirent(dirent, 'lock_owner_name', lockName[0]);
|
this.updateDirent(fileNameObj, 'lock_owner_name', lockOwnerName);
|
||||||
} else if (data.content.change_event === 'unlocked') {
|
} else if (noticeData.content.change_event === 'unlocked') {
|
||||||
this.updateDirent(dirent, 'is_locked', false);
|
this.updateDirent(fileNameObj, 'is_locked', false);
|
||||||
this.updateDirent(dirent, 'locked_by_me', false);
|
this.updateDirent(fileNameObj, 'locked_by_me', false);
|
||||||
this.updateDirent(dirent, 'lock_owner_name', '');
|
this.updateDirent(fileNameObj, 'lock_owner_name', '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (data.type === 'repo-update') {
|
} else if (noticeData.type === 'repo-update') {
|
||||||
seafileAPI.listDir(this.props.repoID, this.state.path, { 'with_thumbnail': true }).then(res => {
|
seafileAPI.listDir(this.props.repoID, this.state.path, { 'with_thumbnail': true }).then(res => {
|
||||||
const { dirent_list, user_perm: userPerm, dir_id: dirID } = res.data;
|
const { dirent_list, user_perm: userPerm, dir_id: dirID } = res.data;
|
||||||
const direntList = Utils.sortDirents(dirent_list.map(item => new Dirent(item)), this.state.sortBy, this.state.sortOrder);
|
const direntList = Utils.sortDirents(dirent_list.map(item => new Dirent(item)), this.state.sortBy, this.state.sortOrder);
|
||||||
|
Loading…
Reference in New Issue
Block a user