@@ -450,23 +450,8 @@ export default {
450450 )
451451
452452 for (const share of shares) {
453- if ([ShareType .Link , ShareType .Email ].includes (share .type )) {
454- this .linkShares .push (share)
455- } else if ([ShareType .Remote , ShareType .RemoteGroup ].includes (share .type )) {
456- if (this .config .showFederatedSharesToTrustedServersAsInternal ) {
457- if (share .isTrustedServer ) {
458- this .shares .push (share)
459- } else {
460- this .externalShares .push (share)
461- }
462- } else if (this .config .showFederatedSharesAsInternal ) {
463- this .shares .push (share)
464- } else {
465- this .externalShares .push (share)
466- }
467- } else {
468- this .shares .push (share)
469- }
453+ const shareList = this .findShareListByShare (share)
454+ shareList .push (share)
470455 }
471456
472457 logger .debug (` Processed ${ this .linkShares .length } link share(s)` )
@@ -529,24 +514,8 @@ export default {
529514 * @param {Function} [resolve] a function to run after the share is added and its component initialized
530515 */
531516 addShare (share, resolve = () => { }) {
532- // only catching share type MAIL as link shares are added differently
533- // meaning: not from the ShareInput
534- if (share .type === ShareType .Email ) {
535- this .linkShares .unshift (share)
536- } else if ([ShareType .Remote , ShareType .RemoteGroup ].includes (share .type )) {
537- if (this .config .showFederatedSharesAsInternal ) {
538- this .shares .unshift (share)
539- }
540- if (this .config .showFederatedSharesToTrustedServersAsInternal ) {
541- if (share .isTrustedServer ) {
542- this .shares .unshift (share)
543- }
544- } else {
545- this .externalShares .unshift (share)
546- }
547- } else {
548- this .shares .unshift (share)
549- }
517+ const shareList = this .findShareListByShare (share)
518+ shareList .unshift (share)
550519 this .awaitForShare (share, resolve)
551520 },
552521
@@ -556,12 +525,26 @@ export default {
556525 * @param {Share} share the share to remove
557526 */
558527 removeShare (share ) {
559- // Get reference for this.linkShares or this.shares
560- const shareList
561- = share .type === ShareType .Email
562- || share .type === ShareType .Link
563- ? this .linkShares
564- : this .shares
528+ this .removeShareFromList (this .findShareListByShare (share), share)
529+ },
530+
531+ findShareListByShare (share ) {
532+ if (share .type === ShareType .Remote || share .type === ShareType .RemoteGroup ) {
533+ if (this .config .showFederatedSharesToTrustedServersAsInternal ) {
534+ return share .isTrustedServer ? this .shares : this .externalShares
535+ } else if (this .config .showFederatedSharesAsInternal ) {
536+ return this .shares
537+ } else {
538+ return this .externalShares
539+ }
540+ } else if (share .type === ShareType .Email || share .type === ShareType .Link ) {
541+ return this .linkShares
542+ } else {
543+ return this .shares
544+ }
545+ },
546+
547+ removeShareFromList (shareList , share ) {
565548 const index = shareList .findIndex ((item ) => item .id === share .id )
566549 if (index !== - 1 ) {
567550 shareList .splice (index, 1 )
0 commit comments