1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-04-27 19:05:16 +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:
awu0403 2025-04-09 14:59:58 +08:00 committed by GitHub
parent 2e5b2797b3
commit 618f75ab13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 27 deletions

View File

@ -144,7 +144,7 @@ const FileTagsDialog = ({ record, onToggle, onSubmit }) => {
<ModalBody>
{isLoading ?
<CenteredLoading />
:
:
<div>
<div className="mb-6">
<div className='mb-1'>{gettext('Matching tags')}</div>

View File

@ -162,36 +162,48 @@ class LibContentView extends React.Component {
this.calculatePara(this.props);
}
onMessageCallback = (data) => {
if (data.type === 'file-lock-changed') {
const currentUrl = window.location.href;
const parsedUrl = new URL(currentUrl);
const pathParts = parsedUrl.pathname.split('/').filter(part => part.length > 0);
const dirRouter = decodeURIComponent(pathParts.slice(3).join('/'));
let notiUrlIndex = '';
if (data.content.path.includes('/')) {
notiUrlIndex = data.content.path.lastIndexOf('/');
}
const notifRouter = data.content.path.slice(0, notiUrlIndex);
if (dirRouter === notifRouter) {
const dirent = { name: data.content.path.split('/').pop() };
if (data.content.change_event === 'locked') {
if (data.content.expire === -1) {
this.updateDirent(dirent, 'is_freezed', true);
onMessageCallback = (noticeData) => {
/**
* noticeData structure:
* {
* type: 'file-lock-changed', // opertaion type
* content: {}
* }
*/
if (noticeData.type === 'file-lock-changed') {
const getFilePath = (noticeData) => {
if (!noticeData.content || !noticeData.content.path) {
return '';
}
const path = noticeData.content.path.replace(/^\/+/, '');
const lastSlashIndex = path.lastIndexOf('/');
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 {
this.updateDirent(dirent, 'is_freezed', false);
this.updateDirent(fileNameObj, 'is_freezed', false);
}
this.updateDirent(dirent, 'is_locked', true);
this.updateDirent(dirent, 'locked_by_me', true);
let lockName = data.content.lock_user.split('@');
this.updateDirent(dirent, 'lock_owner_name', lockName[0]);
} else if (data.content.change_event === 'unlocked') {
this.updateDirent(dirent, 'is_locked', false);
this.updateDirent(dirent, 'locked_by_me', false);
this.updateDirent(dirent, 'lock_owner_name', '');
this.updateDirent(fileNameObj, 'is_locked', true);
this.updateDirent(fileNameObj, 'locked_by_me', true);
let lockOwnerName = noticeData.content.lock_user.split('@')[0];
this.updateDirent(fileNameObj, 'lock_owner_name', lockOwnerName);
} else if (noticeData.content.change_event === 'unlocked') {
this.updateDirent(fileNameObj, 'is_locked', false);
this.updateDirent(fileNameObj, 'locked_by_me', false);
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 => {
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);